This is a migrated thread and some comments may be shown as answers.

RadLegend is not working with RadCartesianChart

1 Answer 111 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Hady
Top achievements
Rank 2
Hady asked on 31 Oct 2018, 03:41 PM

I tried to build a code sample with RadLegend but it throws an exception. i attached my code sample 

 

{Com.Telerik.Android.Common.Exceptions.MissingLayoutPartException: Layout part with id com.companyname.TelerikChart:id/notification_background is missing from the specified layout.  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <034d4a9852dd45bea9353cc7776c99f0>:0   at Java.Interop.JniPeerMembers+JniInstanceMethods.FinishCreateInstance (System.String constructorSignature, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0004f] in <034d4a9852dd45bea9353cc7776c99f0>:0   at Com.Telerik.Widget.Primitives.Legend.RadLegendView..ctor (Android.Content.Context p0) [0x0007a] in <3df33cbb9c2a44bbb60084f618a2993d>:0   at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <43dbbdc147f2482093d8409abb04c233>:0   --- End of managed Com.Telerik.Android.Common.Exceptions.MissingLayoutPartException stack trace ---com.telerik.android.common.exceptions.MissingLayoutPartException: Layout part with id com.companyname.TelerikChart:id/notification_background is missing from the specified layout. at com.telerik.android.common.Util.getLayoutPart(Util.java:139) at com.telerik.android.common.Util.getLayoutPart(Util.java:118) at com.telerik.widget.primitives.legend.RadLegendView.<init>(RadLegendView.java:80) at com.telerik.widget.primitives.legend.RadLegendView.<init>(RadLegendView.java:48) at md573f120baf816a4fba7033ee5f3e60d3f.MainActivity.n_onCreate(Native Method) at md573f120baf816a4fba7033ee5f3e60d3f.MainActivity.onCreate(MainActivity.java:29) at android.app.Activity.performCreate(Activity.java:7009) at android.app.Activity.performCreate(Activity.java:7000) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)}

 

Xaml code is

    <telerikChart:RadCartesianChart x:Name="chart" BackgroundColor="Transparent">
        <telerikChart:RadCartesianChart.BindingContext>
            <viewModel:CategoricalViewModel/>
        </telerikChart:RadCartesianChart.BindingContext>
        <telerikChart:RadCartesianChart.HorizontalAxis>
            <telerikChart:CategoricalAxis/>
        </telerikChart:RadCartesianChart.HorizontalAxis>
        <telerikChart:RadCartesianChart.VerticalAxis>
            <telerikChart:NumericalAxis/>
        </telerikChart:RadCartesianChart.VerticalAxis>
        <telerikChart:RadCartesianChart.Series>
            <telerikChart:LineSeries CategoryBinding="Category" ValueBinding="Value" ItemsSource="{Binding CategoricalData}" DisplayName="Speed (mph) vs Time" />
        </telerikChart:RadCartesianChart.Series>
        <telerikChart:RadCartesianChart.Grid>
            <telerikChart:CartesianChartGrid MajorLinesVisibility="XY" MajorLineThickness="1"/>
        </telerikChart:RadCartesianChart.Grid>
    </telerikChart:RadCartesianChart>
    <telerikChart:RadLegend LegendItemFontColor="White"
                            LegendItemFontSize="20"
                            LegendProvider="{x:Reference Name=chart}" />

ViewModel code is

    public class CategoricalData
    {
        public object Category { get; set; }
        public double Value { get; set; }
    }

    public class CategoricalViewModel
    {
        private static Random random = new Random();
        private static string[] categories = new string[] { "Greenings", "Perfecto", "NearBy", "Family", "Fresh" };

        public CategoricalViewModel()
        {
            this.CategoricalData = GetCategoricalData();
        }

        public ObservableCollection<CategoricalData> CategoricalData { get; set; }

        public static ObservableCollection<CategoricalData> GetCategoricalData()
        {
            var data = new ObservableCollection<CategoricalData>();
            for (int i = 0; i < categories.Length; i++)
            {
                data.Add(new CategoricalData() { Value = random.Next(50, 100), Category = categories[i] });
            }

            return data;
        }
    }

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Lance | Manager Technical Support
Telerik team
answered on 31 Oct 2018, 05:38 PM
Hi Hady,

I wanted to also follow up in this forum thread to share my results with the rest of the community.

The demo we reviewed in our Support Ticket was missing the dependencies for the target platform projects. In your project's case, the NuGet package "Telerik.UI.for.Xamarin" should be installed to every project.


In other cases where you're not using the NuGet package, you'll need to manually reference the assemblies in each project. You can find the necessary references in the Getting Started: Required Telerik Assemblies article.

For your convenience, here's the list:

Platform Assemblies
Portable Telerik.XamarinForms.Common.dll
Telerik.XamarinForms.Chart.dll
Android Telerik.Xamarin.Android.Common.dll
Telerik.Xamarin.Android.Chart.dll
Telerik.Xamarin.Android.Primitives.dll
Telerik.XamarinForms.Common.dll
Telerik.XamarinForms.Chart.dll
iOS Telerik.Xamarin.iOS.dll
Telerik.XamarinForms.Common.dll
Telerik.XamarinForms.Chart.dll
UWP Telerik.Core.dll
Telerik.UI.Xaml.Chart.UWP.dll
Telerik.UI.Xaml.Primitives.UWP.dll
Telerik.XamarinForms.Common.dll
Telerik.XamarinForms.Chart.dll


I hope I was able to help clear things up.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Hady
Top achievements
Rank 2
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or