最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ChartJS: chart not show all data - Stack Overflow

programmeradmin4浏览0评论

For some reason, this chart not show the last two data from the array.

var data = {
    labels: ["Brasil", "Argentina", "Chile", "Paraguai", "Peru", "Bolívia", "México"],
    datasets: [{
        data: [ 9.19, 7.77, 6.80, 6.23, 6.00, 4.00, 4.00 ],
        backgroundColor: backgroundColor
    }],
};

Anyone known why is this happens?

For some reason, this chart not show the last two data from the array.

var data = {
    labels: ["Brasil", "Argentina", "Chile", "Paraguai", "Peru", "Bolívia", "México"],
    datasets: [{
        data: [ 9.19, 7.77, 6.80, 6.23, 6.00, 4.00, 4.00 ],
        backgroundColor: backgroundColor
    }],
};

http://codepen.io/marcelo2605/pen/PWWqJm?editors=0010

Anyone known why is this happens?

Share Improve this question asked Jan 18, 2017 at 14:03 marcelo2605marcelo2605 2,7945 gold badges31 silver badges58 bronze badges 1
  • It does not show it because the y axis starts at 4 which right from the bottom. You can see it, if you set: xAxes: [{ display: true }] – Legends Commented Jan 18, 2017 at 14:05
Add a ment  | 

2 Answers 2

Reset to default 6

you need to set Y-Axis to start with 0, by default it start with the minimum value present in the data set which is 4 in your case. Due to this last 2 columns with value 4 are not visible.

 yAxes: [{
            ticks: {
                beginAtZero: true
            }
        }]

updated Pen : http://codepen.io/anon/pen/LxxVBp?editors=0010

The y-scale on your graph has a minimum of 4. The value of your last 2 points is 4, so they are not shown. Set the min to 0, or at least less than 4 and they will show.

发布评论

评论列表(0)

  1. 暂无评论