1👍
Instead of changing the barFill.chart.canvas.width. change barFill.scale.width.
function updateChart(barData) {
angular.forEach(oldData, function () {
barFill.removeData();
});
oldData = barData;
angular.forEach(barData, function (newBar, i) {
barFill.addData([newBar], labels[i]);
});
barFill.scale.width = getWidth(barData);
barFill.resize().update();
}
It works even without the call to update()
by the way, but I just kept it because it is the right way as per the documentation.
I would recommend resizing the container instead of the canvas element btw.
Fiddle – http://jsfiddle.net/ja8cxybf/
- Chartjs-Object.values not seperated by parentheses / Chartjs only displays first element of array
- Chartjs-Chart.js how to display max value?
Source:stackexchange.com