Skip to content

[EuiRange] option to change/remove 20 tick limit #6807

Closed

Description

@bartvanheukelom

As per the documentation for EuiRange:

Maximum of 20 ticks allowed
Spacing can get quite cramped with lots of ticks so we max out the number to 20.

While this is a fine limit in general, hardcoding it seems unnecessarily limiting. I'm working on a project with very wide range sliders (think full screen width) with very narrow ticks (labels are 1 character each), and it could easily fit many many more than 20 ticks that way.
Additionally, a hardcoded limit of 20 doesn't really help when the sliders is very short.

As such, I'd like to request an option to override this limit.

Activity

  1. cee-chen commented on May 25, 2023

    @cee-chen
    Contributor

    Linking to the relevant portion in our code:

    // Error out if there are too many ticks to render
    if (sequence.length > 20) {
    throw new Error(
    `The number of ticks to render is too high (${sequence.length}), reduce the interval.`
    );
    }

    Agreed that it seems pretty heavy-handed of us to simply throw/refuse to render the component instead of warning. Even if we were to throw, it should probably be more intelligently and we should detect whether or not ticks are actually cramped/overflowing first.

    Just curious @bartvanheukelom, would you be interested in all in contributing to EUI to make your requested change? The easiest solution would probably be to change the throw to a simple console.warn instead.

  2. added
    low hanging fruit
    on May 30, 2023
  3. cee-chen commented on Jun 6, 2023

    @cee-chen
    Contributor

    #6829 updates this hard-coded limit to instead semi-intelligently use the width of the track to figure out how much space each tick has. If each tick has a width of less than 5px (which is ludicrously small and means something has gone very wrong), the component will throw/error.

    If the available width per tick is less than 20px, we'll emit a console.warn instead just to let you know you may want to consider using a breakpoint utility hook to responsively customize your tickInterval.

    I left those minimum widths in as static/hard-coded as I figured they were fairly safe buffers, but please feel free to leave another comment if you feel strongly they should be customizable as well.

  4. self-assigned this
    on Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

good first issuelow hanging fruit

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions