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

Possible to bind to SeriesMapping?

5 Answers 181 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Bryce
Top achievements
Rank 1
Bryce asked on 12 Oct 2010, 12:04 AM
I have a chart thats trying to bind to my MVVM and I keep getting an exception inside the radchart from my seriesmapping binding, since as soon as I remove that binding the exception stops throwing.

Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.RadChart.ClearDataSeries() in c:\Builds\WPF_Scrum\Release_SL_2010_Q2_SP2\Sources\Development\Controls\Chart\Chart\RadChart.cs:line 1032
   at Telerik.Windows.Controls.RadChart.Rebind(Object originalData) in c:\Builds\WPF_Scrum\Release_SL_2010_Q2_SP2\Sources\Development\Controls\Chart\Chart\RadChart.cs:line 1014
   at Telerik.Windows.Controls.RadChart.ItemsSourcePropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) in c:\Builds\WPF_Scrum\Release_SL_2010_Q2_SP2\Sources\Development\Controls\Chart\Chart\RadChart.cs:line 852
   at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e) in c:\Builds\WPF_Scrum\Release_SL_2010_Q2_SP2\Sources\Development\Core\Controls\Common\System.Windows\PropertyMetadata.cs:line 200
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
   at Telerik.Windows.Controls.RadChart.set_ItemsSource(Object value) in c:\Builds\WPF_Scrum\Release_SL_2010_Q2_SP2\Sources\Development\Controls\Chart\Chart\RadChart.cs:line 479
   at Telerik.Windows.Controls.RadChart.InitializeDesignTimeData() in c:\Builds\WPF_Scrum\Release_SL_2010_Q2_SP2\Sources\Development\Controls\Chart\Chart\RadChart.cs:line 1131
   at Telerik.Windows.Controls.RadChart.OnApplyTemplate() in c:\Builds\WPF_Scrum\Release_SL_2010_Q2_SP2\Sources\Development\Controls\Chart\Chart\RadChart.cs:line 716
   at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)


<telerikChart:RadChart ItemsSource="{Binding StorageOpsPerSecond}" BorderThickness="0" Controls:StyleManager.Theme="Windows7"
                                                       Height="300" Margin="3 0 3 0" SeriesMappings="{Binding StorageOpsSeriesMapping, Mode=OneWay}">
                                    <telerikChart:RadChart.DefaultView>
                                    <telerikCharting:ChartDefaultView ChartLegendPosition="Bottom">
                                        <telerikCharting:ChartDefaultView.ChartTitle>
                                            <telerikCharting:ChartTitle HorizontalContentAlignment="Stretch" Content="Storage Operations Per Second"/>
                                        </telerikCharting:ChartDefaultView.ChartTitle>
                                        <telerikCharting:ChartDefaultView.ChartLegend>
                                                <telerikCharting:ChartLegend x:Name="chartLegend"/>
                                            </telerikCharting:ChartDefaultView.ChartLegend>
                                            <telerikCharting:ChartDefaultView.ChartArea>
                                                <telerikCharting:ChartArea LegendName="chartLegend" EnableAnimations="True">
                                                    <telerikCharting:ChartArea.AxisX>
                                                        <telerikCharting:AxisX LayoutMode="Normal" IsDateTime="True" DefaultLabelFormat="h:mm" AutoRange="True" 
                                                                   LabelRotationAngle="60" LabelStep="1" TicksDistance="15"/>
                                                    </telerikCharting:ChartArea.AxisX>
                                                </telerikCharting:ChartArea>
                                            </telerikCharting:ChartDefaultView.ChartArea>
                                        </telerikCharting:ChartDefaultView>
                                    </telerikChart:RadChart.DefaultView>
                                </telerikChart:RadChart>


public class StorageServiceViewModel: ServiceViewModelBase
{
    public List<AzProduct> Products {get; set;}
    public ObservableCollection<AddRangeObservableCollection<DataPointViewModel>> StorageOpsPerSecond { get; private set; }
    public List<SeriesMapping> StorageOpsSeriesMapping
    {
         get {return Products.Select((t, i) => GetSeriesMapping(i, t.DisplayName)).ToList();}
    }
 
