Hi,
I'm trying to display some kind of tooltip for series: when the user hovers a series -> display the name of the series (close to mouse cursor would be nice) .
Some context:
- I use multiple(up to 12000) FreeformPointLineSeries, each of them have 50 points (X: 1..50)
- I tried to accomplish this by using SeriesEventMarker but because there are so few points there are cases where the distance between the mouse cursor and the marker's label is quite big
Is there a way to set such a tooltip without relying on SeriesEventMarker?
Thanks in advance!
Tooltip for series
Moderator: Queue Moderators
-
- Posts: 141
- Joined: Wed Mar 27, 2019 1:05 pm
Re: Tooltip for series
Hi,
Yes, this is possible without SeriesEventMarkers. One way to do this is to use an annotation and MouseOverOn and MouseOverOff - events. You can use these events to check if the mouse cursor is over a series and set annotation visibility true or false accordingly. Here is an example.
Setting the series and the annotations:
There is no need to set more than one annotation even if there are thousands of series. You can just update the location and the text of the one annotation.
The events can be as follows:
Hope this is helpful.
Yes, this is possible without SeriesEventMarkers. One way to do this is to use an annotation and MouseOverOn and MouseOverOff - events. You can use these events to check if the mouse cursor is over a series and set annotation visibility true or false accordingly. Here is an example.
Setting the series and the annotations:
Code: Select all
FreeformPointLineSeries fpls = new FreeformPointLineSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]);
fpls.Title.Text = "Series Name";
fpls.MouseOverOn += Fpls_MouseOverOn;
fpls.MouseOverOff += Fpls_MouseOverOff;
_chart.ViewXY.FreeformPointLineSeries.Add(fpls);
AnnotationXY ann = new AnnotationXY(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]);
ann.Visible = false;
ann.Style = AnnotationStyle.Rectangle;
ann.LocationCoordinateSystem = CoordinateSystem.ScreenCoordinates;
ann.MouseInteraction = false;
_chart.ViewXY.Annotations.Add(ann);
The events can be as follows:
Code: Select all
private void Fpls_MouseOverOff(object sender, MouseEventArgs e)
{
_chart.ViewXY.Annotations[0].Visible = false;
}
private void Fpls_MouseOverOn(object sender, MouseEventArgs e)
{
FreeformPointLineSeries fp = sender as FreeformPointLineSeries;
_chart.ViewXY.Annotations[0].LocationScreenCoords.SetValues((float)e.GetPosition(_chart).X + 50, (float)e.GetPosition(_chart).Y - 40); // e.GetPosition gets the mouse position inside several mouse events.
_chart.ViewXY.Annotations[0].Text = fp.Title.Text;
_chart.ViewXY.Annotations[0].Visible = true;
}
Re: Tooltip for series
That was exactly what I was looking for.
Thanks a lot!
Thanks a lot!