chris69nz Posted March 10, 2008 Report Share Posted March 10, 2008 Hi, I like the chart control so far. How would I go about getting labels into the slices in a 3D pie chart? I'd like the content of the label to not be the value, e.g. it will be a formatted description from my business object. Also I would like it to always render from left to right and not rotated with the pie chart, is this possible? Thanks Chris Link to comment Share on other sites More sharing options...
JuanC Posted March 13, 2008 Report Share Posted March 13, 2008 In the following XAML the chart is plotting a property called ProductSales and the point label will show an image (property called ImageLogo} and 2 labels, the first one will show the slice value (the TooltipConverter trick also allows you to show other elements calculated by the chart such as percentages using %p), the second label shows a property in your business object called ProductName. I also included XAML showing how to change the point colors and the AxisX.LabelPath set to ProductName. This will be used in tooltips. <cfx:Chart Gallery="Pie" x:Name="chart1" ItemsSource="{Binding Source={StaticResource productData}}"><cfx:Chart.Series><cfx:SeriesAttributesCollection><cfx:SeriesAttributes BindingPath="ProductSales"><cfx:SeriesAttributes.PointLabels><cfx:PointLabelAttributes><cfx:PointLabelAttributes.Template><DataTemplate><StackPanel Orientation="Horizontal" IsHitTestVisible="false"><Image x:Name="myImg" Source="{Binding Path=DataItem.ImageLogo}" Width="50" Height="50" VerticalAlignment="Center"/><StackPanel><Label Background="Transparent" FontFamily="{Binding Path=FontFamily}" Foreground="{Binding Path=Foreground}" FontSize="{Binding Path=FontSize}" FontStyle="{Binding Path=FontStyle}" HorizontalAlignment="Left" VerticalAlignment="Top"><Label.Content><Binding Path="Self" Converter="{StaticResource MyTooltipConverter}" ConverterParameter="%v" /></Label.Content></Label><Label Content="{Binding Path=DataItem.ProductName}" Background="Transparent" FontFamily="{Binding Path=FontFamily}" Foreground="{BindingPath=Foreground}" FontSize="{Binding Path=FontSize}" FontStyle="{Binding Path=FontStyle}" HorizontalAlignment="Left" VerticalAlignment="Top"/></StackPanel></StackPanel></DataTemplate></cfx:PointLabelAttributes.Template></cfx:PointLabelAttributes></cfx:SeriesAttributes.PointLabels></cfx:SeriesAttributes></cfx:SeriesAttributesCollection></cfx:Chart.Series><cfx:Chart.Points><cfx:PointAttributesCollection> <cfx:PointAttributes Fill="#94FFFF00"/> <cfx:PointAttributes Fill="#94909571"/> <cfx:PointAttributes Fill="#94BD9B50"/> <cfx:PointAttributes Fill="#94ffb203"/> <cfx:PointAttributes Fill="#94b95419"/></cfx:PointAttributesCollection></cfx:Chart.Points><cfx:Chart.AxisX> <cfx:Axis LabelPath="ProductName"/></cfx:Chart.AxisX></cfx:Chart>To use the converter you need xmlns:cfx="clr-namespace:ChartFX.WPF;assembly=ChartFX.WPF"xmlns:cfxConverters="clr-namespace:ChartFX.WPF.Converters;assembly=ChartFX.WPF"And the following in your window/page resources <cfxConverters:TooltipConverter x:Key="MyTooltipConverter"/>Regards, JuanC Link to comment Share on other sites More sharing options...
chris69nz Posted March 14, 2008 Author Report Share Posted March 14, 2008 Thanks! Link to comment Share on other sites More sharing options...
Mick Posted January 29, 2010 Report Share Posted January 29, 2010 Is there any way I can selectively turn on/off pie labels? Is there a property of the chart that I can bind to? In this screen, I want to remove the labels/lines from the small chart because they are clipped & illegible: Thank you, Mick Link to comment Share on other sites More sharing options...
Mick Posted February 16, 2010 Report Share Posted February 16, 2010 Is there any way the pie labels can be selectively turned off? Additionally, I have found that sometimes when the name of the pie slice is too large (in either the main chart or the sub-chart), it gets clipped. Is there any way to set the Z-Index of the label to the forefront so that it is not clipped? The following screen demonstrates label clipping on the small pie for text that is too large: There's an invisible border around the chart, but there's plenty of space for the labels (it also happens on the large chart if the labels are too long). Is there a way to prioritize rendering of labels over rendering of the chart (without labels, the chart information doesn't make much sense if the legend is turned off)? Thank you, Mick Link to comment Share on other sites More sharing options...
JuanC Posted February 18, 2010 Report Share Posted February 18, 2010 >> Is there any way the pie labels can be selectively turned off? You can turn off labels on a per-series basis but when the user clicks one of the "small" charts it will switch places with the big one but we do not generate any events so you will not have a way to flip the per-series labels visibility. Starting in build 3700 we have made the following changes to pie chart 1) In previous builds we forced labels in "small" pies to be inside and scaled only if the Pie properties were unchanged, now it will do it even if you change some of the pie label properties 2) We have exposed a property called ThumbnailStyle, if you set this property to 0 we will keep the old behavior respecting any label changes on the "small pies", you can also set this property to PieThumbnailStyles.HideLabels, in this case we will hide the labels for "small" pies and handle changes automatically. >> There's an invisible border around the chart, but there's plenty of space for the labels The reason for this is that pie charts need to have a square space, unfortunately we limit the space before the label pass, I am not sure if we can fix this on this branch but we will certainly fix this on future major versions (i.e. 8.1) Regards, JuanC Link to comment Share on other sites More sharing options...
JuanC Posted March 18, 2010 Report Share Posted March 18, 2010 Build 3729 should fix the clipping issue in the thumbnail pie related to labels and titles. JuanC Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.