我需要在我的累积Nvd3图表中添加多个y轴,有人知道我需要修改库代码的哪一部分吗?
如果您自己已经完成此操作并可以提供Jsfiddle,则更好。
任何建议都将不胜感激。
我需要在我的累积Nvd3图表中添加多个y轴,有人知道我需要修改库代码的哪一部分吗?
如果您自己已经完成此操作并可以提供Jsfiddle,则更好。
任何建议都将不胜感激。
$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);
}
},
yAxis1: {
tickFormat: function(d){
return d3.format(',.1f')(d);
}
},
yAxis2: {
tickFormat: function(d){
return d3.format(',.1f')(d);
}
}
}
};
定义您的数据:
$scope.data = [{key: 'series1', type: "line", yAxis: 1, values:[{x: 10, y: 20}, {x: 20, y: 35}, {x: 30, y:18}]},
{key: 'series2', type: "line", yAxis: 1,values:[{x: 10, y: 12}, {x: 20, y: 26}, {x: 30, y: 15}]},
{key: 'series3', type: "line", yAxis: 2,values:[{x: 10, y: 0.75}, {x: 20, y: 0.9}, {x: 30, y: 0.8}]},
{key: 'series4', type: "line", yAxis: 2,values:[{x: 10, y: 0.2}, {x: 20, y: 0.3}, {x: 30, y: 0.4}]}]
type
和 yAxis
键。<div>
设置为普通模式: <nvd3 options="options" data="data"></nvd3>
就是这样!
您将获得与累积线图相同的图表,但能够设置多个轴。
chart.y1Axis
.tickFormat(d3.format(',f'));
chart.y2Axis
.tickFormat(function(d) { return '$' + d3.format(',f')(d) });