我使用NVD3.js來顯示多行圖表。NVD3.js yAxis和工具提示不同的精確度
我想Y軸顯示爲2位數字
編輯答案
var chart;
nv.addGraph(function() {
chart = nv.models.lineChart()
.options({
margin: { left: 140, bottom: 50 },
x: function (d, i) {
return i;
},
showXAxis: true,
showYAxis: true,
transitionDuration: 250,
tooltips: true,
tooltipContent: function (key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + e.point.y + ' at ' + x + '</p>'
}
});
// chart sub-models (ie. xAxis, yAxis, etc) when accessed directly, return themselves, not the parent chart, so need to chain separately
chart.xAxis
.axisLabel("Maturity")
.tickFormat(function(d) { return pivotedData[0].values[d].x; });
chart.yAxis
.axisLabel('Model Spread').tickFormat(d3.format(',.2f'));
d3.select('#chart1 svg')
.datum(pivotedData)
.call(chart);
//TODO: Figure out a good way to do this automatically
nv.utils.windowResize(chart.update);
chart.dispatch.on('stateChange', function (e) { nv.log('New State:', JSON.stringify(e)); });
return chart;
});
但在我想顯示12個個小數位線的工具提示。
這可能嗎?
我確實嘗試過編輯該功能,並且它對工具提示沒有任何影響 – theHaggis
您是否使用最新版本的NVD3(來自源存儲庫)?你使用哪種圖表類型? –
是的,我昨天拉它,我正在使用lineChart模型。圖表= nv.models.lineChart() – theHaggis