Jump to content
Software FX Community

Binding SeriesAttributes 's Fill property to a column on a dataTable


aafayad
 Share

Recommended Posts

I have a datatable that has three column( id, AverageColor, AverageCost). I would like to have a serie for each row of that table. The bindingPath property will point to the AverageCost Field and  the Fill  property to be bound to the AverageColor Field. both fields are mapped to each other.

I would like to achieve the following:

<cfx:Chart.Series>

<cfx:SeriesAttributes FillPath="AverageColor"  BindingPath="AverageCost" />

</cfx:Chart.Series>

Unfortunalty there is no FillPath property. 

 

Link to comment
Share on other sites

Although as you noted we do not expose a FillPath property you can achieve the chart you are looking for by changing the template we use to draw the chart markers (in this sample I am assuming it is a bar chart).

<cfx:Chart Gallery="Bar" x:Name="chart1" ItemsSource="{Binding Source={StaticResource bidsData}}">

  <

cfx:Chart.Series>

  <

cfx:SeriesAttributes BindingPath="AverageCost"/>

  </

cfx:Chart.Series>

  <

cfx:Chart.AllSeries>

  <

cfx:AllSeriesAttributes>

  <

cfx:AllSeriesAttributes.Template>

  <

DataTemplate>

  <

Rectangle Width="{Binding Path=Width}" Height="{Binding Path=Height}" Fill="{Binding Path=DataItem.AverageBrush}" />

  </

DataTemplate>

</

cfx:AllSeriesAttributes.Template>

  </

cfx:AllSeriesAttributes>

  </

cfx:Chart.AllSeries>

  <

cfx:Chart.AxisX>

  <

cfx:Axis>

  <

cfx:Axis.Labels>

  <

cfx:AxisLabelAttributes BindingPath="id>

  </

cfx:Axis.Labels>

  </

cfx:Axis>

  </

cfx:Chart.AxisX>

</cfx:Chart>

Note that I am assuming a property called AverageBrush that returns a WPF brush, if you have a color property you can either create an extra property that returns a new SolidColorBrush using the color or you can also use a Converter in your binding. 

Regards,

JuanC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...