How to select an entire line on the chart?


https://www.nevron.com/Forum/Topic8797.aspx
Print Topic | Close Window

By Fernando Albino - 10 Years Ago
Hello,

I would be like to select an especific line (by clicking), for then clone this.

Can anyone help me?

Fernando
By Nevron Support - 10 Years Ago
Hi Fernando,

You can easily perform a hit test using the following code:

void nChartControl1_MouseMove(object sender, MouseEventArgs e)
{
NHitTestResult result = nChartControl1.HitTest(e.X, e.Y);

    if (result.Series as NLineSeries != null)
    {
      // result.Series holds a reference to the clicked line;
    }
}

The All Examples\Interactivity\Mouse Events group of examples show how to perform hit testing in general. Just let us know if you have any questions...
By Fernando Albino - 10 Years Ago
Excellent, thank you!

I need help for something else...

The selected line need to move to the right or left (then modify X axis values to do this(?), im using NNumericUpDown)
I have a fix milliseconds List<DateTime> to create X axis, loaded from some file. who can I modify this to can be able to move right or left my line? It's possible to expand X axis after created?

Thank you!
By Nevron Support - 10 Years Ago
Hi Fernando,

Can you elaborate a bit on what you want to accomplish - if is it simply to shift the X values of the line then you just need to iterate over the data points in the line and add / subtract a fixed amount in order to move the line...