chartjs / chartjs-plugin-annotation

Annotation plugin for Chart.js
MIT License
603 stars 325 forks source link

Enable line annotation label as label sub-element #727

Closed stockiNail closed 2 years ago

stockiNail commented 2 years ago

This PR moves label node of line annotation to sub element.

stockiNail commented 2 years ago

Not sure why this.rotation and this.options.rotation need both to be used (and the fallback with || might not work in all cases as expected, specifically when this.rotration is 0)

I thought a little bit more and you're right! This is wrong only when the calculated rotation is 0 and the label options of a line is set to 'auto'.

Maybe the best could be to set element.rotation for all annotations which have got a label, and then use it instead of the options.

stockiNail commented 2 years ago

Not sure why this.rotation and this.options.rotation need both to be used (and the fallback with || might not work in all cases as expected, specifically when this.rotration is 0)

@kurkle I have changed using only element.rotation at runtime of the label.