我正在使用chartsJS库(2.4)来创建圆环图。如果我使用普通电脑,它的工作完美。但是如果尝试使用移动设备访问它,则图表根本不会呈现。我究竟做错了什么?代码在
之下<script>
var data = {
labels: [
"Team 1",
"Team 2",
],
datasets: [
{
data: [<?=$team1_pct?>, <?=$team2_pct?>],
backgroundColor: [
"#14c9ea",
"#0f1e2d",
],
hoverBackgroundColor: [
"#14c9ea",
"#0f1e2d",
]
}]
};
var canvas=document.getElementById("myChart");
var ctx=canvas.getContext("2d");
var myDoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: data,
options:{ responsive: true,
title: {
display: true,
text: 'Head to Head',
},
cutoutPercentage: 60,
animation: {
onComplete: function (animation) {
var canvas = document.getElementById("myChart");
var ctx = canvas.getContext("2d");
ctx.font = "36px verdana";
ctx.fillText("VS", 110, 142);
}
}
},
});
</script>
谢谢。