HeatMapChart - How to show a label when Mouse hovers over Chart


Author
Message
joern kunze
joern kunze
Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)
Group: Forum Members
Posts: 86, Visits: 221
... thanks for the hint - now I got it working:

   m_RectangularCallout.Anchor = new NScalePointAnchor(nChartControl1.Charts[0],
                    (int)StandardAxis.PrimaryX,
                    (int)StandardAxis.PrimaryY,
                    (int)StandardAxis.Depth,
                    AxisValueAnchorMode.Clip, new NVector3DD(1, 2, 0));

Best regards,
Joern
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 Joern,

The heat map series does not support expose anchor coordinates for the callout - you may need to use a different type of anchor - for example axs scale point anchor - check out the Panels \ Annotations \ General example on how to create such an anchor. Let us know if you meet any problems or have any questions.



Best Regards,
Nevron Support Team


joern kunze
joern kunze
Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)
Group: Forum Members
Posts: 86, Visits: 221
Hi Experts,

I have a HeatMapChart like the following:
https://www.nevron.com/forum/uploads/images/5be95721-1d09-4f17-bbee-979e.jpg

now I want to show a label with the X and Y  and the according values when the Mouse hovers over the chart. Is there an easy way to do so?

I tried it with an NRectangularCallout together with a new Controller:

[Serializable]
  public class MyDataLabelTool : NTool {
  
   #region Constructor
   public MyDataLabelTool() {
   }
   #endregion

   #region Overrides

   public override void OnMouseMove(object sender, Nevron.Chart.Windows.NMouseEventArgs e) {
    NControlView view = (NControlView)this.GetView();
    NHitTestCacheService hitTestService = GetView().GetServiceOfType(typeof(NHitTestCacheService)) as NHitTestCacheService;
    if (hitTestService == null)  return;

    NHitTestResult result = new NHitTestResult(hitTestService.HitTest(new NPointF(e.X, e.Y)) as NChartNode);
    INMouseService mouseService = (INMouseService)GetView().GetServiceOfType(typeof(INMouseService));
    if (result.ChartElement == ChartElement.DataPoint) {
      mouseService.Cursor = Cursors.SizeAll;
      int fX = result.HeatMapDataPointX;
      int fY = result.HeatMapDataPointY;

      int iIndex = result.DataPointIndex;
      double fValue = ((NHeatMapSeries)(result.Chart.Series[0])).Data.Values[iIndex];
      Console.WriteLine("Index: " + iIndex.ToString() + " X:" + fX.ToString() + " Y:" + fY.ToString() + " Value: " + fValue.ToString("N2"));
// up to here it is working => on the output window the correct values are displayed


      NRectangularCallout m_RectangularCallout = (NRectangularCallout)result.Chart.Series[0].Tag;
      NDataPointAnchor anchor = new NDataPointAnchor(result.Chart.Series[0], iIndex, ContentAlignment.MiddleCenter, StringAlignment.Center);
      m_RectangularCallout.Anchor = anchor;      // anchor still has no series at this point (series==null)
      m_RectangularCallout.Text = " X:" + fX.ToString() + " Y:" + fY.ToString() + " Value: " + fValue.ToString("N2");
      m_RectangularCallout.Visible = true;

// no error here - but also no Label
    }
    else {
      mouseService.Cursor = mouseService.DefaultCursor;
    }

   }
   #endregion



The Controller itself seems to get the correct values when the mouse is moved - but the anchor point seems to be wrong. After doing:
NDataPointAnchor anchor = new NDataPointAnchor(result.Chart.Series[0], iIndex, ContentAlignment.MiddleCenter, StringAlignment.Center);

the anchor.Series is still null - and no Label is shown.

Thanks for helping,
Best regards,
Joern


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