浏览代码

demo htmlwidgets::JS() with tooltipOptions

master
父节点
当前提交
8d442e3c84
共有 3 个文件被更改,包括 31 次插入 和 6 次删除
  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 查看文件

@@ -435,4 +435,23 @@ The final step is to move the Javascript we wrote before into the js binding.
* it works!
* 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 查看文件

@@ -25,6 +25,10 @@ frappeCharts::frappeChart(
lineOptions = list(regionFill = TRUE),
axisOptions = list(xIsSeries = TRUE),
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
文件差异内容过多而无法显示
查看文件


正在加载...
取消
保存