Databinding SeriesMapping and seriesmapping to different data sources

3 posts, 0 answers
  1. Morten Post
    Morten Post avatar
    4 posts
    Member since:
    Jul 2009

    Posted 23 Sep 2011 Link to this post


    I have a radchart that I wish to add x series to dynamically depending on what you check off in a checkbox list.

    I have a RadChart declared like this:
    <telerik:RadChart x:Name="radChart" telerik:StyleManager.Theme="Metro" SeriesMappings="{Binding ChartSeriesMapping}" >

    My ChartSeriesMapping is declaredl like this:
    private SeriesMappingCollection _chartSeriesMapping;
    public SeriesMappingCollection ChartSeriesMapping
            return _chartSeriesMapping;
            if (_chartSeriesMapping != value)
                _chartSeriesMapping = value;

    I'm adding series like this:
    SeriesMapping salesAmountMapping = new SeriesMapping();
    salesAmountMapping.LegendLabel = p.StoreName;
    salesAmountMapping.ItemsSource = report.ChartData;
    salesAmountMapping.SeriesDefinition = new BarSeriesDefinition();
    salesAmountMapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue));
    salesAmountMapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));
    Where ChartData is containing XValue and YValue public properties.

    But the charts is always empty when I'm adding new series... How is this supposed to work? Also, how come legend Label is always set to Series 0, Series 1, etc?

    Thanks in advance.
  2. Morten Post
    Morten Post avatar
    4 posts
    Member since:
    Jul 2009

    Posted 23 Sep 2011 Link to this post


    I've looked a bit more into this. It seems like the RadChart is never databinding, which I find quite odd:

    So Why isn't SeriesMappings binding? ItemsSource is but not SeriesMappings :-(

     <telerik:RadChart telerik:StyleManager.Theme="Metro" SeriesMappings="{Binding Path=ChartSeriesMapping}" DataBinding="RadChart_DataBinding"/>

    But if I add ItemsSource={Binding...} it works. 

    DataTemplate looks like this:

    <DataTemplate x:Key="TouchReportTemplate">
                    <telerik:RadChart x:Name="myRadChart2" DataContext="MyReport" telerik:StyleManager.Theme="Metro" UseDefaultLayout="False" SeriesMappings="{Binding ChartSeriesMapping}">
                        <telerik:ChartArea x:Name="ChartArea1" EnableAnimations="True"></telerik:ChartArea>

    And is used here:

    <s:ScatterView x:Name="myScatterView" ItemTemplateSelector="{StaticResource ReportTemplateSelector}" ItemsSource="{Binding Reports}" >
            <Style TargetType="s:ScatterViewItem">
                <Setter Property="MinWidth" Value="400" />
                <Setter Property="MinHeight" Value="300" />
                <Setter Property="MaxWidth" Value="800" />
                <Setter Property="MaxHeight" Value="700" />
                <EventSetter Event="s:ScatterViewItem.PreviewTouchMove" Handler="ScatterViewItem_PreviewTouchMove" />
                <EventSetter Event="s:ScatterViewItem.PreviewTouchUp" Handler="ScatterViewItem_PreviewTouchUp" />

  3. Yavor
    Yavor avatar
    401 posts

    Posted 28 Sep 2011 Link to this post

    Hi Morten Post,

    Indeed, there is a problem in this scenario. It is logged in our Public Issue Tracking System, so you can track its status here. Did you try wrapping the RadChart in your DataTemplate into a UserControl as a workaround to this issue?

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top