出于某种原因,我很难找到一种方法来设置 y 轴的起点。我希望 y 轴从 0 开始。现在它从 15 开始
这是我的代码:
<script>
nv.addGraph(function() {
var chart = nv.models.lineWithFocusChart();
chart.xAxis
.tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) });
chart.x2Axis
.tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) });
chart.yAxis
.tickFormat(d3.format(',f'));
chart.y2Axis
.tickFormat(d3.format(',f'));
d3.select('#chart svg')
.datum(
[
{
key : 'Current' ,
color : '#2ca02c',
values : [
{ x:01112014 , y:15 },
...
]
},
{
key : 'Backlog' ,
color : '#ff7f0e',
values : [
{ x:01112014 , y:50 },
...
]
}
]
)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
</script>
最佳答案
尝试使用forceY
:
chart.lines.forceY([ 0 ]); // main chart
chart.lines2.forceY([ 0 ]); // view finder chart
关于javascript - NVD3.js Y轴最小值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21061012/