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

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

1 Answer 57 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Varun
Top achievements
Rank 1
Varun asked on 05 May 2015, 03:42 AM

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

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 07 May 2015, 02:29 PM
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.

 
Tags
Chart
Asked by
Varun
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or