Chart.js: evenly distribute ticks when using maxTicksLimit

前端 未结 2 418
清酒与你
清酒与你 2020-12-08 22:07

I made a line chart using Chart.js version 2.1.3.

        var canvas = $(\'#gold_chart\').get(0);
        var ctx = canvas.getContext(\'2d\');
        var f         


        
2条回答
  •  半阙折子戏
    2020-12-08 22:44

    A simpler solution until this is permanently fixed by the Chart JS contributors is to include a decimal in maxTicksLimit.

    For example:

    maxTicksLimit: 8,
    

    produces a huge gap at the end.

    maxTicksLimit: 8.1,
    

    Does not produce a huge gap at the end.

    Depending on what you want to set your maxTicksLimit to, you need to play around with different decimals to see which one produces the best result.

提交回复
热议问题