Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF IntensityGraph, display cell value on mouse event

Solved!
Go to solution

Is there a way to display value of a cell in a "tooltip-like" popup when you click/hover anywhere on IntensityGraph?

Thank you

0 Kudos
Message 1 of 3
(4,642 Views)
Solution
Accepted by topic author kirko7

Using the technique from WPF graph display point value on hover, here is a version specific to intensity data:

 

    private static readonly GraphQueryArgs query = new GraphQueryArgs(
        PlotsToSearch.Any, SearchDimensions.HorizontalAndVertical,
        SearchDirections.ForwardAndReverse, isInclusive: true );

    public MainWindow( ) {
        InitializeComponent( );

        graph.PlotAreaMouseMove += this.OnPlotAreaMouseMove;
        graph.PlotAreaMouseLeave += delegate { graph.ToolTip = null; };
        ToolTipService.SetInitialShowDelay( graph, 0 );
        ToolTipService.SetShowDuration( graph, int.MaxValue );
    }

    private void OnPlotAreaMouseMove( object sender, MouseEventArgs e ) {
        IPlot plot = graph.AllPlots[0];
        Point screenPosition = graph.GetPlotAreaPosition( e );
        Point relativePosition = graph.ScreenToRelative( screenPosition );

        PlotValue nearestValue = graph.FindNearestValue( plot, relativePosition, query );
        if( nearestValue != null )
            graph.ToolTip = string.Format(
                "Nearest intensity value is {2} at ({0},{1}).",
                nearestValue.Value.Cast<object>( ).ToArray( ) );
    }

~ Paul H
0 Kudos
Message 2 of 3
(4,612 Views)

Much appreciated!

0 Kudos
Message 3 of 3
(4,599 Views)