Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
XamWebChart Bind Series Fill Color
posted

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 { getprivate set; }
 
        public GeographyDataDetailItem(string identifierdouble amountIColorProvider 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?


 

Parents
No Data
Reply Children
No Data