I have a requirement where i need to manually set the color on a pie chart.
Dim iRow As Integer Dim paintElement As PaintElement For Each r As DataRow In dt.Rows Dim o As Override = New Override() o.Row = iRow o.Column = 0 Dim sColor() As String sColor = r.Item(2).ToString.Split(",") paintElement = New PaintElement() paintElement.ElementType = PaintElementType.SolidFill paintElement.Fill = Color.FromArgb(sColor(0), sColor(1), sColor(2), sColor(3)) o.PE = paintElement
chart.Override.Add(o)
iRow += 1 Next
this works like a charm. However, when I look at the Legend, the colors are not matching. I assume I have to do an override for the legend colors as well.
How can I do That ?
Hello Fred,
Fred Morin said: If I use custom linear, will this assure me that each row has the color i want it to have ?
If I use custom linear, will this assure me that each row has the color i want it to have ?
If you keep the same array order in Color[] and your rows, then you could be sure that each has correct color from DataSet.
Let me know if you have any questions.
Regards
I could try that, however, i must tell you the color in is the dataset, each row's last column is the color which I extract at runtime. If I use custom linear, will this assure me that each row has the color i want it to have ?
Did you try with CustomPalette property. I think that using this approach you could achieve desired behavior.
The code will be :
Color[] initColor = new Color[] { Color.Red, Color.Gold, Color.LightSkyBlue };
this.ultraChart1.ColorModel.ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.CustomLinear;
this.ultraChart1.ColorModel.CustomPalette = initColor;
Please let me know if you have any questions.