Inheriting Data from the Parent Chart

The axes can inherit data from the parent chart by using the following code:


<c1:C1Chart Name="chart" ChartType="Column" >
<c1:C1Chart.Data>
<c1:ChartData>
<c1:DataSeries SymbolFill="{Binding Brush1}" Values="1,2,3,4" />
<c1:DataSeries SymbolFill="{Binding Brush2}" Values="4,3,2,1" />
</c1:ChartData>
</c1:C1Chart.Data>
<c1:C1Chart.View>
<c1:ChartView>
<c1:ChartView.AxisX>
<c1:Axis Max="{Binding XMax}" />
</c1:ChartView.AxisX>
<c1:ChartView.AxisY>
<c1:Axis Max="{Binding YMax}" />
</c1:ChartView.AxisY>
</c1:ChartView>
</c1:C1Chart.View>
</c1:C1Chart>

where data context is

public class ChartDataContext
{
public Brush Brush1 { get; set; }
public Brush Brush2 { get; set; }

public double XMax { get; set; }
public double YMax { get; set; }
}

// set data context
chart.DataContext = new ChartDataContext()
{
Brush1 = new SolidColorBrush(Colors.Red),
Brush2 = new SolidColorBrush(Colors.Blue),
XMax = 10,
YMax = 10
};


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.