Jump to content
Software FX Community

How to change default marker for Pie charts?


Recommended Posts

Unfortunately changing how the marker is represented in the legend requires a new template, your idea of honoring the Marker.Shape is very good but we cannot incorporate it because it would break scenarios where people changed the marker shape in a line chart and then switched to pie.

Add this to your Window.Resources or in your app.xaml

  <DataTemplate x:Key="LegendItemRect">

  <Grid x:Name="grid" Margin="{Binding Path=Margin}">


  <ColumnDefinition Width="*" SharedSizeGroup="FirstRow" />

  <ColumnDefinition Width="*" />


  <Rectangle Fill="{Binding Path=Fill}" Stroke="{Binding Path=Stroke}" Width="12" Height="12" Margin="0,0,4,0" Grid.Column="0" />

  <Border Background="Transparent" Grid.Column="1" VerticalAlignment="Center">

  <ContentControl IsHitTestVisible="false" Content="{Binding Path=Content}" ContentTemplate="{Binding Path=ContentTemplate}" Foreground="{Binding Path=Foreground}" FontFamily="{Binding Path=FontFamily}" FontSize="{Binding Path=FontSize}" FontStyle="{Binding Path=FontStyle}" FontWeight="{Binding Path=FontWeight}"/>




  <DataTrigger Binding="{Binding Path=Dimmed}">




  <Setter Property="Opacity" Value="0.25" TargetName="grid" />




And this code to your constructor or loaded handler

  chart1.LegendBox.ItemAttributes[chart1.AxisX].Template = (DataTemplate) FindResource("LegendItemRect");




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.

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