implot
implot copied to clipboard
Showing values of points in tooltips and hovering markers
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 .
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 .
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?
- 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 .
A set of 2 of these can be a perfect solution to replace "QueryX" (https://github.com/epezent/implot/issues/53#issuecomment-640225645)
- 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 .
@Prinkesh Is the code available in one of your fork branches?
I have added few things like showing percentage change of Y values on selection .
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 .
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?
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.
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(..) ;
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.
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.
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 .