我是javascript的新手,我想尝试使用javascript,特别是d3.js来可视化数据。我找到了我想在nvd3.js (http://nvd3.org/examples/linePlusBar.html)中构建的示例图--这是行和条形图在一个地方的结合,我尝试将它修改为相同的(http://www.highcharts.com/demo/combo-multi-axes),但我仍然不能这样做。
我的问题是,如何使用nvd3.js在“线加条形图”中添加更多行?
谢谢:)
发布于 2014-06-25 07:53:33
当您使用nvd3.js绘制线加条形图时,在传递到图表的JSON中请确保添加了属性"bar" : true,以在条形图中表示该特定数据,其余数据将加载为线图。
传递到图表中的示例JSON如下所示:
[{
"key" : "Bar Chart",
"bar" : true,
"color" : "#ccf",
"values" : [[1136005200000, 1271000.0], [1138683600000, 1271000.0], [1141102800000, 1271000.0], [1143781200000, 0], [1146369600000, 0]]
}, {
"key" : "Line Chart1",
"color" : "#c2f",
"values" : [[1136005200000, 71.89], [1138683600000, 75.51], [1141102800000, 68.49], [1143781200000, 62.72], [1146369600000, 70.39]]
}, {
"key" : "Line Chart2",
"color" : "#cff",
"values" : [[1136005200000, 89], [1138683600000, 51], [1141102800000, 49], [1143781200000, 72], [1146369600000, 39]]
}]
更新
通过查看您的小提琴这里,我在控制台中找到了以下内容
- Refused to execute script from 'https://raw.githubusercontent.com/novus/nvd3/master/lib/d3.v3.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
- Refused to execute script from 'https://raw.githubusercontent.com/novus/nvd3/master/nv.d3.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
- Refused to execute script from 'https://raw.githubusercontent.com/novus/nvd3/master/src/models/linePlusBarChart.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled. 基本上,它在加载d3.js和nvd3.js时遇到了困难,我用指向js文件的新链接更新了小提琴在这里,它似乎工作得很好。
希望它能帮上忙
https://stackoverflow.com/questions/24398961
复制相似问题