Description Usage Arguments Value Examples
Format numbers in htmlwidgets with d3.format.
1 2 3 | use_d3_format(widget)
d3_formatter(specifier, prefix = "", suffix = "", locale = "en-US")
|
widget |
An object of type |
specifier |
Format for numbers, currency, percentage, e.g. |
prefix |
Character string to append before formatted value. |
suffix |
Character string to append after formatted value. |
locale |
Localization to use, for example |
The same htmlwidget
with an extra dependency.
a JS
function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | library(d3.format)
dat <- data.frame(
x = c("format", "numeric", "values", "with ease"),
y = c(1233172L, 1467863L, 1953877L, 1382088L)
)
# With highcharter
library(highcharter)
hchart(dat, mapping = hcaes(x, y), type = "column") %>%
use_d3_format() %>%
hc_yAxis(labels = list(
formatter = d3_formatter(",.3~s", suffix = " unit")
))
# with apexcharter
library(apexcharter)
apex(dat, aes(x, y), "column") %>%
use_d3_format() %>%
ax_yaxis(labels = list(
formatter = d3_formatter(",.3~s", suffix = " unit")
))
# With billboarder
library(billboarder)
billboarder(data = dat) %>%
bb_aes(x = x, y = y) %>%
bb_barchart() %>%
use_d3_format() %>%
bb_y_axis(
tick = list(
format = d3_formatter(",.3~s", suffix = " unit")
)
)
# with echarts4r
library(echarts4r)
dat %>%
e_charts(x) %>%
use_d3_format() %>%
e_bar(y, name = "Serie 1") %>%
e_y_axis(
formatter = d3_formatter(",.3~s", suffix = " unit"),
offset = -10
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.