Parcourir la source

demo htmlwidgets::JS() with tooltipOptions

master
Garrick Aden-Buie il y a 6 ans
Parent
révision
8d442e3c84
3 fichiers modifiés avec 31 ajouts et 6 suppressions
  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 Voir le fichier

* 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 Voir le fichier

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
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


Chargement…
Annuler
Enregistrer