tickformatter_func {rbokeh} | R Documentation |
Display tick values that are formatted by a user-defined function.
tickformatter_func(code = "", args = NULL, clear = FALSE)
code |
A snippet of JavaScript code that reformats a single tick to the desired format. The variable "tick" will contain the unformatted tick value and can be expected to be present in the code snippet namespace at render time. |
args |
A mapping of names to Bokeh plot objects. These objects are made available to the formatter code snippet as the values of named parameters to the callback. |
clear |
A logical indicating whether all non-specified parameters should be cleared out of any exising specification in the figure. This can be useful when modifying a previously-defined figure. |
A specification that is used as the tickformatter
argument for x_axis
or y_axis
.
figure() %>% ly_points(1:26, letters) %>% x_axis( ticker = ticker_num(desired_num_ticks = 20), tickformatter = tickformatter_func(code = "return tick + 'm';")) figure(width = 1000) %>% ly_lines(date, co2, data = co2_df) %>% x_axis(tickformatter = tickformatter_func(" var cur = new Date(); var diff = (cur.getTime() - tick) / (1000 * 60 * 60 * 24 * 365); return diff.toFixed(2) + ' years ago'"))