| * it works! | * it works! | ||||
| * Try adding other options | * Try adding other options | ||||
| ### Writing JavaScript in R | |||||
| The [tooltips](https://frappe.io/charts/docs/basic/annotations#tooltips) | |||||
| can be formatted using the `tooltipOptions` property: | |||||
| ``` | |||||
| tooltipOptions: { | |||||
| formatTooltipX: d => (d + '').toUpperCase(), | |||||
| formatTooltipY: d => d + ' pts', | |||||
| } | |||||
| ``` | |||||
| To write this in R (add to `widget_demo.R`) | |||||
| ```r | |||||
| tooltipOptions = list( | |||||
| formatTooltipX = htmlwidgets::JS("d => 'Year: ' + d"), | |||||
| formatTooltipY = htmlwidgets::JS("d => d + ' babies'") | |||||
| ) | |||||
| ``` |
| lineOptions = list(regionFill = TRUE), | lineOptions = list(regionFill = TRUE), | ||||
| axisOptions = list(xIsSeries = TRUE), | axisOptions = list(xIsSeries = TRUE), | ||||
| colors = c("#466683", "#44bc96"), | colors = c("#466683", "#44bc96"), | ||||
| width = "100%" | |||||
| width = "100%", | |||||
| tooltipOptions = list( | |||||
| formatTooltipX = htmlwidgets::JS("d => 'Year: ' + d"), | |||||
| formatTooltipY = htmlwidgets::JS("d => d + ' babies'") | |||||
| ) | |||||
| ) | ) | ||||
| ``` | ``` |