Jump to content
Software FX Community

Setting chart style changes internal series order


Recommended Posts

- Version 8.0.3581.26941 -

Depending on the style I use for a chart, series order that is internal to the chart changed. It appears that the ChartFX.WPF.Motifs.Glass.Style (the default style) is the only one that doesn't change the internal series order.

The reason I need the internal series order to remain the same as the order I added them is because I am trying to sync 2 separate series (bars and lines).

The order for the lines from bottom to top SHOULD be - blue, green, yellow, red, light blue.

Posted Image


Posted Image

Floating (bars have strokes/fills assigned, but they are obviously different from what is being displayed)

Am I doing something incorrectly?


---------- CODE ----------


  Title="Chart series colors"
  <cfx:Chart x:Name="chart1" />


using System.Collections.Generic;
using System.Windows;
using ChartFX.WPF;

namespace ChartFX
  /// <summary>
  /// Interaction logic for Window7.xaml
  /// </summary>
  public partial class Window7 : Window
  public Window7()
  this.Loaded += new RoutedEventHandler(Window7_Loaded);

  private void Window7_Loaded(object sender, RoutedEventArgs e)

  // Create the ItemsSource and bind it to the chart
  IList<ExampleBindingClass> exampleBindingClasses = new List<ExampleBindingClass>();
  exampleBindingClasses.Add(new ExampleBindingClass { X = "A", Y1 = 1, Y2 = 2, Y3 = 3, Y4 = 4, Y5 = 5 });
  exampleBindingClasses.Add(new ExampleBindingClass { X = "B", Y1 = 1, Y2 = 2, Y3 = 3, Y4 = 4, Y5 = 5 });
  chart1.AxisX.Labels.BindingPath = "X";
  chart1.ItemsSource = exampleBindingClasses;

  // Add bar series
  for (int i = 1; i <= 5; i++)
  SeriesAttributes bars = new SeriesAttributes("Y" + i);

  // Add lines series and align colors
  for (int i = 1; i <= 5; i++)
  SeriesAttributes lines1 = new SeriesAttributes("Y" + i);
  lines1.Gallery = Gallery.Line;
  lines1.Stroke = chart1.Series[i - 1].Fill;
  lines1.Fill = chart1.Series[i - 1].Fill;
  lines1.StrokeThickness = 10;


  chart1.Style = ChartFX.WPF.Motifs.Basic.Style; // Change this line to see the problem

  public class ExampleBindingClass
  public string X { get; set; }
  public double Y1 { get; set; }
  public double Y2 { get; set; }
  public double Y3 { get; set; }
  public double Y4 { get; set; }
  public double Y5 { get; set; }

Link to comment
Share on other sites

The problem is that at the time you are "copying" the brushes used in the first 5 series for the second set of 5 series, the palette is still glass so you are copying the glass colors, after that you are setting the Palette which will result in the palette being used in the first set of series (because you never modified their properties) but NOT on the second set of series because your settings override the palette.

The solution is to move the setting of the Style before both series loops.


Link to comment
Share on other sites

No. It is NOT necessary to clear and re-add series when the style changes.

You were simply requesting the series brushes before the palette was changed and additionally only changing some of the series brushes (last 5). So when the palette was changed you end up with the first 5 series using the new palette (because you never set their brushes) and the second 5 series having the color matching the first 5 colors of the PREVIOUS palette.


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