Marker on cursor


Author
Message
Neil Rickards
Neil Rickards
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1
Hi,

Can anyone recommend a good way to display the current position of a cursor? I can get the value easily enough, but would like to display it as a floating number near the axis that follows the cursor

Is this something that's possible?

Many thanks,
Neil
Reply
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Plamen,

Yes - in this case you have to implement the following steps:

1. Intercept the mouse move event fired by the control.

2. Transform the passed view coordinates to scale coordinates.

The following code snippet shows how to achieve this:

  private void Form1_Load(object sender, EventArgs e)
  {
   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
   chart.MinDockZoneMargins = new NMarginsL(45, 0, 0, 0);


   NBarSeries bar = new NBarSeries();

   bar.Values.Add(10);
   bar.Values.Add(20);
   bar.Values.Add(30);

   chart.Series.Add(bar);

   nChartControl1.MouseMove += new MouseEventHandler(nChartControl1_MouseMove);
  }

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

   if (result.Chart != null)
   {
    NCartesianChart chart = (NCartesianChart)result.Chart;

    NStandardScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NStandardScaleConfigurator;
    scale.CustomLabels.Clear();

    NViewToScale2DTransformation transform = new NViewToScale2DTransformation(nChartControl1.View.Context, chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);
    NPointF point = new NPointF(e.X, e.Y);

    NVector2DD pointScale = new NVector2DD();

    transform.Transform(point, ref pointScale);

    NCustomValueLabel label = new NCustomValueLabel();
    label.Value = pointScale.Y;
    label.Text = label.Value.ToString("N2");
    scale.CustomLabels.Add(label);

    nChartControl1.Refresh();
   }
  }

Hope this helps - let us know if you meet any problems or have any questions.



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search