Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Dashed Legend label as per dashed dataset border

Open Joy-300799 opened this issue 2 years ago • 2 comments

Feature Proposal

I am trying to render the legend label as dashed w.r.t the dashed border line, as says in screenshot (Enterprise Rate Goal & Site Rate Goal). How can we achieve this? I don't see a straightforward way to do this. Any help would be appreciated! Screenshot 2023-03-10 at 7 07 05 PM

Possible Implementation

No response

Joy-300799 avatar Apr 17 '23 06:04 Joy-300799

You can write a custom generatelabels function. In here for the pointstyle you can pass a canvas element. For the first item you can draw a green rect, for the other two you can draw a custom dotted line yourself

https://www.chartjs.org/docs/master/configuration/legend.html#legend-label-configuration

LeeLenaleee avatar Apr 19 '23 20:04 LeeLenaleee

@Joy-300799 I have a working example, please check line 58 of javascript file https://codepen.io/luaneaquino/pen/wvLWmWV

aquino-luane avatar Aug 06 '24 09:08 aquino-luane