我正在使用ChartJs创建一个stacked group bar chart。在此图表中,我假设显示3个数据。但是,它仅显示2。我在下面提供了我的脚本。谁能看看它,看看可能出什么问题了?
这是我用来跟踪的chartjs github repo。
$(function () {
new Chart(document.getElementById("stacked_group_bar_chart").getContext("2d"), getChartJs('stackedgroup'))
new Chart(document.getElementById("line_chart").getContext("2d"), getChartJs('line'));
});
function getChartJs(type) {
var config = null;
if (type === 'line') {
config = {
type: 'line',
data: {
labels: ["January", "February", "March", "April", "May"],
datasets: [{
label: "Refund",
data: [65, 59, 80, 45, 56],
borderColor: 'rgba(0, 188, 212, 0.75)',
backgroundColor: 'rgba(0, 188, 212, 0.3)',
pointBorderColor: 'rgba(0, 188, 212, 0)',
pointBackgroundColor: 'rgba(0, 188, 212, 0.9)',
pointBorderWidth: 1
}
]
},
options: {
responsive: true,
legend: false
}
}
}
else if (type === 'stackedgroup') {
config = {
type: 'bar',
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
label: "My First dataset",
data: [65, 59, 80, 81, 56, 55, 40],
backgroundColor: 'rgba(0, 188, 212, 0.8)',
stack: 'Stack 0'
}, {
label: "My Second dataset",
data: [28, 48, 40, 19, 86, 27, 90],
backgroundColor: 'rgba(233, 30, 99, 0.8)',
stack: 'Stack 0'
}, {
label: "My Third dataset",
data: [28, 48, 40, 19, 86, 27, 90],
backgroundColor: 'rgba(233, 30, 99, 0.8)',
stack: 'Stack 1'
}]
},
options: {
responsive: true,
legend: false,
tooltips: {
mode: 'index',
intersect: false
},
scales: {
xAxes: [{ stacked: true }],
yAxes: [{ stacked: true }]
}
}
}
}
return config;
}