    public StorageServiceViewModel(IAuthenticateService authService, ICustomerService customerService, IMonitorHistoryService monHistoryService, IMonitorCurrentService monCurrentService)
        : base(authService, customerService, monHistoryService, monCurrentService)
    {
        StorageOpsPerSecond = new ObservableCollection<AddRangeObservableCollection<DataPointViewModel>>();
 
        if(IsInDesignMode)
        {
            Products =customerService.GetProducts(Guid.Empty);
            LoadData();
        }
    }
 
 
    public override void LoadData()
    {
        foreach (AzProduct product in Products)
        {
            StorageProductViewModel spvm = new StorageProductViewModel(product, MonitorCurrentService,
                                                                        MonitorHistoryService);
            StorageProducts.Add(spvm);
            StorageOpsPerSecond.Add(spvm.TransactionsPerSecond);
 
            spvm.Load();
        }
    }
 
    public override void LoadProducts(List<AzProduct> products)
    {
        foreach(AzProduct product in products)
        {
            if(product.Type == ProductTypes.EMC || product.Type == ProductTypes.NetApp)
            {
                Products.Add(product);
            }
        }
    }
 
    private SeriesMapping GetSeriesMapping(int index, string displayName)
    {
        SeriesMapping mapping = new SeriesMapping();
        mapping.CollectionIndex = index;
        mapping.LegendLabel = displayName;
 
        LineSeriesDefinition lsd = new LineSeriesDefinition();
        lsd.ShowItemLabels = false;
        lsd.ShowPointMarks = false;
        lsd.ShowItemToolTips = true;
        lsd.ItemToolTipFormat = "#Y";
        mapping.SeriesDefinition = lsd;
 
        ItemMapping im = new ItemMapping();
        im.FieldName = "Timestamp";
        im.DataPointMember = DataPointMember.XValue;
        mapping.ItemMappings.Add(im);
 
        im = new ItemMapping();
        im.FieldName = "Value";
        im.DataPointMember = DataPointMember.YValue;
        mapping.ItemMappings.Add(im);
 
        return mapping;
    }
}

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 14 Oct 2010, 12:55 PM
Hi Bryce,

Thank you for reporting this bug! We reproduced this issue and it is logged in our system here. Our developers fixed it immediately and you will be able to get the fix with the next LIB. This issue is caused by the SeriesMappings being null when you try to set the ItemsSouce. Please, excuse us for the inconvenience. We have added points to your account for helping us pinpoint this issue. Don't hesitate to contact us if you have other questions.

Kind regards,
Yavor Ivanov
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
Ingo
Top achievements
Rank 1
answered on 19 Jan 2011, 02:35 PM
Hi Yavor,

I have a problem which seems to be quite similar to the one described above. At the moment I can't really find a bug in my code. Maybe I need new glasses.....

You wrote that there should be a fix available with the next Lib - so, is this problem already fixed with the Version 2010.3.1314 (in the PITS it is
marked as resolved but not scheduled)? As I have already the version installed then there may be a new issue altogether then?

Thanks for your help, it is dearly appreciated!

Kind regards,
Ingo

0
Giuseppe
Telerik team
answered on 24 Jan 2011, 05:44 PM
Hello Ingo,

The original issue mentioned in this forum thread was fixed 3 months ago so probably you are experiencing a different problem. We would suggest you to open a formal support ticket and send us a runnable sample application that we can investigate locally so we can advise you properly how to proceed.


Greetings,
Giuseppe
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Jurie
Top achievements
Rank 1
answered on 27 Jan 2011, 09:41 PM
Using the same code in version 2010.3.1314.1040 gives you the following error:

Message: Unhandled Error in Silverlight Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.RadChart.AssociateSeriesMappingsWithChartArea()
   at Telerik.Windows.Controls.RadChart.Rebind(Object originalData)
   at Telerik.Windows.Controls.RadChart.Rebind()
   at Telerik.Windows.Controls.RadChart.InternalRebind()
   at Telerik.Windows.Controls.RadChart.OnApplyTemplate()
   at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)     

I tried adding a chartname, and then adding 
            mapping.ChartAreaName = "chartName";

Still same error.
0
Giuseppe
Telerik team
answered on 28 Jan 2011, 11:34 AM
Hi Jurie,

Find attached a sample application that demonstrates RadChart.SeriesMappings bindings.

Should your problem persist, please open a formal support ticket and send us a runnable sample application that we can investigate locally and advise you how to proceed.


Kind regards,
Giuseppe
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Chart
Asked by
Bryce
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Ingo
Top achievements
Rank 1
Giuseppe
Telerik team
Jurie
Top achievements
Rank 1
Share this question
or