var vis = new pv.Panel().canvas('grphLangSpeakers').height(langCount*(barWidth+barGap)).width(canvasWidth)
.add(pv.Bar)
.data(popCountArray)
.bottom(0).width(function(d){ return d})
.height(barWidth)
.top(function() {return this.index * (barGap+barWidth)});
vis.render();
我使用上面的代码通过 Protovis 生成条形图。如何将此图表更改为对数刻度?
最佳答案
你应该使用 pv.Scale.log 作为你的函数:
http://vis.stanford.edu/protovis/jsdoc/symbols/pv.Scale.log.html
var yScale = pv.Scale.log(0,popCountArray.length).range(0,height);
....
.top(function() yScale (this.index));
vis.render();
希望对你有帮助
关于javascript - 使用 Protovis 的对数条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4012036/