[Chartjs]-Bar dashed chart is overlapping in chartjs

1👍

The issue should be in the height calculation because the plugin was thought for no-stacked bar.:

var height = chart.chartArea.bottom - top + (borderWidth / 2) - 1;

As you can see, the height is calculated assuming to go to the bottom of chart area.
You can try the following, overriding the above row:

const valueTop = element._yScale.getValueForPixel(top);
const value = chart.data.datasets[element._datasetIndex].data[element._index];
const bottom = element._yScale.getPixelForValue(valueTop - value);
var height = bottom - top + (borderWidth / 2) - 1;

Leave a comment