Page 1 of 1

How to implement dynamic marker functionality on a curve

Posted: Tue Nov 12, 2024 7:58 am
by 16098770
I want to dynamically add some markers on the curve, similar to what is shown in the image below. How can I achieve this?
20241112155720.png
20241112155720.png (6.57 KiB) Viewed 3216 times

Re: How to implement dynamic marker functionality on a curve

Posted: Tue Nov 12, 2024 8:27 am
by Marc
Hello,

Could you clarify what you mean by dynamic please? ... It is possible to use the OnAfterDraw event (see: tutorial) but you could add text according to mouse movements or data movements. The image you show suggests something related to Axis label location, whereupon you could use the GetAxisLabel event alone (see Axis tutorial) or to set the text and then plot the text in OnAfterDraw. Many options.

Regards,
Marc Meumann

Re: How to implement dynamic marker functionality on a curve

Posted: Tue Nov 12, 2024 8:41 am
by 16098770
Dynamic markers can display marker text on the curve based on x-axis coordinate values. Ideally, they should also support zooming.

Re: How to implement dynamic marker functionality on a curve

Posted: Tue Nov 12, 2024 10:43 am
by Marc
The applied example in the tutorial I linked shows you how to do that:

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])); 
            } 
        } 
} 
In this case it's taking series values "s.CalcXPos(3), s.CalcYPos(3)" but values could be extracted from axis scales in the same way, using the Calc...(various options) methods.

tChart1.Graphics3D.RotateLabel offers text at angles other than horizontal.

Regards,
Marc