Unable to see the chart even after following all the steps in chart getting started url

2 posts, 0 answers
  1. Varun
    Varun avatar
    1 posts
    Member since:
    Mar 2011

    Posted 04 May 2015 Link to this post

    Hi

    I'm using xamarin forms and my sdk browser app is working.

    I had tried to implement the telerik chart control in xaml. The chart control shows up with white background and doesn't have the data

    The bindingcontext is having data and also there are no errors. Even the control itemsource is having the data. I have followed the getting started documentation.

    http://docs.telerik.com/devtools/xamarin/controls/chart/chart-getting-started

     

    Please provide assistance or help to resolve the issue.

     

     

    using System;
    using System.Collections.Generic;
    using Telerik.XamarinForms.Chart;
    using Xamarin.Forms;



    namespace SampleXamarinForms
    {
    public partial class LineSeries :ContentPage
    {
    private ChartSelectionBehavior beh;
    public GraphViewModel DataContext {
    get;
    set;
    }
    public LineSeries()
    {
    DataContext = new GraphViewModel();
    InitializeComponent();

    //this.BindingContext = DataContext;


    BackgroundColor = Xamarin.Forms.Device.OnPlatform(Xamarin.Forms.Color.White, Xamarin.Forms.Color.White, Xamarin.Forms.Color.Transparent);

    this.Content = CreateChart();
    this.Content.BindingContext = DataContext;
    barChart.BindingContext = DataContext;
    }



    private static RadCartesianChart CreateChart()
    {
    var chart = new RadCartesianChart
    {
    HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis(),
    VerticalAxis = new Telerik.XamarinForms.Chart.NumericalAxis(),
    };

    var series = CreateSeries();

    chart.Series.Add(series);
    return chart;
    }

    private static BarSeries CreateSeries()
    {
    var series = new Telerik.XamarinForms.Chart.BarSeries();
    series.SetBinding(BarSeries.ItemsSourceProperty, new Binding("Data"));

    series.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
    {
    PropertyName = "Value"
    };

    series.CategoryBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
    {
    PropertyName = "Category"
    };

    return series;
    }
    }

    }

    Regards

  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 07 May 2015 Link to this post

    Hi Varun,

    The code you have provided looks correct. The PropertyNameDataPointBinding objects, created in your code receive the following values for PropertyName (as constructor parameters): "Value" and "Category". These values should match the names of public properties in the objects which populate the chart. Can you please verify if this is the case? If not, you will need to change the parameters used in the PropertyNameDataPointBinding constructors to match the names of the properties of your business object.

    Best regards,
    Ves
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. DevCraft banner
Back to Top