implot icon indicating copy to clipboard operation
implot copied to clipboard

Showing values of points in tooltips and hovering markers

Open Prinkesh opened this issue 4 years ago • 12 comments

Although a small feature. I think this gives user a better way for seeing and comparing the value instead of showing the value at a fixed position .

Here is an example for the same .

b68290c6290184728990d120b48fcfd8

We could also provide value getters for the user for these tooltips . So that they can show different values on hover .

Like if someone wants to see some stats which they don't want to plot but see the values w.r.t to x axis . They could add those in the getters .

Prinkesh avatar Jun 07 '20 19:06 Prinkesh

It's been a requested feature in the past, so I'm in support of adding something like this. Questions, things to think about:

  • It seems that you've chosen to display values as a function of mouse x location. Should we also support mouse y location?
  • Should this be set via a flag or perhaps via a function call inside of a Begin/EndPlot and before any plot items (similar to what I suggested here https://github.com/epezent/implot/issues/53#issuecomment-640225645
  • can this be implemented by the user instead of us if we provide appropriate API utility functions? (e.g. I think this could be done with IsPlotHovered, GetPlotMousePos, and custom rendering). If that's the case, would we be better off showing this as an example in the demo instead of adding it to the API?

epezent avatar Jun 07 '20 19:06 epezent

  • It seems that you've chosen to display values as a function of mouse x location. Should we also support mouse y location?

Since X is shared we could be with these kind of markers for X .

08853b6abc4019866c444c2cb9b671bc

Prinkesh avatar Jun 07 '20 21:06 Prinkesh

A set of 2 of these can be a perfect solution to replace "QueryX" (https://github.com/epezent/implot/issues/53#issuecomment-640225645)

ozlb avatar Jun 08 '20 03:06 ozlb

  • It seems that you've chosen to display values as a function of mouse x location. Should we also support mouse y location?

Since X is shared we could be with these kind of markers for X .

08853b6abc4019866c444c2cb9b671bc

@Prinkesh Is the code available in one of your fork branches?

ozlb avatar Jun 09 '20 04:06 ozlb

Hi @ozlb .

Its available on feature/tooltips-and-hover

Prinkesh avatar Jun 20 '20 21:06 Prinkesh

I have added few things like showing percentage change of Y values on selection .

dff5ca0f0c9b0bc25e2beb64400fef2a

Should this be set via a flag or perhaps via a function call inside of a Begin/EndPlot and before any plot items (similar to what I suggested here #53 (comment)

We should use flags to turn on/off the tooltips or to choose between percentage change values or absolute value while in selection or query mode

can this be implemented by the user instead of us if we provide appropriate API utility functions? (e.g. I think this could be done with IsPlotHovered, GetPlotMousePos, and custom rendering). If that's the case, would we be better off showing this as an example in the demo instead of adding it to the API?

Can also be implemented by user but this kind of features are generally required . So would be a better option to add the in core itself and let the user turn it on/off by flags .

Prinkesh avatar Jun 21 '20 07:06 Prinkesh

In https://github.com/epezent/implot/issues/53#issuecomment-640221232 you can see what i so called QueryX; @epezent did reject the PR because with not so much changes can be implemented as custom code externally: can your "values of points" be realized with standard imPlot API as well?

ozlb avatar Jun 21 '20 15:06 ozlb

Yes. The plot mouse position get be retrieved with GetPlotMousePos, and then the closest point in the plot data can be searched for by the user. We might consider adding helper functions that do this.

epezent avatar Jun 21 '20 16:06 epezent

In #53 (comment) you can see what i so called QueryX; @epezent did reject the PR because with not so much changes can be implemented as custom code externally: can your "values of points" be realized with standard imPlot API as well?

Yes it can be done with standard api as well .

// GetPlotMousePos()  then 
AddRectangleFilled(...)
AddText(...) // If in selection mode change the label as required 
MarkerCircle(...)

Right now i choose the value of y as nearest point from user input data closest to mouse location . But if we extend it to approx value on the line segment it would be too much code repetition on user end .

Also let's say user data is static and loaded when the program starts or is changed only when range of the plot changes . Now to show the markers / tooltips they would have to in-occur an extra cost of iterating through the data to find the nearest point to current location . But this can be done in the LineRenderer part of code itself . So saving the extra cost on user end .

On other note how about exposing a callback registration functionality?

// void callback(StateArgs...) { 
// Implement Custom Rendering based on current State
// }

BeginPlot()
   RegisterToolTip(callback);   
  // Either user can implement this callback or we can provide utils of pre-implemented ones which they can register
   // If registered we can call this registered function in the LineRenderer Loop
   PlotLine(..) ;
   

Prinkesh avatar Jun 21 '20 16:06 Prinkesh

Iterate buffer one more time it's inefficient and not necessarily if there will be API functions to push x points and after plot get relative y (getter index/pointer). External rendering of makers/cursors/queryX, whatever name you want, should be possible, what about interactivity with it? I mean, if you are operating on it like drag&drop move, you need an API as well to notify it and also another to give info that there are no other operations I guess.

ozlb avatar Jun 21 '20 18:06 ozlb

Hi @ozlb .

Its available on feature/tooltips-and-hover

@Prinkesh FYI, it's impossible to compile with gcc in linux and I can't open issue in your fork.

ozlb avatar Jul 01 '20 04:07 ozlb

Hi @ozlb . Its available on feature/tooltips-and-hover

@Prinkesh FYI, it's impossible to compile with gcc in linux and I can't open issue in your fork.

Can you try now .

Prinkesh avatar Jul 01 '20 04:07 Prinkesh