Jump to content
Software FX Community

Pie chart fixed color based on value


rudi

Recommended Posts

I need to fix the colors of a piechart. For example 1 is always green, 2 is always red etc. At the moment the colors of the first slice is always blue, no mather whether its value is 1 or 2.

I'm not sure to what would be the best way of achieving this. Do I need to modify the template where I can take the Styling Pie example in your installation as a sample? Is it better to use the Conditional attributes? Is there a third way that would be the best?

Could you please let me know what would be the best way of achieving this?

 

Thanks,

Rudi.

Link to comment
Share on other sites

Hi,

I'm afraid I'll need some more help with this. The value of 1 should be green and 3 red.

When I use only 1 condition that has From value of 1 and BindingPath set to Y the pies are always green, which seems to make sense. If I however add the second condition everythings gets the first color of the pallet (blue in my case). Could you help me find out what I do wrong?

The code I have is:

<ChartFX:Chart.ConditionalAttributes>

  <ChartFX:ConditionalAttributes Fill="Green">

  <ChartFX:ConditionalAttributes.Condition>

  <ChartFX:RangeCondition From="1" To="1" FromOpen="True" BindingPath="Y"/>

  </ChartFX:ConditionalAttributes.Condition>

  </ChartFX:ConditionalAttributes>

  <ChartFX:ConditionalAttributes Fill="Red">

  <ChartFX:ConditionalAttributes.Condition>

  <ChartFX:RangeCondition From="3" To="3" FromOpen="True" BindingPath="Y"/>

  </ChartFX:ConditionalAttributes.Condition>

  </ChartFX:ConditionalAttributes>

</ChartFX:Chart.ConditionalAttributes>

AnnotationView.txt

Link to comment
Share on other sites

To fix this issue please remove the FromOpen="True" from both RangeCondition elements. When FromOpen is true we do a greater than comparison, instead of a greather than or equal comparison.

The default for BindingPath is the value being plotted so you can remove BindingPath="Y" as well.

Regards,

JuanC

post-5571-13922409547184_thumb.jpg

Link to comment
Share on other sites

Works great. Thanks!

As a reference to others:

<ChartFX:Chart Gallery="Pie" ItemsSource="{Binding Source={StaticResource TaskViewSource}, Path=CurrentItem.RunStatistics}">

<ChartFX:Chart.DataTransforms>

<ChartFXData:CrosstabTransform RowPath="RunStatusCode" Sorted="False"/>

</ChartFX:Chart.DataTransforms>

<ChartFX:Chart.Titles>

<ChartFX:Title>Run Status</ChartFX:Title>

</ChartFX:Chart.Titles>

<ChartFX:Chart.ConditionalAttributes>

<ChartFX:ConditionalAttributes Fill="Green">

<ChartFX:ConditionalAttributes.Condition>

<ChartFX:RangeCondition From="1" To="1" BindingPath="RunStatusCode"/>

</ChartFX:ConditionalAttributes.Condition>

</ChartFX:ConditionalAttributes>

<ChartFX:ConditionalAttributes Fill="WhiteSmoke">

<ChartFX:ConditionalAttributes.Condition>

<ChartFX:RangeCondition From="2" To="2" BindingPath="RunStatusCode"/>

</ChartFX:ConditionalAttributes.Condition>

</ChartFX:ConditionalAttributes>

</ChartFX:Chart.ConditionalAttributes>

</ChartFX:Chart>
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.

×
×
  • Create New...