d3-simple-slider icon indicating copy to clipboard operation
d3-simple-slider copied to clipboard

Labels can overlap

Open johnwalley opened this issue 7 years ago • 2 comments

screen shot 2018-07-02 at 11 58 39

johnwalley avatar Jul 02 '18 10:07 johnwalley

Possible solutions include providing a cut-down array of tickValues and rotating the labels after the fact, e.g. https://bl.ocks.org/mbostock/4403522

However, this module is named d3 simple slider so we should consider solutions which put less burden on the user. For example, provide an interface to let the user simply specify a rotation angle. Even better, but much larger in scope, would be to detect the size of the labels and adjust the tick values accordingly.

johnwalley avatar Jul 02 '18 12:07 johnwalley

You can use element.getComputedTextLength() to calculate the text width of the label, but the question is then what? One could: • truncate the text and add an ellipsis, and keep knocking off characters until it fits in the designated width (slider width / # of ticks), but the label may be unusable (e.g. a bunch of "20..." in your example) • figure out the widest label text, and skip every nth label to make sure they all fit... but if there wind up not being enough tick labels to infer what the other ticks represent, then that's a bad solution too.

rusackas avatar Nov 07 '18 20:11 rusackas