Hello
I've a UltraLineChart to whcih i bind a datatable. I get 8-16 series in my chart. But the legend and line colors get repeated for every five lines. How can i give different colors for different series?
Thank you
Regards
NLV
nlvraghavendra said:1. It hides the scroll bar too.
that is because of this code:
if (e.Primitive.Path.IndexOf("Legend") == -1) { e.Primitive.Visible = false; }
one way to fix that is:
if (e.Primitive.Path.IndexOf("Legend") == -1) {
e.Primitive.Visible = e.Primitive.Path.IndexOf("ScrollBar") != -1; }
nlvraghavendra said:2. When i move my mouse out of the chart, the chart reverts itself back showing all the lines. Why is ChartDrawItem event raised when i move my mouse out of the control? I really dont understand.
the chart needs to invalidate the view on mouseout in order to clear any highlighting and tooltips being displayed.
i think you will get the desired behavior by moving your Click code to a MouseDown event handler, and call InvalidateLayers() as well:
private void ultraChart1_Click(object sender, EventArgs e) { } private void ultraChart1_MouseDown(object sender, MouseEventArgs e) { emptyChartClicked = true; this.currentRow = -1; this.ultraChart1.InvalidateLayers(); }
Okie, i did it through ChartDrawItem event.
I've other several issues with the chart
My requirement:
1.Click a legend -> Hide all the other lines and show the selected line
2. Click outside the legend any where in the empty area of the chart area or legend area -> Show all the lines again.
Problems
I've completed item 1. But the problem is
1. It hides the scroll bar too.
2. When i move my mouse out of the chart, the chart reverts itself back showing all the lines. Why is ChartDrawItem event raised when i move my mouse out of the control? I really dont understand.
Code:
ChartDrawItem
private void ifgContractLineChart_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e) { if (e.HasData) { if (e.Primitive is Polyline) { if (lineChartSeriesCount >= originalLineChartSeriesCount) lineChartSeriesCount = 0; PaintElement pe = new PaintElement(); Color clr = HexToColor(lineColors[lineChartSeriesCount++]); pe.Fill = clr; pe.FillStopColor = clr; e.Primitive.PE = pe; } if (e.Primitive.Path.IndexOf("Legend") != -1) { if (lineChartSeriesCount >= originalLineChartSeriesCount) lineChartSeriesCount = 0; PaintElement pe = new PaintElement(); Color clr = HexToColor(lineColors[lineChartSeriesCount++]); pe.Fill = clr; pe.FillStopColor = clr; e.Primitive.PE = pe; } if (e.Primitive is Infragistics.UltraChart.Core.Primitives.ScrollBar) { } if (e.Primitive.Path != null && e.Primitive.Path.IndexOf("Legend") != -1) { e.Primitive.Caps |= PCaps.HitTest; } if (this.currentRow != -1 && e.Primitive.Row == currentRow) { e.Primitive.PE = new PaintElement(Color.Red); } else if (!emptyChartClicked) { if (e.Primitive.Path.IndexOf("Legend") == -1) { e.Primitive.Visible = false; } else { e.Primitive.PE = new PaintElement(Color.White); } } //ifgContractLineChart.Axis.X.ScrollScale.Visible = true; } }
ChartDataClicked
private void ifgContractLineChart_ChartDataClicked(object sender, Infragistics.UltraChart.Shared.Events.ChartDataEventArgs e) { this.currentRow = e.Primitive.Row; this.ifgContractLineChart.InvalidateLayers(); emptyChartClicked = false; }
Chart Clicked
private void ifgContractLineChart_Click(object sender, EventArgs e) { emptyChartClicked = true; this.currentRow = -1; }
Thank you.