1 回答
TA贡献1785条经验 获得超4个赞
这是工作代码。
var optionsTwo = {
type: 'bar',
data: {
//labels: ["Label1", "Label2"],
labels: ["the labels"],
datasets: [{
data: [45000],
label: "Label 1",
backgroundColor: "#3e95cd",
}, {
data: [40000],
label: "Label 2",
backgroundColor: "#8e5ea2",
}, ]
},
options: {
legend: {
display: true,
position: "bottom",
labels: {
fontColor: 'rgb(0, 0, 0)'
}
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
}
var ctxOne = document.getElementById('bar-chart').getContext('2d');
new Chart(ctxOne, optionsTwo);
<link href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script>
<div class="chart-second" style=" height: 80vh; margin: 0 auto;">
<div class="chart-wrapper">
<canvas id="bar-chart" width="400" height="400" aria-label="Chart" role="img"></canvas>
</div>
</div>
添加回答
举报