且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

nvd3 scatterPlot 与 R 中的 rCharts:点的大小不同?

更新时间:2023-01-24 23:29:35

可以使用 chart 方法,该方法允许您指定 sizecolor 等.现在的实现有点笨拙,需要您传递一个 javascript 函数,该函数返回指定大小的列.#!... !# 语法需要告诉 rCharts 将内容视为 JS 文字,而不是在组装有效负载时将其转换为字符串.该图表可以在此处

It is possible using the chart method, which allows you to specify size, color etc. The implementation is a little clunky right now, and requires you to pass a javascript function that returns the column specifying the size. The #! ... !# syntax is required to tell rCharts to treat the contents as a JS literal, and not convert it to a string while assembling the payload. The chart can be viewed here

library(rCharts)
p2 <- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterChart')
p2$xAxis(axisLabel = 'Weight')
p2$chart(size = '#! function(d){return d.gear} !#')
p2