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

RadChart with multiple data source support. In the example here you can see how to use the new ItemsSource property of the SeriesMapping.

4 Answers 130 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 23 Mar 2011, 08:24 PM
Hi guys,

Just tried the new Q1 2011 RadChart multiple data source support and got some errors.

When I notify my changes from the viewmodel to a RadChart with some data, I get a stackoverflow exception.
If the RadChart is created empty and I try to notify new data, nothing happens, the chart is not updated.

Am I doing something? Is this a bug?

Thanks in advance,

Here is my code (simplified):

MainPage.xaml

<StackPanel x:Name="LayoutRoot" Background="White">
        <Button Height="40" Content="Reload" Click="Button_Click"/>
        <telerikPresentation:RadChart UseDefaultLayout="False">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition />
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
 
                <Charting:ChartTitle Content="Chart" />
                <Charting:ChartLegend Grid.Row="3" x:Name="legend" ItemsPanelOrientation="Horizontal" Header="Header"/>
                <Charting:ChartArea Grid.Row="1" Grid.RowSpan="2" x:Name="chartArea"/>
            </Grid>
            
            <telerikPresentation:RadChart.SeriesMappings>
                <Charting:SeriesMapping ChartAreaName="chartArea" ItemsSource="{Binding CurvaFaseA}">
                    <Charting:SeriesMapping.SeriesDefinition>
                        <Charting:LineSeriesDefinition ShowItemLabels="False" ShowPointMarks="False" />
                    </Charting:SeriesMapping.SeriesDefinition>
                    <Charting:SeriesMapping.ItemMappings>
                        <Charting:ItemMapping FieldName="Duracao" DataPointMember="XValue" />
                        <Charting:ItemMapping FieldName="Tensao" DataPointMember="YValue" />
                    </Charting:SeriesMapping.ItemMappings>
                </Charting:SeriesMapping>
 
                <Charting:SeriesMapping ChartAreaName="chartArea" ItemsSource="{Binding CurvaFaseB}">
                    <Charting:SeriesMapping.SeriesDefinition>
                        <Charting:LineSeriesDefinition ShowItemLabels="False" ShowPointMarks="True"/>
                    </Charting:SeriesMapping.SeriesDefinition>
                    <Charting:SeriesMapping.ItemMappings>
                        <Charting:ItemMapping FieldName="Duracao" DataPointMember="XValue" />
                        <Charting:ItemMapping FieldName="Tensao" DataPointMember="YValue" />
                    </Charting:SeriesMapping.ItemMappings>
                </Charting:SeriesMapping>
            </telerikPresentation:RadChart.SeriesMappings>
 
        </telerikPresentation:RadChart>
    </StackPanel>

MainPage.xaml.cs

public partial class MainPage : UserControl {
		private MainPageViewModel _viewModel;
 
		public MainPage() {
			InitializeComponent();
			_viewModel = new MainPageViewModel();
			DataContext = _viewModel;
		}
 
		private void Button_Click(object sender, RoutedEventArgs e) {
			_viewModel.Click();
		}
	}

And the ViewModel

public class MainPageViewModel : ViewModelBase {
		public List<GraficoCbemaItem> CurvaFaseA { getset; }
		public List<GraficoCbemaItem> CurvaFaseB { getset; }
 
		public MainPageViewModel() {
			//if you comment the next line, there is no exception but no data is reloaded too
			CurvaFaseA = CreateCurva().ToList();
		}
 
		private IEnumerable<GraficoCbemaItem> CreateCurva() {
			Random random = new Random(DateTime.Now.Millisecond);
			for (int i = 0; i < 50; i++) {
				yield return new GraficoCbemaItem(random.Next(100), random.Next(200));
			}
		}
		
		public void Click() {
			CurvaFaseA = CreateCurva().ToList();
			CurvaFaseB = CreateCurva().ToList();
			OnPropertyChanged(() => CurvaFaseA);
			OnPropertyChanged(() => CurvaFaseB);
		}
	}
 
	public class GraficoCbemaItem {
		public decimal Duracao { getset; }
		public decimal Tensao { getset; }
 
		public GraficoCbemaItem(decimal duracao, decimal tensao) {
			Duracao = duracao;
			Tensao = tensao;
		}
	}

4 Answers, 1 is accepted

Sort by
0
Andre
Top achievements
Rank 1
answered on 23 Mar 2011, 08:26 PM
Oh God, wrong subject, how can I edit that?
0
Ves
Telerik team
answered on 29 Mar 2011, 12:19 PM
Hi Andre,

Thank you for contacting us and for all the details. I am afraid this is a bug in RadChart. I have logged it in our Public Issue Tracking system, you can find it here. Our developers are already working on it, so the fix will be available in the next internal build. Internal builds are usually published every Monday.

I have updated your Telerik points.

Regards,
Ves
the Telerik team
0
Brian
Top achievements
Rank 1
answered on 04 May 2011, 08:05 PM
Is this fix available in any of the current code releases?  We are running Version=2011.1.315.1040 and I'm seeing the issue.
Tks.
0
Ves
Telerik team
answered on 09 May 2011, 01:04 PM
Hello Brian,

Here is how to read the version:

2011 -- Year
1 -- Quarter
315 - March 15-th
1040 - Framework: Silverlight
1040 - Framework version: 4.0

That said, you are using a version released prior to this thread. Please, download the latest version (2011 Q1 SP1 -- 2011.1.419) and give it a try.

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
Andre
Top achievements
Rank 1
Answers by
Andre
Top achievements
Rank 1
Ves
Telerik team
Brian
Top achievements
Rank 1
Share this question
or