Properly display bin width in barChart using dc.js and crossfilter.js

后端 未结 2 919
自闭症患者
自闭症患者 2020-12-28 15:47

I\'m making a bar chart using the Dimensional Charting javascript library dc.js, which is based on d3 and crossfilter.

All I want to do is display a histogram with a

2条回答
  •  一向
    一向 (楼主)
    2020-12-28 16:19

    Bar charts in dc.js use the xUnits function to automatically calculate the width of the bars in a histogram based on the range of your x-axis. If you want to set the width to a static value you can use a custom xUnits function for example:

    chart.xUnits(function(){return 10;});
    

    This should give you a more fitting width.

提交回复
热议问题