gpt4 book ai didi

javascript - 使用 Protovis 的对数条形图

转载 作者:行者123 更新时间:2023-11-30 06:06:41 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com