Hi,
I would like to Bind the Fill color of my pie slices to a color in my model bound to my WebDataChart.
The current xaml for my pie chart looks like:
<ControlTemplate x:Key="DataLocation"> <Viewbox Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Stretch="Fill"> <Grid> <Grid.Resources> <Style x:Key="PieChartSeriesStyle" TargetType="Chart:Series"> <Setter Property="Stroke" Value="#00FFFFFF" /> <Setter Property="Marker"> <Setter.Value> <Chart:Marker Foreground="#FFFFFFFF" /> </Setter.Value> </Setter>
</Style>
</Grid.Resources> <Chart:XamWebChart x:Name="PieChart" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Chart:XamWebChart.Scene> <Chart:Scene> <Chart:Scene.GridArea> <Chart:GridArea BorderThickness="0" Background="#00FFFFFF" /> </Chart:Scene.GridArea> </Chart:Scene> </Chart:XamWebChart.Scene> <Chart:XamWebChart.Series> <Chart:Series ChartType="Pie" Style="{StaticResource PieChartSeriesStyle}" DataMapping="Value=Amount;Label=Identifier" DataSource="{Binding Path=ToolTip.Details}"
Fill="{Binding DetailItem.ColorProvider.BackgroundColor}"> </Chart:Series>
</Chart:XamWebChart.Series> </Chart:XamWebChart>
</Grid> </Viewbox> </ControlTemplate>
The objects that are Bound to this ControlTemplate are:
public sealed class GeographyDataItem{
public IEnumerable<GeographyDataDetailItem> Details { get { return _details; } }
}
With children:
public sealed class GeographyDataDetailItem { private readonly IColorProvider _colorProvider; public IColorProvider ColorProvider { get { return _colorProvider; } } public string Identifier { get; private set; } public double Amount { get; private set; } public GeographyDataDetailItem(string identifier, double amount, IColorProvider colorProvider) { _colorProvider = colorProvider; Identifier = identifier; Amount = amount; } } Where IColorProvider is:
public sealed class GeographyDataDetailItem { private readonly IColorProvider _colorProvider; public IColorProvider ColorProvider { get { return _colorProvider; } } public string Identifier { get; private set; } public double Amount { get; private set; } public GeographyDataDetailItem(string identifier, double amount, IColorProvider colorProvider) { _colorProvider = colorProvider; Identifier = identifier; Amount = amount; } }
Where IColorProvider is:
public interface IColorProvider { Color ForegroundColor { get; } Color BackgroundColor { get; } } What I am lost at, is in the XAML for the Fill property; How can I access my GeographyDataDetailItem.ColorProvider.BackgroundColor property to set the Fill? Is there a ColorValueMapper like the XamTreeMap control to do this?
public interface IColorProvider { Color ForegroundColor { get; } Color BackgroundColor { get; } }
What I am lost at, is in the XAML for the Fill property; How can I access my
GeographyDataDetailItem.ColorProvider.BackgroundColor property to set the Fill?
Is there a ColorValueMapper like the XamTreeMap control to do this?
I answered my question here:http://stackoverflow.com/questions/5398393/infragistics-xamwebchart-series-fill-color-binding