【发布时间】:2016-01-25 09:49:41
【问题描述】:
我想创建一个包含点和线的图表,如下图所示。
我尝试了多图表类型:'line' + 'barchart',它似乎工作。 但是当我指定 'scatter' + 'line' 时,不会显示任何散点数据。
Angular nvd3 可以做到这一点吗?
非常感谢您的帮助。
这是我的 plunker 代码:
var app = angular.module('plunker', ['nvd3']);
app.controller('MainCtrl', function($scope) {
$scope.options = {
chart: {
type: 'multiChart',
height: 450,
margin : {
top: 30,
right: 60,
bottom: 50,
left: 70
},
color: d3.scale.category10().range(),
//useInteractiveGuideline: true,
transitionDuration: 500,
xAxis: {
tickFormat: function(d){
return d3.format(',f')(d);
}
},
yAxis: {
tickFormat: function(d){
return d3.format('.02f')(d);
}
}
}
};
$scope.data = [
{
key: 'X',
type: 'scatter',
values: [
{ x: 1, y: 125, size: Math.random(), shape: 'circle' },
{ x: 2, y: 125, size: Math.random(), shape: 'circle' },
{ x: 3, y: 140, size: Math.random(), shape: 'circle' }
],
yAxis: 1
},
{
key: 'Y',
type: 'bar',
values: [
{x:1, y:109, label:'C2.1'},
{x:2, y:102, label:'C2.2'},
{x:3, y:105, label:'C2.3'}
],
yAxis: 1
},
{
key: 'Z',
type: 'line',
values: [
{ x: 1, y: 115 },
{ x: 2, y: 120 },
{ x: 3, y: 130 }
],
yAxis: 1
}
];
});
【问题讨论】:
标签: charts line scatter angular-nvd3