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

Help with data binding and seriesmapping for a chart

0 Answers 51 Views
Chart
This is a migrated thread and some comments may be shown as answers.
JAS J
Top achievements
Rank 1
JAS J asked on 06 Oct 2011, 11:34 PM

>> Update:
The problem was that I was creating a new ChartArea everytime.

Jas

Hi needed some help getting my chart to show up.  I cant seem to figure out where the error is. Can anyone see the error? what am I missing

Here is what I have :

ChartData is a List<DataSeries>
A DataSeries is a List<DataPOints>

A DataPoint is:

Class
{
    int YValue
    DateTime XValue
    double XValueOA (the OA version of the XValue above);
}

 

 


 

 

 

<telerik:RadChart ItemsSource="{Binding ChartData}" SeriesMappings="{Binding ChartSeriesMapping}">

<RadChart.DefaultView>
  <telerik:ChartDefaultView ChartLegendPosition="Right">
   <telerik:ChartDefaultView.ChartArea>
    <telerik:ChartArea LegendName="ChartLegend1" EnableAnimations="False" >
    </telerik:ChartArea>
   </telerik:ChartDefaultView.ChartArea>
  </telerik:ChartDefaultView>
 </telerik:RadChart.DefaultView>
</telerik:RadChart>

:
Once I have the data, and I can see that the data is good, I do the following to bind the data:
I first set the ChartData

ChartData = NewData; // I verified that the data looks fine
 
int seriesIndex = 0;
ChartSeriesMapping.Clear();
foreach ( string client in Clients)
{
 SeriesMapping mapping = new SeriesMapping();
 
 ItemMapping itemMappingXValue = new ItemMapping
 {  FieldName = "XValue", DataPointMember = DataPointMember.XValue  };
  
 ItemMapping itemMappingYValue = new ItemMapping
 {  FieldName = "YValue", DataPointMember = DataPointMember.YValue };// I have tried the OA value as well
 
 SeriesDefinition definition = new LineSeriesDefinition() {ShowItemLabels = false, SeriesName = client,
  Visibility = SeriesVisibility.Visible};
 
 mapping.ChartArea = new ChartArea { AxisX = { IsDateTime = true, AutoRange = true } };
 mapping.ItemMappings.Add(itemMappingXValue);
 mapping.ItemMappings.Add(itemMappingYValue);
 
 mapping.CollectionIndex = seriesIndex++;
 
 mapping.SeriesDefinition = definition;
 
 ChartSeriesMapping.Add(mapping);
}

 

Unfortunately the chart never shows up. It disaplays  "No Data Series"

Can anyone see what i might be doing wrong?

thanks!!!!!
Jas

No answers yet. Maybe you can help?

Tags
Chart
Asked by
JAS J
Top achievements
Rank 1
Share this question
or