This question is locked. New answers and comments are not allowed.
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
MainPage.xaml.cs
And the ViewModel
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 { get; set; } public List<GraficoCbemaItem> CurvaFaseB { get; set; } 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 { get; set; } public decimal Tensao { get; set; } public GraficoCbemaItem(decimal duracao, decimal tensao) { Duracao = duracao; Tensao = tensao; } }