Profile Picture

NHitTestResults and ChartElement.DataPoint No Longer Works

Posted By James Richason 5 Years Ago

NHitTestResults and ChartElement.DataPoint No Longer Works

Author
Message
James Richason
Question Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 5 Years Ago
Posts: 10, Visits: 63
We have an old method that used to search for a DataPoint and then display that position on the chart.  DataPoint is no longer found.  Has something changed about how data points are added.

Here's the code:

  private void OnValueChanged(object sender, EventArgs e)
   {
    var xAxisValue = DateTime.FromOADate(_chartHorizontalAxisCursor.Value);
    double yAxisValue = _chartVerticalAxisCursor.Value;
    NHitTestResult hitTest = _chartControl.HitTest(_mouseXPoint, _mouseYPoint);
    if (hitTest.ChartElement == ChartElement.DataPoint)
    {
      if (GetChartCategory(_resultsViewInfo.ChartType) == ChartCategory.Column)
      {
       toolTip1.SetToolTip(_chartControl, "Y:" + yAxisValue.ToString("N"));
      }
      else
      {
       toolTip1.SetToolTip(_chartControl, "X:" + xAxisValue.ToString("MMM dd hh:mm:ss tt") + ", Y:" + yAxisValue.ToString("N"));
      }
    }
    else
    {
      //toolTip1.SetToolTip(_chartControl, "JR");
      toolTip1.SetToolTip(_chartControl, "Y:" + yAxisValue.ToString("N"));
    }
   }




Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi James,
We just tested with the following code:
  private void Form1_Load(object sender, EventArgs e)
   {
    NChart chart = nChartControl1.Charts[0];
    chart.Enable3D = true;
    NPointSeries point = new NPointSeries();

    for (int i = 0; i < 10; i++)
    {
      point.Values.Add(i);
    }

    chart.Series.Add(point);

    nChartControl1.MouseMove += NChartControl1_MouseMove;
   }

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

    if (result.ChartElement == ChartElement.DataPoint)
    {
      textBox1.Text = "Data point: " + result.DataPointIndex.ToString();
    }
    else
    {
      textBox1.Text = result.ChartElement.ToString();
    }
   }

and hit testing was working properly - is there something specific about your configuration - like - 2D/3D, type of series etc...

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic