我正在使用nvd3的piechart.js组件在我的网站上生成一个饼图.提供的.js文件包含几个var,如下所示:
var margin = {top: 30, right: 20, bottom: 20, left: 20}
, width = null
, height = null
, showLegend = true
, color = nv.utils.defaultColor()
, tooltips = true
, tooltip = function(key, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + '</p>'
}
, noData = "No Data Available."
, dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
;
Run Code Online (Sandbox Code Playgroud)
在我的内联js中,我已经能够覆盖其中一些变量,比如这样(覆盖showLegend和margin):
var chart = nv.models.pieChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value }) …
Run Code Online (Sandbox Code Playgroud)