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

RadChart as RadGridView column template

2 Answers 101 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Edo asked on 21 Nov 2012, 03:09 PM
I'm trying to show a RadGridView with a RadChart in each row.
Binding the grid's ItemSource to the relevant property works, all charts show the data labels,
However, only the last row's chart shows the actual value heights (see attached image).

Another issue is the commented ChartArea.AxisX. uncommenting this property section causes an NullReferenceException to be thrown from Telerik.Windows.Controls.Charting.AxisX.CalculateItemRange(DataSeries dataSeries, Int32 index)

<Window x:Class="testApp.Window1"
        Title="Window1" Height="300" Width="300">
        <my:Window1ViewModel x:Key="MyViewModel"/>
    <Grid x:Name="LayoutRoot" DataContext="{StaticResource MyViewModel}">
        <telerik:RadGridView ItemsSource="{Binding Items}" AutoGenerateColumns="False">
                <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Label}"/>
                <telerik:GridViewDataColumn Header="Values">
                            <telerikChart:RadChart ItemsSource="{Binding Values}"
                                                           UseDefaultLayout="False" MaxWidth="200" MaxHeight="100">
                                <telerikCharting:ChartArea x:Name="MyChartArea">
                                    <telerikCharting:SeriesMapping ChartAreaName="MyChartArea">
                                            <telerikCharting:LineSeriesDefinition LegendDisplayMode="None"/>
                                            <telerikCharting:ItemMapping DataPointMember="YValue"/>

using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace testApp
  class Window1ViewModel
    public ObservableCollection<ItemsClass> Items { get; set; }
    public Window1ViewModel()
      Items = new ObservableCollection<ItemsClass>
                new ItemsClass("Test1", new[] {0.1, 0.3, 0.5, 0.2}),
                new ItemsClass("Test2", new[] {0.2, 0.3, 0.5, 0.2}),
                new ItemsClass("Test3", new[] {0.3, 0.3, 0.5, 0.2})
  public class ItemsClass
    public string Label { get; set; }
    public IEnumerable<double> Values { get; set; }
    public ItemsClass(string label, IEnumerable<double> values)
      Label = label;
      Values = values;

Any idea?

2 Answers, 1 is accepted

Sort by
Petar Marchev
Telerik team
answered on 22 Nov 2012, 11:33 AM
Hello Edo,

Thank you for the code snippets, I was able to create a new project based on this code and run it with no problem.

I was unable to reproduce neither of the issues you reported. I have attached a snapshot of the output the chart produced. I have also attached the project I used for your reference. See if you get the same behavior on your side. If you keep experiencing problems with this you can update the project to reproduce this faulty behavior so that we can investigate.

I guess that this code is just a small part of your actual project and this is why as a start you can try to place the chart inside a user control and place that user control in the DataTemplate and see how that goes.

On a side note I would like to direct to to our Sparklines. Depending on your scenario, on the type data you are trying to visualize, the Sparklines might be a better choice of visual display. You can explain your requirements to us so that we discuss what type of display may be most appropriate. 

All the best,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Top achievements
Rank 1
answered on 22 Nov 2012, 12:00 PM
Thanks Peter, for you replay.
Using the assemblies you included does work.
My version of Telerik controls is older, which must be the reason for the misbehavior.

I will look into upgrading the controls and also the Sparklines, which seem to be exactly what I need.

Asked by
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Top achievements
Rank 1
Share this question