JetBrains / lets-plot

Multiplatform plotting library based on the Grammar of Graphics
https://lets-plot.org
MIT License
1.57k stars 51 forks source link

Add an option to configure axis tooltips when user-defined breaks are provided #1178

Open IKupriyanov-HORIS opened 2 months ago

IKupriyanov-HORIS commented 2 months ago

Consider two plots:

from lets_plot import *
LetsPlot.setup_html()

gggrid([
    ggplot(
        {
            'x': [0, 1, 2, 3, 4, 5, 6],
            'y': [0, 0, 0, 0, 0, 0, 0]
        }, 
        aes('x', 'y')
    ) \
        + geom_point() \
        + scale_x_continuous(breaks={'min': 0, '2': 2, '4': 4, 'max': 6}),
    ggplot(
        {
            'x': [0, 1, 2, 3, 4],
            'y': [10, 29, 17, 42, 1]
        }, 
        aes('x', 'y')
    ) \
        + geom_point() \
        + scale_x_continuous(breaks={'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4})
])

In the first plot, when the pointer hovers over min/max points, it might be acceptable to display either "min" or 0. Therefore, an option to toggle between these two display modes is necessary. If the point doesn't have a corresponding break, the domain value should be displayed.

In the second plot, when the pointer hovers over any point, the tooltip should display the break value instead of the domain value. An option to configure this behavior will be helpful in this case.