I was trying to create a polar barchart with the echarts4r
library and the chart is generated properly. I have x
, y
, and z
fields in the dataset. To generate the chart we need only the x
and y
fields. Now I want to show x
, y
and z
in the tooltip. x
and y
are showing well in the tooltip, however the z
value is undefined. See below an example code:
library(echarts4r)
# create example dataset
df <- data.frame(x = c("A", "B", "C"), y = c(10, 20, 30), z = c("foo", "bar", "baz"))
# create polar bar chart
df %>%
e_charts(x) %>%
e_bar(y, coord_system = "polar") %>%
e_angle_axis(startAngle = 90, max = 150, axisLine = list(show = FALSE), axisTick = list(show = FALSE),
splitLine = list(show = FALSE), axisLabel = list(show = FALSE)) %>%
e_radius_axis(type = "category", data = df$x, axisLabel = list(interval =0,margin = 50, fontSize= 15, color = 'black'),
axisLine = list(show = FALSE), axisTick = list(show = FALSE), z = 10) %>%
e_polar() %>%
e_legend(show = FALSE) %>%
e_tooltip(formatter = htmlwidgets::JS("
function(params) {
return params.name + '<br>' + params.value + '<br>' + params.data.z;
}
"))
How can I also show the z
value in the tooltip?