How to implement dynamic marker functionality on a curve
Posted: Tue Nov 12, 2024 7:58 am
I want to dynamically add some markers on the curve, similar to what is shown in the image below. How can I achieve this?
Steema Software - Customer Support Forums
http://teechart.com/support/
Code: Select all
private void Form1_Load(object sender, System.EventArgs e) {
tChart1.Aspect.View3D = false;
line1.FillSampleValues(20);
}
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) {
if(tChart1.Series.Count > 0){
if(tChart1.Series[0].Count > 10) {
Series s = tChart1.Series[0];
int h = Convert.ToInt32(g.TextHeight("H"));
Point p1 = new Point(s.CalcXPos(3), s.CalcYPos(3));
Point p2 = new Point(s.CalcXPos(10), s.CalcYPos(10));
g.Pen.Color = Color.Blue;
g.Pen.Width = 2;
g.Pen.Style = System.Drawing.Drawing2D.DashStyle.Dash;
g.MoveTo(p1);
g.LineTo(p2, 0);
g.TextOut(p1.X, p1.Y - h, "Point value: " + s.YValues[3].ToString());
g.TextOut(p2.X, p2.Y, "Point value: " + s.YValues[10].ToString());
g.TextOut(p2.X, p2.Y + h, "Change is: " + Convert.ToString(s.YValues[3] - s.YValues[10]));
}
}
}