1
如何使用nvd3將我的域設置爲[0,400]?這裏是我的代碼:NVD3多欄水平圖x軸域
var chart;
nv.addGraph(function() {
chart = nv.models.multiBarHorizontalChart().x(function(d) {
return d.label
}).y(function(d) {
return d.value
}).margin({
top : 30,
right : 20,
bottom : 50,
left : 175
}).barColor(d3.scale.category20().range()).transitionDuration(250).stacked(true)
chart.yAxis.tickFormat(d3.format(',.2f'));
d3.select('#chart1 svg').datum(long_short_data).call(chart);
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function(e) {
nv.log('New State:', JSON.stringify(e));
});
return chart;
});
謝謝,我一直在嘗試'xDomain',但我沒有設置足夠大的規模。然後我發現,X軸是垂直軸,而不是水平軸。我需要修改水平的一個。 – Pio
@Pio檢查用'chart.forceX([0,400])更新的答案;'是否有效 – shabeer90