Browse Source

demo htmlwidgets::JS() with tooltipOptions

master
Garrick Aden-Buie 6 years ago
parent
commit
8d442e3c84
3 changed files with 31 additions and 6 deletions
  1. +19
    -0
      dev/dev.Rmd
  2. +5
    -1
      dev/widget_demo.Rmd
  3. +7
    -5
      dev/widget_demo.html

+ 19
- 0
dev/dev.Rmd View File

* 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'")
)
```

+ 5
- 1
dev/widget_demo.Rmd View File

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'")
)
) )
``` ```

+ 7
- 5
dev/widget_demo.html
File diff suppressed because it is too large
View File


Loading…
Cancel
Save