d3 bar chart is upside down

前端 未结 3 1210
甜味超标
甜味超标 2021-01-02 03:11

I have a simple bar chart drawn in d3, with vertical bars: http://jsfiddle.net/philgyford/LjxaV/2/

However, it\'s drawing the bars down, with the baseline at the top

3条回答
  •  一向
    一向 (楼主)
    2021-01-02 03:42

    Setting the y attribute seems to work:

    .attr('y', function(d){ return (height - parseInt(y(d.percent))); })
    

    jsfiddle here

提交回复
热议问题