chartjs / chartjs-plugin-annotation

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

Enable box annotation label as label sub-element #725

Closed stockiNail closed 2 years ago

stockiNail commented 2 years ago

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

This PR enables the box label animation.

stockiNail commented 2 years ago

@kurkle the following options are missing in the label of box annotation because the goal was to use the box rendering options. But it makes sense to add the following missing options:

  backgroundColor
  backgroundShadowColor
  borderCapStyle
  borderDash
  borderDashOffset
  borderJoinStyle
  borderRadius
  borderShadowColor
  borderWidth
  shadowBlur
  shadowOffsetX
  shadowOffsetY

In my opinion this deserves a specific PR, with doc and new test cases.

About callout, I don't see any use case. The callout is thought to outline a point linking it to a label. I would like do not enable it in box annotation. What do you think?

kurkle commented 2 years ago

@kurkle the following options are missing in the label of box annotation because the goal was to use the box rendering options. But it makes sense to add the following missing options:

  backgroundColor
  backgroundShadowColor
  borderCapStyle
  borderDash
  borderDashOffset
  borderJoinStyle
  borderRadius
  borderShadowColor
  borderWidth
  shadowBlur
  shadowOffsetX
  shadowOffsetY

In my opinion this deserves a specific PR, with doc and new test cases.

About callout, I don't see any use case. The callout is thought to outline a point linking it to a label. I would like do not enable it in box annotation. What do you think?

I don't see a use case for the callout either, but you never know what people come up with. I think it the options should fall back to box options, but be overridable for the label. This would probably be easier if #630 was finished.

stockiNail commented 2 years ago

I think it the options should fall back to box options, but be overridable for the label. This would probably be easier if #630 was finished.

I agree for this reason I haven't started yet. All those options could be defined as commons.

stockiNail commented 2 years ago

get label() { return this.elements && this.elements[0]; }

Yes, a fast path. breaking change anyway!

stockiNail commented 2 years ago

get label() { return this.elements && this.elements[0]; }

Yes, a fast path. breaking change anyway!

done

stockiNail commented 2 years ago

@kurkle thanks for approval. What about CC issues?