【问题标题】:Logarithmic bar chart using Protovis使用 Protovis 的对数条形图
【发布时间】:2010-12-16 22:24:53
【问题描述】:
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 生成条形图。如何将此图表更改为对数刻度?

【问题讨论】:

    标签: javascript data-visualization protovis


    【解决方案1】:

    你应该使用 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();

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-13
      • 2021-04-22
      • 1970-01-01
      • 2023-03-13
      • 2014-10-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多