【发布时间】:2017-05-20 09:02:59
【问题描述】:
我正在使用nvd3 来生成折线图。我想要 y 轴的 log-scale。
为此,我使用以下代码:
const chart = nv.models.lineChart()
.x(function (d) { return d[0] })
.y(function (d) { return d[1] })
.margin({ left: 100 })
.useInteractiveGuideline(true)
.showLegend(true)
.showYAxis(true)
.showXAxis(true);
chart.xAxis.tickFormat(d3.format(',r'));
chart.yAxis.tickFormat(d3.format('.02f'));
chart.yScale(d3.scale.log());
我得到的结果如下:
有没有办法减少 y 轴的刻度数,使它们不重叠?或者有没有我可以用来合理地生成刻度的库?我想避免手动设置tickValues。
【问题讨论】:
标签: javascript d3.js data-visualization nvd3.js