Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7048465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:53:44+00:00 2026-05-28T02:53:44+00:00

I have a pie chart on a WPF user control whose data changes periodically,

  • 0

I have a pie chart on a WPF user control whose data changes periodically, however I am not instantiating a new chart control each time, just clearing the data in the ItemsSource and then inserting new values.

Each time the values get refreshed, the colour palate continues rolling through its colour selections.

The chart colour selection always starts off with the same colour selections (first is red, then blue etc), I would like to be able to tell the chart to restart its colour selection from scratch each time I reset the data source, instead of getting different colours everytime I clear the and reset the data items.

I tried creating a new instance of the ObservableCollection each time but that did not make any difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:53:44+00:00Added an answer on May 28, 2026 at 2:53 am

    I’ve got the same problem, and I found another solution. Maybe it’s not the better one, but it works.

    I added an int property to my object binding on the PieSeries, who represent the element’s index in the ObservableCollection.
    Then I created a ResourceDictionaryCollection which contains all the default colors of the Palette:

    <datavis:ResourceDictionaryCollection x:Key="CouleursGraphique">
        <!-- Blue -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFB9D6F7" />
            <GradientStop Color="#FF284B70" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Red -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFFBB7B5" />
            <GradientStop Color="#FF702828" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Light Green -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFB8C0AC" />
            <GradientStop Color="#FF5F7143" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Yellow -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFFDE79C" />
            <GradientStop Color="#FFF6BC0C" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Indigo -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFA9A3BD" />
            <GradientStop Color="#FF382C6C" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Magenta -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFB1A1B1" />
            <GradientStop Color="#FF50224F" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Dark Green -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FF9DC2B3" />
            <GradientStop Color="#FF1D7554" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Gray Shade -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFB5B5B5" />
            <GradientStop Color="#FF4C4C4C" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Blue -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FF98C1DC" />
            <GradientStop Color="#FF0271AE" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Brown -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFC1C0AE" />
            <GradientStop Color="#FF706E41" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Cyan -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFADBDC0" />
            <GradientStop Color="#FF446A73" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Special Blue -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FF2F8CE2" />
            <GradientStop Color="#FF0C3E69" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Gray Shade 2 -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFDCDCDC" />
            <GradientStop Color="#FF757575" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Gray Shade 3 -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFF4F4F4" />
            <GradientStop Color="#FFB7B7B7" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
        <!-- Gray Shade 4 -->
        <ResourceDictionary>
          <RadialGradientBrush x:Key="Background" GradientOrigin="-0.1,-0.1" Center="0.075,0.015" RadiusX="1.05" RadiusY="0.9">
            <GradientStop Color="#FFF4F4F4" />
            <GradientStop Color="#FFA3A3A3" Offset="1" />
          </RadialGradientBrush>
        </ResourceDictionary>
      </datavis:ResourceDictionaryCollection>
    

    I added a converter that returns the color at the specified index of ResourceDictionaryCollection.

     /// <summary>
        /// Convertit une valeur.
        /// </summary>
        /// <param name="value">Valeur produite par la source de liaison.</param>
        /// <param name="targetType">Type de la propriété de cible de liaison.</param>
        /// <param name="parameter">Paramètre de convertisseur à utiliser.</param>
        /// <param name="culture">Culture à utiliser dans le convertisseur.</param>
        /// <returns>
        /// Une valeur convertie. Si la méthode retourne null, la valeur Null valide est utilisée.
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ResourceDictionaryCollection listeCouleurs = parameter as ResourceDictionaryCollection;
            int indice = (int)value;
    
            return listeCouleurs[indice % listeCouleurs.Count]["Background"];
        }
    

    And i used all this elements in the Xaml like this:

      <charting:Chart.Series>
    <charting:PieSeries ItemsSource="{Binding Path=Donnees}"
                        DependentValuePath="Valeur"
                        IndependentValuePath="Libelle">
      <charting:PieSeries.Palette>
        <datavis:ResourceDictionaryCollection>
          <ResourceDictionary>
            <Style x:Key="DataPointStyle" TargetType="Control">
              <Setter Property="Background" Value="{Binding Path=Index, Converter={StaticResource convCouleur}, ConverterParameter={StaticResource CouleursGraphique}}"/>
            </Style>
          </ResourceDictionary>
        </datavis:ResourceDictionaryCollection>
      </charting:PieSeries.Palette>
    </charting:PieSeries>
    

    I hope that answer can help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a pie chart in JFreeChart. However, numerical values are not appearing
I have a pie chart in BIRT and about 80 data points. I'm looking
i have a pie chart but i am not able to put a hyperlink
I have developed an animated Pie Chart, in which when a user clicks on
I am new to android. I have drawn a pie chart, and when I
Say I have multiple detail bands containing pie charts. Each pie chart's JRXML looks
I have a microsoft pie chart control. I am setting the background transparent, but
I have external data that I'd like to make into a pie chart with
I have some pretty basic data for a pie chart. Yes: 189.84 (57.03%) No:
RS2008 - pie chart I have 'outside' labels with lines pointing to the segment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.