Nevron Forum
Back
Login
Register
Login
Register
Home
»
Nevron Vision for NET
»
Nevron Chart for .NET
»
HeatMapChart - How to show a label when Mouse hovers over Chart
HeatMapChart - How to show a label when Mouse hovers over Chart
Post Reply
HeatMapChart - How to show a label when Mouse hovers over Chart
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
Goto Topics Forum
Author
Message
joern kunze
joern kunze
posted 9 Years Ago
ANSWER
Topic Details
Group: Forum Members
Posts: 86,
Visits: 221
Hi Experts,
I have a HeatMapChart like the following:
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
Tags
HeatMap
Label
NHeatMapSeries
Reply
Like
0
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Threaded View
Threaded View
HeatMapChart - How to show a label when Mouse hovers over Chart
joern kunze
-
9 Years Ago
Hi Joern, The heat map series does notsupport expose anchor...
Nevron Support
-
9 Years Ago
... thanks for the hint - now I got it working:...
joern kunze
-
9 Years Ago
Post Reply
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search