2014-06-17 45 views
0

現在我已經有了這樣的額外端點。如何在NVD3折線圖上擴展數據刻度

enter image description here

有什麼辦法來擺脫這些目標的?目前我正在使用此設置:

nv.addGraph -> 
    chart = nv.models.lineChart() 
     .showLegend(false) 
     .width(elem.width()) 
     .margin(top: 10, left: 50, bottom: 20, right: 50) 

    chart.xAxis 
     .tickValues(_.map(data[0].values, (d) -> d.x)) 
     .tickFormat((d) -> d3.time.format('%d/%m')(new Date(d))) 
     .tickPadding(10) 

    chart.yAxis 
     .tickFormat(d3.format('+.2f')) 
     .tickPadding(10) 
     .showMaxMin(false) 

    d3.select(elem[0]) 
     .datum(data) 
     .transition().duration(0) 
     .call(chart) 

謝謝!

回答

1

嘗試展開域使用yDomain圖表選項Y軸:

chart.yDomain([-0.70, 0.50]); 
+0

完美的作品!但是我找不到任何這種'yDomain'文檔,任何參考? –

+1

其實我基於[源代碼](https://github.com/novus/nvd3/blob/master/nv.d3.js)代碼和d3.js [docs](https://github.com)/mbostock/D3 /維基/ API-參考)。但我也使用[angular-nvd3](http://krispo.github.io/angular-nvd3/)指令,它完全解析nvd3核心API。您可以在[實時編輯](http://krispo.github.io/angular-nvd3/#/lineChart)頁面上找到並定製「擴展」模式下的大多數可用選項。 – krispo

+0

@krispo所以你如何在angular-nvd3中做到這一點?我無法重新縮放y軸...謝謝 – ackuser