
Tooltips for annotations
This discussion was imported from CodePlex
nicolasr75 wrote at 2013-04-23 16:39:
Hello all,
first of all: many thanks to the OxyPlot author(s). This is really great work !!!
My question:
in my plot I show a time series. For certain instants of time I show a vertical line annotation and additionally a rectangular annotation like a flag which contains a number. The number corresponds to an event and I would like to show additional information for the flag as a tooltip. Is it possible to show something like a tooltip when the mouse hovers over the annotation?
Thanks for any ideas.
Nicolas
first of all: many thanks to the OxyPlot author(s). This is really great work !!!
My question:
in my plot I show a time series. For certain instants of time I show a vertical line annotation and additionally a rectangular annotation like a flag which contains a number. The number corresponds to an event and I would like to show additional information for the flag as a tooltip. Is it possible to show something like a tooltip when the mouse hovers over the annotation?
Thanks for any ideas.
Nicolas
justserega wrote at 2013-04-24 06:48:
I join to both: question and thanks to OxyPlot authors! (Best chart library for .net)
I have the same problem. Chart series with rectangle (annotation) corresponding time interval, tooltip is needed to show additional information.
May be you give clue on source code how to implement this functionality (I ready send patch if it would usefull)
I have the same problem. Chart series with rectangle (annotation) corresponding time interval, tooltip is needed to show additional information.
May be you give clue on source code how to implement this functionality (I ready send patch if it would usefull)
objo wrote at 2013-04-24 11:16:
The tooltips should be easy to implement for WPF and Silverlight, but it may be more difficult on the other platforms. I have not decided whether to make solution where OxyPlot does most of the work related to the tooltips (hit testing) or if it should
rely on the different implementations.
The original idea was to use
The original idea was to use
IRenderContext.SetToolTip
to set the tooltip on all following graphics elements. It is implemented for WPF in
ShapesRenderContext.ApplyToolTip
nicolasr75 wrote at 2013-04-24 11:33:
Hello and thanks for the reply. I didn't expect that it is so easy :-) at least for WPF. I wrote my own Annotation class for other reasons anyway, so here is part of the class that shows setting the tooltip:
public class FlagAnnotation : Annotation
{
...
public override void Render(IRenderContext rc, PlotModel model)
{
...
OxyPlot.Wpf.ShapesRenderContext src = rc as OxyPlot.Wpf.ShapesRenderContext;
src.SetToolTip("This ist the tooltip");
OxyRect rect = new OxyRect();
...
rc.DrawRectangle(rect, OxyColors.LightBlue, OxyColors.Black);
...
}
}
debgz wrote at 2014-07-08 12:11:
Thanks for the Sample! I build myself a PointAnnotation with tooltips enabled out of that:
With default ShapesRenderContext tooltip text only applies to text and images.
With default ShapesRenderContext tooltip text only applies to text and images.
public class TooltipPointAnnotation : PointAnnotation {
/// <summary>
/// gets or sets the tooltip text
/// </summary>
public string Tooltip { get; set; }
public override void Render(IRenderContext rc, PlotModel model) {
/* get render context */
ShapesRenderContext src = rc as ShapesRenderContext;
/* set tooltip to render context if it exists */
if (src != null) {
src.SetToolTip(Tooltip);
}
/* draw elements the tooltip may apply to (text and images) */
base.Render(rc, model);
}
}
Given the above I get a nice point annotation with an tooltip on the annotation text.objo wrote at 2014-07-10 12:36:
I think the
I have added https://oxyplot.codeplex.com/workitem/10230
ToolTip
property should be added to the PlotElement
class and set when rendering all elements. Some refactoring should also be done - e.g. a new virtual
Render
method on the PlotElement
class!I have added https://oxyplot.codeplex.com/workitem/10230
Customer support service by UserEcho