Mick Posted January 26, 2010 Report Share Posted January 26, 2010 - 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. Basic Floating (bars have strokes/fills assigned, but they are obviously different from what is being displayed) Am I doing something incorrectly? Mick ---------- CODE ---------- xaml: <Window x:Class="ChartFX.Window7" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cfx="clr-namespace:ChartFX.WPF;assembly=ChartFX.WPF" Title="Chart series colors" Height="400" Width="600" > <Grid> <cfx:Chart x:Name="chart1" /> </Grid></Window> xaml.cs 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() { InitializeComponent(); this.Loaded += new RoutedEventHandler(Window7_Loaded); } private void Window7_Loaded(object sender, RoutedEventArgs e) { chart1.Series.Clear(); // 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); chart1.Series.Add(bars); } // 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.Series.Add(lines1); } 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; } }} Quote Link to comment Share on other sites More sharing options...
JuanC Posted January 26, 2010 Report Share Posted January 26, 2010 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. JuanC Quote Link to comment Share on other sites More sharing options...
Mick Posted January 26, 2010 Author Report Share Posted January 26, 2010 This means that it is necessary to clear and re-add every series each time a style is changed, correct? Thank you, Michael Quote Link to comment Share on other sites More sharing options...
JuanC Posted January 27, 2010 Report Share Posted January 27, 2010 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. JuanC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.