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

built-in label auto-skip doesn't work

Open rochadk opened this issue 10 years ago • 7 comments

As title says, the built in label auto-skip doesn't remove overlapping labels

image

http://codepen.io/anon/pen/ZBQMar?editors=1111

rochadk avatar Nov 11 '16 11:11 rochadk

Try setting autoSkip: true and autoSkipPadding on the ticks options.

http://codepen.io/anon/pen/vyZJBB

fewstera avatar Nov 24 '16 15:11 fewstera

I think the issue is here, https://github.com/chartjs/Chart.js/blob/master/src/core/core.scale.js#L526-L528

I am not sure how rotated label would be half the width ? wouldn't it be same dimensions assuming squared labels (L^2) or even longer rectangular labels (L X W).

I hope I am not missing anything from the calculation ? However, removing that may break #2584

possible solution

The following pseudo method to may do the trick since there are multi ticks in this example:

if (totalTickLabelLength > totalChartWidth) {
   skipRatio += SOME_ADJUST_VALUE
}

Jareechang avatar Feb 05 '17 00:02 Jareechang

We might have to find another way to fix #2584 to properly fix this

etimberg avatar Feb 05 '17 02:02 etimberg

ok @etimberg , it seems like for issue #2584, we just need to find a way to check if it is a long label, and apply rotations accordingly so there is no label overlap.

Shall we open an issue, and I could investigate this ?

Jareechang avatar Feb 11 '17 19:02 Jareechang

Sure, go for it :smile:

etimberg avatar Feb 12 '17 01:02 etimberg

+1 for this, unfortunately can't to write this ourselves at this time

rebsgroup avatar Mar 06 '18 15:03 rebsgroup

This one seems to be fixed since 2.6.0 (codepen)

simonbrunel avatar Dec 12 '18 16:12 simonbrunel