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

databinding to ChartArea

1 Answer 101 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Lukas
Top achievements
Rank 1
Lukas asked on 22 Oct 2009, 12:08 PM
Hi,
how can I bind data to ChartArea? It doesnt have SeriesMapping property.

I have a chart that have 3 chart areas. I want to bind the same collection (Observable collection of ViewModels) to these areas, but each area will display different property from ViewModel. Or is making 3 Charts instead of 3 ChartAreas a better approach? (but then i would loose the fancy background).

Second question.. can I save ChartArea to picture or this is possilbe only for charts?

Thanks

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 26 Oct 2009, 03:04 PM
Hi Lukas,

Databinding to multiple ChartAreas will be supported with the Q3 2009 release scheduled for November. Currently you can preview the functionality in the public BETA release available for download in your Client.Net account:

XAML:
<telerik:RadChart x:Name="RadChart1" UseDefaultLayout="False">
    <telerik:RadChart.SeriesMappings>
        <chart:SeriesMapping>
            <chart:SeriesMapping.ItemMappings>
                            <chart:ItemMapping FieldName="YValue" DataPointMember="YValue" />
            </chart:SeriesMapping.ItemMappings>
        </chart:SeriesMapping>
        <chart:SeriesMapping ChartAreaName="ChartArea1">
            <chart:SeriesMapping.ItemMappings>
                            <chart:ItemMapping FieldName="YValue" DataPointMember="YValue" />
            </chart:SeriesMapping.ItemMappings>
        </chart:SeriesMapping>
        <chart:SeriesMapping ChartAreaName="ChartArea2">
            <chart:SeriesMapping.ItemMappings>
                            <chart:ItemMapping FieldName="YValue" DataPointMember="YValue" />
            </chart:SeriesMapping.ItemMappings>
        </chart:SeriesMapping>
    </telerik:RadChart.SeriesMappings>
    <StackPanel Orientation="Vertical">
        <chart:ChartArea x:Name="ChartArea1" />
        <chart:ChartArea x:Name="ChartArea2" />
    </StackPanel>
</telerik:RadChart>

C#
SeriesMapping sm = new SeriesMapping();
sm.ChartArea = this.ChartArea1;
sm.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));
RadChart1.SeriesMappings.Add(sm);
 
sm = new SeriesMapping();
sm.ChartArea = this.ChartArea2;
sm.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));
RadChart1.SeriesMappings.Add(sm);
 
RadChart1.ItemsSource = new List<ChartData>()
    {
                    new ChartData(1),
                    new ChartData(2),
                    new ChartData(3),
                    new ChartData(4),
                    new ChartData(5),
                    new ChartData(6)
    };
 
public class ChartData
{
    public ChartData(double y)
    {
                    this.YValue = y;
    }
 
    public ChartData(DateTime x, double y)
    {
                    this.XValue = x;
                    this.YValue = y;
    }
 
    public DateTime XValue
    {
                    get;
                    set;
    }
 
    public double YValue
    {
                    get;
                    set;
    }
}


As for your second question -- export to image is supported only for the chart control and not for the ChartArea.


All the best,
Manuel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Chart
Asked by
Lukas
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or