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

Vertical legend multiline labels overlaps

Open Cellard opened this issue 2 years ago • 3 comments

Expected behavior

It is expected, that multiline label will reserve space to not overlap with next label

Current behavior

Multiline label overlaps with next one

Снимок экрана 2022-08-01 в 11 29 24

Reproducible sample

https://codepen.io/cellard/pen/vYRpVyP

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

v3.8.2

Browser name and version

No response

Link to your project

No response

Cellard avatar Aug 01 '22 08:08 Cellard

Hey, can you tell where did you see the syntax of passing array of array for the labels field?

kartik-madhak avatar Aug 02 '22 05:08 kartik-madhak

Passing array to a label to make it multiline is a well-known receipt suggested by stackoverflow community.

Are you saying this is not declared feature? I count it so natural and surprised not finding it in official documentation... The only place I found is Title Configuration (and Subtitle too), but actually it works for any labels — for dataset, for ticks, etc (see an example below).

The case with "extremely long labels" — https://codepen.io/cellard/pen/xxWYEvX — seems much harder to solve (

Cellard avatar Aug 02 '22 07:08 Cellard

It is indeed intentional behaviour. Explanation can be found in the docs here: https://www.chartjs.org/docs/master/general/data-structures.html#data-structures

In case you want multiline labels you can provide an array with each line as one entry in the array

LeeLenaleee avatar Aug 02 '22 11:08 LeeLenaleee

Is there any option to control the gap between the multiline labels? I am trying to remove gap completely between the multiline labels image

AndeYashwanth avatar Jun 26 '23 13:06 AndeYashwanth