Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure if this is the best way of doing it but I struggled with the same thing and eventually got it working like this.</p> <p>Declare a palette:</p> <pre><code>System.Windows.Controls.DataVisualization.ResourceDictionaryCollection pieSeriesPalette = new System.Windows.Controls.DataVisualization.ResourceDictionaryCollection(); </code></pre> <p>Then create a brush (or brushes) with the color information:</p> <pre><code>Brush currentBrush = new SolidColorBrush(Color.FromRgb(128, 128, 128)); //Grey </code></pre> <p>With each brush, create a new Style and add it to the palette collection:</p> <pre><code>System.Windows.ResourceDictionary pieDataPointStyles = new ResourceDictionary(); Style stylePie = new Style(typeof(PieDataPoint)); stylePie.Setters.Add(new Setter(PieDataPoint.BackgroundProperty, currentBrush)); pieDataPointStyles.Add("DataPointStyle", stylePie); pieSeriesPalette.Add(pieDataPointStyles); </code></pre> <p>Note that each brush (or palette entry) has to be created as a new ResourceDictionary object. If you create 10 brushes and just add them all to the same ResourceDictionary the piechart will only use the first color. (Or maybe I'm just doing something wrong).</p> <p>Then set the chart palette to the custom palette:</p> <pre><code>this.yourChartsName.Palette = pieSeriesPalette; </code></pre> <p>This is only useful if you want to customise the palette to specific colors. For a color range or fixed list of colors I believe you can just definie the palette in XAML. Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload