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

5 posts, 0 answers
  1. Andre
    Andre avatar
    31 posts
    Member since:
    Feb 2011

    Posted 23 Mar 2011 Link to this post

    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;
    		}
    	}

  2. Andre
    Andre avatar
    31 posts
    Member since:
    Feb 2011

    Posted 23 Mar 2011 Link to this post

    Oh God, wrong subject, how can I edit that?
  3. DevCraft banner
  4. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 29 Mar 2011 Link to this post

    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
  5. Brian
    Brian avatar
    73 posts
    Member since:
    Sep 2010

    Posted 04 May 2011 Link to this post

    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.
  6. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 09 May 2011 Link to this post

    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
Back to Top
DevCraft banner