How to implement dynamic marker functionality on a curve
-
- Newbie
- Posts: 2
- Joined: Mon Sep 23, 2024 12:00 am
How to implement dynamic marker functionality on a curve
I want to dynamically add some markers on the curve, similar to what is shown in the image below. How can I achieve this?
Re: How to implement dynamic marker functionality on a curve
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
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
Steema Support
-
- Newbie
- Posts: 2
- Joined: Mon Sep 23, 2024 12:00 am
Re: How to implement dynamic marker functionality on a curve
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
The applied example in the tutorial I linked shows you how to do that:
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
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]));
}
}
}
tChart1.Graphics3D.RotateLabel offers text at angles other than horizontal.
Regards,
Marc
Steema Support