Nevron Forum

Using parameters of DataPoints from the series

https://www.nevron.com/Forum/Topic5411.aspx

By Alexander Sorich - Tuesday, July 26, 2011

Hello,
I'm looking for a funktion for
extract for parameter from series.
I'm using a Chart for .NET,
and I'm creating a series, for example NLineseries.
Then I'm adding a DataView to the serie.
If i'm click at the DataPoint in the series, i need the parameter from DataPoint
for example:
seriesName "Dataseries1"
seriesID "123456"
xvalue "01.07.2011"
value "45,67"
zvalue "123,456"

How can i extract there parameters?
I need there parameters not for a tooltip,
but for another funktion for example for output in the TextBox.

Best Regards,
Alexander
By Nevron Support - Tuesday, July 26, 2011

Hi Alexander,

You can use the HitTest method for this purpose - take a look at the following code snippet:

  private void Form1_Load(object sender, EventArgs e)
  {
   NChart chart = nChartControl1.Charts[0];

   NBarSeries bar = new NBarSeries();
   bar.Values.Add(10);
   bar.Values.Add(20);
   bar.Values.Add(30);
   chart.Series.Add(bar);

   nChartControl1.MouseDown += new MouseEventHandler(nChartControl1_MouseDown);
  }

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

   if (result.ChartElement == ChartElement.DataPoint)
   {
    double value = (double)(((NSeries)result.Series).Values[result.DataPointIndex]);
    textBox1.Text = "Data Point [" + result.DataPointIndex.ToString() + "], Value [" + value.ToString() + "]";
   }
  }

it shows how to perform hit test and get the data point value when you click on it. Hope this helps - let us know if you meet any problems.

By Alexander Sorich - Tuesday, August 2, 2011

Hello Nevron Support Team,
Thankyou very much for Your help! I can implement the method with MouseDown
and use the information in my software now.
I've a question to the chart.
If I'm creating the
NsmoothLineSeries,
NsmoothAreaSeries,
NbarSeries,
NpolarLineSeries,
NpolarPointSeries,
NpieSeries,
NradarLineSeries or
NradarAreaSeries,
then it is possible to show the datapoints.
If i'm creating a
NareaSeries,
NpolarAreaSeries or
NlineSeries,
i always get the [0] Element to show after mouse click.
It is possible to remove this error ?

Best Regards,
Alexander

p.s.
I have got added an reply of MouseMovie. I have the same problem in MouseMovie too.
If I take the mouse over the datapoint from
NareaSeries,
NpolarAreaSeries or
NlineSeries,
i get the [0] Element to show after mouse click too.
by the another N...Seies Types this problem does not appear.