canvas-gauges icon indicating copy to clipboard operation
canvas-gauges copied to clipboard

Avoid tick labels overlapping

Open andreapicaro opened this issue 4 years ago • 3 comments

Hello, when setting major ticks dynamically it may happen that labels overlaps. Is there any option or strategy to avoid this overlapping? Thanks

andreapicaro avatar Jun 09 '21 06:06 andreapicaro

I've also ran into this issue, did you find a solution?

jasekiw avatar Jul 29 '22 15:07 jasekiw

您的邮件我已收到,谢谢!

TuShen121 avatar Jul 29 '22 15:07 TuShen121

@andreapicaro

I was able to fix the labels overlapping by using the events that the library emits. I had to copy over a several methods from the library to modify the drawRadialNumbers method. Note I only implemented as much as I needed for my use case which was labels at the top of the gauge. (this does not handle labels overlapping vertically). I wouldn't consider this code a candidate for a PR since there are definitely additional cases to handle.

You can see the code here:

https://gist.github.com/jasekiw/d7fbe6d8637404355301901a1eee6e8d

example usage:

const gauge = new RadialGauge(gaugeOptions);
applyRadialNumbersOverride(gauge); // from the window object after linking in the script
gauge.draw();

jasekiw avatar Jul 29 '22 19:07 jasekiw