ChartJS:图表未显示所有数据 [英] ChartJS: chart not show all data

查看:68
本文介绍了ChartJS:图表未显示所有数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,此图表未显示数组中的最后两个数据.

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?

推荐答案

您需要将Y轴设置为以0开头,默认情况下,它以数据集中存在的最小值(在您的情况下为4)开始.因此,最后2列的值为4的列不可见.

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
            }
        }]

更新的笔: http://codepen.io/anon/pen/LxxVBp?编辑者= 0010

这篇关于ChartJS:图表未显示所有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