I came up with this JSFiddle : https://www.jsfiddle.net/gcb1dyou which has rounded chartJs bar corners.Problem is when legend clicked to filter data,corners disappear like below

When I clicked orange label as you can see rounded border disappeared on the yellow bar.
var lastVisible = 0;
for (var findLast = 0, findLastTo = this._chart.data.datasets.length; findLast < findLastTo; findLast++) {
if (!this._chart.getDatasetMeta(findLast).hidden) {
lastVisible = findLast;
if (this._chart.data.datasets[findLastTo - 1].data[this._index] == 0) {
lastVisible -= 1;
}
}
} Here I tried to add another if to make lastVisible findLast-1 when data is hidden(legend clicked) and previous index is null but didn't work
else{
if(this._chart.data.datasets[findLastTo - 1].data[this._index] == 0){
lastVisible=findLastTo-2;
}
}
How can I solve this?Expecting to see your answers.