Jump to content
Software FX Community

Pie Labels and OtherTransform


Mick

Recommended Posts

I retemplated the labels for a pie chart following the directions at this post: http://community.softwarefx.com/forums/p/8822/20612.aspx#20612.

However, when I combine label templating with an OtherTransform, the label for the OtherTransform isn't applied - instead, it's a percent (the default label).

Posted Image 

Is there a way to make the two use the same label ("Other"), or do I have to choose between templating labels orusing an OtherTransform?

Thank you,

Mick


Link to comment
Share on other sites

Is there a property on the OtherTransform that I can get to through my DataTemplate? IF so, what is its binding path?

For example, I may want to display "Other (3%)" or "Other (5 items)" instead of hardcoding "Other" as my pie slice name.

This is what I have currently:

Labels:

  <DataTemplate
  x:Key="ChartFXPieLabelTemplate"
  >
  <Label
  Content="{Binding Path=DataItem.Content}" ...

Other ("Other" is hard coded)

  <DataTemplate
  x:Key="ChartFXPieLabelOtherTemplate"
  >
  <Label
  Content="Other" ...

---

Thank you,

Mick

Link to comment
Share on other sites

You can display the number of items by using the DataItem.Items.Count path, note that we expose the items collection, and we use this in the tooltip to display the detail of all the elements grouped in the Other bucket.

<TextBlock Text="{Binding Path=DataItem.Items.Count}"/> 

To show the accumulated value or percentage you can use ToolTipConverter, the advantage of using this is that it knows about Axis settings, e.g. if you set the Axis.Format to currency it will show the currency sign when displaying the value, e.g.

xmlns:cfxConverters="clr-namespace:ChartFX.WPF.Converters;assembly=ChartFX.WPF"

<DataTemplate.Resources>  <cfxConverters:TooltipConverter x:Key="MyTooltipConverter"/></DataTemplate.Resources>

<TextBlock>  <TextBlock.Text>   <Binding Path="Self" Converter="{StaticResource MyTooltipConverter}" ConverterParameter="V: %v P: %p%%" />  </TextBlock.Text></TextBlock> 

JuanC 

WpfApplication1Modified.zip

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...