JetBrains / lets-plot

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

The tooltip format with `{}` in the pattern ignores the default formatting #484

Open OLarionova-HORIS opened 2 years ago

OLarionova-HORIS commented 2 years ago

When using the '{}' construction in the format pattern, a string representation of the value is substituted into the result. It would be better to use the default formatted value.

For example, we want to change the content of the axis tooltip by adding a symbol to the value:

N = 21
x = [v for v in range(N)]
y0 = [pow(10, v / 10.) for v in range(N)]
y1 = [v * 5 for v in range(N)]
formula = ['10^(x/10)'] * N + ['5*x'] * N
data = dict(x=x * 2, y=y0 + y1, formula=formula)

ggplot(data) + geom_point(aes('x', 'y', color='formula', size='formula')) + scale_size_manual(values=[7, 3]) + scale_y_log10()
Screenshot 2021-11-26 at 14 42 30
alshan commented 2 years ago

Internal use: https://forum.datalore-plot.jetbrains-boston.com/t/tooltips-config/114/79