chartjs / chartjs-plugin-annotation

Annotation plugin for Chart.js
MIT License
607 stars 328 forks source link

Annotations don't split to specific scale on stacked chart #665

Closed chedvacohen closed 2 years ago

chedvacohen commented 2 years ago

Hi, I use chartjs-plugin-annotation to draw box annotations on stacked chart. According to the documentation I added the property yScaleID to each box annotation in accordance with the related scale id. I expected that the annotations position will be only on the specific scale, but the reality is that the annotations ״smeared״ on all scales from top to bottom. The creation of the annotation is done as follows:

 const annotation = {
      type: 'box',
      xMin:"2022-01-26T02:00:00",
      xMax:"2022-01-26T16:30:00",
      yMin:undefined,
      yMax:undefined,
      backgroundColor:"#FFF2B2",
      drawTime: 'beforeDraw',
      borderWidth: 0,
      yScaleID:'y'
}

Note that I set the properties yMin and yMax to undefined in order the box will be painted on the entire height of the  scale. Result: image

Expected result: image