所以我终于能够设置yAxis tickValues了,但是现在当我使用yRange()来反转它时,记号消失了,有没有更好的方法呢?还是我忘了添加另一个设置??
我还设置了xAxis tickValues,我需要它们均匀分布,就像按顺序排列一样。但是我知道你不应该使用nvd3图表来改变刻度类型。
相关代码如下:
var xLabels = ["", 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 6000, 8000, 10000];
var yLabels = [-10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120];
var chart = nv.models.lineChart()
.x(function (d) {
return d.Hz;
})
.y(function (d) {
return d.dB;
})
.showLegend(false)
.showYAxis(true)
.showXAxis(true);
chart.forceY(yLabels);
chart.forceX(xLabels);
chart.yRange([0, 450]); //This inverts the yAxis
chart.xAxis
.axisLabel('Frequency (Hz)')
.tickValues(xLabels)
.orient('top'); //reposition xaxis labels on top
chart.yAxis
.axisLabel('dB')
.tickValues(yLabels);发布于 2016-02-20 04:27:45
如果上面的代码是addGraph()函数的一部分,那么可以尝试在返回chart对象之前添加nv.utils.windowResize(chart.update);。
https://stackoverflow.com/questions/35513977
复制相似问题