javascript - 使用 Protovis 的对数条形图

标签 javascript data-visualization protovis

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/

相关文章:

javascript - 带填充的行高

javascript - 无需滚动即可在所有平台上将所有元素放入视口(viewport)中

python - 如何创建分类进度条

javascript - 使用 dc.js 创建一个简单的饼图

javascript - 如何将类似 JSON 的字符串转换为 Javascript 对象?

Python可视化优化参数

javascript - IE8 TypeError 对象不支持方法的此属性

javascript - 为什么 Firefox 不将所有鼠标滚轮事件传递到我的 javascript 应用程序?

javascript - 如何将 Protovis 图表附加到特定的 HTML 标签?

javascript - 在函数式 javascript 中翻译此代码(在 map 中聚合 2 个数组)