升级到2.7及更高版本后,ChartJS甜甜圈图大小变得混乱

时间:2019-02-20 15:39:27

标签: javascript chart.js chartjs-2.6.0

升级到ChartJS 2.7或更高版本后,我的甜甜圈图的尺寸看起来变得不均匀。

这是ChartJS 2.6中我的甜甜圈图的外观 enter image description here

这就是ChartJS 2.7或更高版本现在的样子...

enter image description here

这是此图表的脚本:

var pieOpt = {
    responsive: true,
    tooltips: {
        mode: 'index',
       	intersect: false,
       	callbacks: {
            label: function(tooltipItems, data) {	                
                return data.labels[tooltipItems.index] +': '+ formatCurrency( data.datasets[0].data[tooltipItems.index] );
            }
    	}           	
    },
    hover: {
         mode: 'nearest',
         intersect: true
    },
    legend: {
      	position:'bottom'	        	
    },
    animation: {
        animateScale: true,
        animateRotate: true
    }
};
	
var config2 = {
	type: 'doughnut',
	data: {
	    datasets: [{
	        backgroundColor: [
	            window.chartColors.green,
	            window.chartColors.red,
	            window.chartColors.yellow
	        ],
	        label: 'Dataset 1'
	    }],
	    labels: [
	        "Remaining Fund",
	        "Labor Cost",
	        "Material"
	    ]
	},
	options: pieOpt
};

我唯一改变的是升级ChartJS的版本。有谁知道为什么我会看到这个?

0 个答案:

没有答案