I have a page that uses several UltraWebCharts for pie charts. To keep things consistant, I used the ColorModel.CustomPalette to assign a color palette to each chart. I have twelve colors in my palette. However, each pie chart starts on a different color, and some charts will repeat colors even though they have less than twelve items. I'm hoping you can help me stop them from repteating.
Edit:
I found part of the issue (explained in the next post), so I removed the code from this post, as it made it hard to read.
That worked great! Thank you very much!
private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e) { int wedgeCounter = 0; Dictionary<int, PaintElement> paintElementsByRow = new Dictionary<int, PaintElement>(); foreach (Primitive p in e.SceneGraph) { Wedge w = p as Wedge; if (w != null) { PaintElement pe; switch (wedgeCounter++) { case 0: pe = new PaintElement(Color.Red); break; case 1: pe = new PaintElement(Color.Green); break; case 2: pe = new PaintElement(Color.Blue); break; default: pe = new PaintElement(Color.Black); break; } paintElementsByRow[w.Row] = w.PE = pe; } Box b = p as Box; if (b != null && b.Path != null && b.Path.IndexOf("Legend") != -1 && paintElementsByRow.ContainsKey(b.Row)) { b.PE = paintElementsByRow[b.Row]; } } }
Sadly, while this fix worked great for the wedges, now the colors don't match the boxes in the legend. I have discovered how to change the colors of the boxes as well, but I can't find any way to link any given wedge to a box in the FillSceneGraph method.
Is this possible? Is there any way for me to link the two at this point, or will I manually have to create a legend? If so, do you have any good code examples of how to do so?
Thanks for all your help so far.
That worked great! Thank you so much.
private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e) { int wedgeCounter = 0; foreach (Primitive p in e.SceneGraph) { Wedge w = p as Wedge; if (w != null) { switch (wedgeCounter++) { case 0: w.PE = new PaintElement(Color.Red); break; case 1: w.PE = new PaintElement(Color.Green); break; case 2: w.PE = new PaintElement(Color.Blue); break; } } } }