I'm trying to create a stacked bar chart with chartjs. I have time series with discrepencies in time, this means some series can have value for a time but others don't. For this reason I chose to include directly the x values in the dataset and not as a label array, but the chart does not render correctly.
Here is my code:
var config = {
type:'bar',
data:{
datasets:datasets
},
options: {
responsive: true,
title:{
display:true,
text:"MyChart"
},
tooltips: {
mode: 'index'
},
hover: {
mode: 'index'
},
legend: {
position: 'bottom'
},
elements: { point: { radius: 0 }},
scales: {
xAxes: [{
stacked: true,
type: 'time',
time: {
unit: 'minutes',
unitStepSize: 5,
displayFormats:{
minutes:'HH:mm'
}
},
scaleLabel: {
display: true,
labelString: 'Date'
}
}],
yAxes: [{
stacked:true,
scaleLabel: {
display: true,
labelString: 'Resources Consumed'
}
}]
}
}
};
var ctx = document.getElementById('session-sql-activity').getContext("2d");
ctx.canvas.height = 300;
ctx.canvas.width = 800;
new Chart(ctx,config);
I think the issue is with the x axis stacking.
Here is a JSFiddle illustrating the problem.