Hi,
is there a way to select a series with a mouse and then
drag around? Motivation would be: you have a few
series plotted and you want to see how well a particular series
aligns with another one.
Made up example: Imagine you have two sinus like curves
that were recorded sequentially (i.e. x-axis not the same, y may
be different too). You want to pick with the mouse one of the
curves and drag is close to the other to see how well they match in
shape.
Thanks,
Norman
is shifting a series with the mouse possible?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Norman,
Yes you can achieve doing something like this:
Yes you can achieve doing something like this:
Code: Select all
private bool clicked;
private int origX, origY, X, Y, Index;
private void Form1_Load(object sender, EventArgs e)
{
tChart1.Aspect.View3D = false;
tChart1.Zoom.Allow = false;
line1.FillSampleValues();
line2.FillSampleValues();
for (int i = 0; i < tChart1.Series.Count; i++)
{
tChart1[i].Click += new MouseEventHandler(Series_Click);
}
}
void Series_Click(object sender, MouseEventArgs e)
{
SetClicked(e.X, e.Y, tChart1.Series.IndexOf(sender as Steema.TeeChart.Styles.Series));
}
private void SetClicked(int X, int Y, int i)
{
clicked = true;
Index = i;
origX = X;
origY = Y;
}
private void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if (clicked)
{
X = e.X;
Y = e.Y;
tChart1.Refresh();
}
}
private void tChart1_MouseUp(object sender, MouseEventArgs e)
{
clicked = false;
tChart1.Refresh();
}
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
if (clicked)
{
int diffX = X - origX;
int diffY = Y - origY;
Steema.TeeChart.Styles.Series s = tChart1[Index];
for (int i = 0; i < s.Count-1; i++)
{
Point p0 = new Point(s.CalcXPos(i) + diffX, s.CalcYPos(i) + diffY);
Point p1 = new Point(s.CalcXPos(i+1) + diffX, s.CalcYPos(i+1) + diffY);
g.Pen.Color = s.Color;
g.Line(p0, p1);
}
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |