I tried searching in the documentation but didn’t get anywhere with this question.
What “format standard” is the format option for RangeSlider?
yield_slider = RangeSlider(
I’m trying to get:
However, format takes ‘%’ and formats it as a percentage so I get:
What is the correct way to escape special characters like the percent symbol?
I’ve tried the obvious ones ‘%%’ and ‘%’ to no avail.
By default, ranges use the
NumeralTickFormatter, which documents all of its formats in the reference guide: formatters — Bokeh 3.2.0 Documentation
Under the covers,
numbro.js. Looking at their docs, I am not sure that any escaping is supported.
However, besides format strings, you can pass any actual tick formatter objects, e.g. a
PrintfTickFormatter might be a better choice here:
Thanks, that’s very helpful.
PrintfTickFormatter is the best solution given I have the ability to use all of the printf functionality
So I think we can close this except for one note for people looking at this thread later.
Just due to the limitations of
NumeralTickFormatter, if you want to escape a character AND use the thousands separator, I don’t think there is a supported way to print this.
For example, if you want
2560 to become
2,560 minutes you’ll either have to go with:
PrintfTickFormatter(format='%.0f minutes') = "2560 minutes"
So in this rare case, making a custom class might be necessary.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.