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

Set propert 'Telerik.Windows.Controls.Charting.DataPoint.YValue' threw an exception.

3 Answers 112 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Robert Kaucher
Top achievements
Rank 2
Robert Kaucher asked on 17 Jun 2011, 03:47 PM
I have an object in my Vm called WorkingForecast and it contains a series of attributes of type int. I am trying to bind the data series to said properties but it is throwing an error when loading. Here is my chart's data series definition.
<telerikCharting:ChartArea.DataSeries>
   <telerikCharting:DataSeries>
     <telerikCharting:DataSeries.Definition>
      <telerikCharting:SplineSeriesDefinition >
      </telerikCharting:SplineSeriesDefinition>
     </telerikCharting:DataSeries.Definition>
 <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month01Qty, TargetNullValue=0}" XCategory="Jan"/>
 <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month02Qty, TargetNullValue=0}" XCategory="Feb"/>
 <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month03Qty, TargetNullValue=0}" XCategory="Mar"/>
 <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month04Qty, TargetNullValue=0}" XCategory="Apr"/>
      <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month05Qty, TargetNullValue=0}" XCategory="May"/>
      <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month06Qty, TargetNullValue=0}" XCategory="Jun"/>
      <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month07Qty, TargetNullValue=0}" XCategory="Jul"/>
       <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month08Qty, TargetNullValue=0}" XCategory="Aug"/>
       <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month09Qty, TargetNullValue=0}" XCategory="Sep"/>
       <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month10Qty, TargetNullValue=0}" XCategory="Oct"/>
       <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month11Qty, TargetNullValue=0}" XCategory="Nov"/>
       <telerikCharting:DataPoint YValue="{Binding WorkingForecast.Month12Qty, TargetNullValue=0}" XCategory="Dec"/>
    </telerikCharting:DataSeries>
 </telerikCharting:ChartArea.DataSeries>

I receive the error: Set propert 'Telerik.Windows.Controls.Charting.DataPoint.YValue' threw an exception. Any suggestions? WorkingForecast is null initially.

3 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 22 Jun 2011, 11:12 AM
Hello Robert,

The DataPoint class does not inherit from DependencyObject, so you cannot populate its properties through bindings. I would suggest populating the chart by setting its ItemsSource property (or binding it) to a collection, which holds the data to be displayed. You can find more details in the following help topics:


Best regards,
Ves
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Robert Kaucher
Top achievements
Rank 2
answered on 23 Jun 2011, 01:54 PM
Ves,
Thanks for the reply. I have created an object called ChartDatum with the following structure.

ChartDatum
public DateTime Period
public int? ForecastValue
public int? PerviousForecastValue
public int? SupplierForecastValue

I then created an ObservableCollection<ChartDatum> ChartData which I have bound to ItemsSource and bound the properties as follows:
<telerik:RadChart.SeriesMappings>
                                     
    <telerik:SeriesMapping LegendLabel="{Binding PeriodValue, StringFormat='Supplier Forecast - \{0:y\}'}">
        <telerik:SeriesMapping.SeriesDefinition>
            <telerik:SplineSeriesDefinition/>
        </telerik:SeriesMapping.SeriesDefinition>
        <telerik:ItemMapping DataPointMember="YValue" FieldName="SupplierForecastValue" />
        <telerik:ItemMapping DataPointMember="XValue" FieldName="Period" />
     </telerik:SeriesMapping>
     
    <!---->
    <telerik:SeriesMapping LegendLabel="{Binding PeriodValue, StringFormat='Forecast - \{0:y\}'}">
        <telerik:SeriesMapping.SeriesDefinition>
            <telerik:SplineSeriesDefinition/>
        </telerik:SeriesMapping.SeriesDefinition>
        <telerik:ItemMapping DataPointMember="YValue" FieldName="ForecastValue"/>
        <telerik:ItemMapping DataPointMember="XValue" FieldName="Period" />
    </telerik:SeriesMapping>
     
    <!---->
    <telerik:SeriesMapping LegendLabel="{Binding PreviousPeriodValue, StringFormat='Previous Forecast - \{0:y\}'}">
        <telerik:SeriesMapping.SeriesDefinition>
            <telerik:SplineSeriesDefinition/>
        </telerik:SeriesMapping.SeriesDefinition>
 
        <telerik:SeriesMapping.ItemMappings>
            <telerik:ItemMapping DataPointMember="YValue" FieldName="PreviousForecastValue"/>
            <telerik:ItemMapping DataPointMember="XValue" FieldName="Period" />
        </telerik:SeriesMapping.ItemMappings>                                      
    </telerik:SeriesMapping>
     
</telerik:RadChart.SeriesMappings>
My XAxis is defined as follows:
<telerik:ChartArea>
   <telerik:ChartArea.AxisX>
      <telerik:AxisX IsDateTime="True"
                              LabelRotationAngle="30"
                              LabelStep="1"
                              Step="1"
                              LayoutMode="Between"
                              DefaultLabelFormat="MMM-yyyy"
                              >
       </telerik:AxisX>
   </telerik:ChartArea.AxisX>
</telerik:ChartArea>
But I am seeing a few anomolies.
1. SOME of the labels are repeating. MAR-2011 MAR-2011 APR-2011 APR-2011 MAY-2011 JUN-2011 JUN-2011 JUL-2011 AUG-2011 AUG-2011 but the data is fine for the repeating months, it only shows once even in the repeating months. This is due to the range being plotted by the chart, which I don't want. When I take the format off I get Tuesday March 1, 2011 then Sunday March 20, 2011 but I only want the DateTimes that actually exist in my data to appear. There is only ever data for the first day of each month.

2. The previous forecast item series never shows up. The only difference of note is that it has values that are -1 month from the other two series sets. This means it has values for Mar - 2011 while the other two series sets are null and the other two have values for MAR-2012 while the previous forecast has null for that month.  Error in my setter. Ignore this issue.

An example of the Line chart using multiple lines that are not hard coded as in the demos would be helpful. I find the documentation in the help on RadChart to be very fragmented. It's hard to follow instruction on something that is new (RadChart) when you are being shown examples of different chart types that do not apply to what you are doing. I think more, smaller examples that are split into code behind vs. XAML methods would make reading and understanding the online help much easier.

But don't take my comment to mean I am dissatisfied in any way. You guys still rock!

0
Ves
Telerik team
answered on 28 Jun 2011, 12:15 PM
Hello Robert,

I believe the DateTime grouping in RadChart will do the trick in this case. Please, find a help topic here and an online example here.

As to the help and examples -- RadChart is a complex and feature rich control and it allows a large number combination of features to be applied. We are trying to provide feature-oriented help and examples, so that you can find the descriptions of the features you need and then combine them into your application. I am not sure I followed your request for multiple lines that are not hard coded. Can you please provide additional details? Thanks.

Best regards,
Ves
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Robert Kaucher
Top achievements
Rank 2
Answers by
Ves
Telerik team
Robert Kaucher
Top achievements
Rank 2
Share this question
or