Hi,
I want to add a specific vertical line in the LineChart.
Like this attachment, there is a vertical black line in this chart.
Could you tell me how to do this? thanks a lot!
http://forums.infragistics.com/forums/t/43733.aspx
can this line be drag when the mouse down?
if it can, how to do that?
thanks for your reply.
You will have to handle a combination of MouseMove, DataItemOver/Out, MouseDown/Up events to accomplish this.
public int XCoord { get; set; }public bool IsMouseDown { get; set; }public bool IsMouseOver { get; set; }private NumericDataPoint point = new NumericDataPoint(0, "", true);
private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e){ if (e.Grid.Count == 0) return; Rectangle bounds = e.ChartCore.GridLayerBounds; int x = XCoord; if (x < bounds.Left) { x = bounds.Left; } if (x>bounds.Right) { x = bounds.Right; } Box line = new Box(new Rectangle(x, bounds.Top, 2, bounds.Height)); line.PE.Stroke = line.PE.Fill = Color.Black; line.PE.StrokeWidth = 1; line.Row = line.Column = 0; line.Caps = PCaps.HitTest | PCaps.Tooltip; line.Layer = e.ChartCore.GetChartLayer(); line.Chart = ChartType.ColumnChart; line.Value = "myline";
line.DataPoint = point;
e.SceneGraph.Add(line);}
private void Form1_Load(object sender, EventArgs e){ ultraChart1.ChartType = ChartType.ColumnChart; ultraChart1.Data.DataSource = DemoTable.Table(); XCoord = 150;}
private void ultraChart1_DataItemOver(object sender, Infragistics.UltraChart.Shared.Events.ChartDataEventArgs e){ if (e.Primitive is Box && e.Primitive.DataPoint == point) { IsMouseOver = true; }}
private void ultraChart1_DataItemOut(object sender, Infragistics.UltraChart.Shared.Events.ChartDataEventArgs e){ IsMouseOver = false;}
private void ultraChart1_MouseDown(object sender, MouseEventArgs e){ if (IsMouseOver) IsMouseDown = true; else IsMouseDown = false;}
private void ultraChart1_MouseUp(object sender, MouseEventArgs e){ IsMouseDown = false;}
private void ultraChart1_MouseMove(object sender, MouseEventArgs e){ if (IsMouseDown) { XCoord = e.X; ultraChart1.InvalidateLayers(); }}