I am trying to use the ChartDrawItem event. I put a Consule.WriteLine() to see when it's called. I realize as long my ultrachart is open, it keeps looping in it. Is this suppose to be like that? I simply want to make use of the Primivitive to change color of my 3D chart. I only need to run one time when I load the ultraChart.
Does anyone know why it goes infinite loop in ChartDrawItem?
if
(e.HasData && this.ultraChart1.ChartType == ChartType.HeatMapChart3D)
{
Path p = e.Primitive as Path;
if (e.Primitive.Row != -1)
int division = dt.Rows.Count / 4;
if (e.Primitive.Row < division)
SolidBrush sb = new SolidBrush(ultraColorPicker1.Color);
p.Brush = sb;
p.PE.Stroke = ultraColorPicker1.Color;
}
else if (e.Primitive.Row < division * 2)
SolidBrush sb = new SolidBrush(ultraColorPicker2.Color);
p.PE.Stroke = ultraColorPicker2.Color;
else if (e.Primitive.Row < division * 3)
SolidBrush sb = new SolidBrush(ultraColorPicker3.Color);
p.PE.Stroke = ultraColorPicker3.Color;
else if (e.Primitive.Row == dt.Rows.Count - 1)
SolidBrush sb = new SolidBrush(ultraColorPicker4.Color);
p.PE.Stroke = ultraColorPicker4.Color;
else
ultraChart1.ColorModel.Skin.ApplyRowWise =
true;
ChartDrawItem fires for once for each primitive as that primitive is being rendered. Charts and especially 3d charts can have hundreds and thousands of primitives depending on the amount of data. And in case of 3d charts a data item can be made up of more than one primitive.
If you're trying to change a color on one of the data points, I suggest using Overrides collection to apply a color based on Row and Column values. You can find more information on using overrides here:http://help.infragistics.com/Help/NetAdvantage/WinForms/2009.1/CLR2.0/html/Chart_Apply_an_Override_to_a_Chart.html
I looked at the Help documentation(local) and tried to do the same. It only applies to the stroke. How can I apply color to the 3D surface? With FillSceneGraph, I set the Primitive as Path and set the path.Brush = Color. With Override, I tried to do the below but it doesn't work. Any clue?
Override override1 = new Override ();
override1.Row = 0;
override1.Column = -2;
SolidBrush sb1 = new SolidBrush(Color.Red);
override1.PE.CustomBrush = sb1;
override1.PE.Stroke = Color.Red;
override1.PE.Fill = Color.Red;
this
.ultraChart1.InvalidateLayers();
Make sure that you're not using code inside ChartDrawItem event. Also, check if you have set ElementType on the override or that it's not empty. It should be sufficient to set just the Fill property.
private void Form1_Load(object sender, EventArgs e){ ultraChart1.ChartType = ChartType.ColumnChart3D; ultraChart1.Data.DataSource = new int[,] {{2,3,4},{6,2,5},{0,3,1} };
Override override1 = new Override(); override1.Column = -2; override1.Row = 0; override1.PE.ElementType = PaintElementType.SolidFill; override1.PE.Fill = Color.Red;
ultraChart1.Override.Add(override1);}