Skip to content

Improved auto skipper #4612

@benmccann

Description

@benmccann

There's a ticks.autoSkip feature (docs), which plots only a subset of ticks and labels to avoid overlapping labels.

We should make the following improvements to the auto skipper:

  • Make it aware of major ticks. It should first attempt to include all major ticks. It should then attempt to include minor ticks in between. This should fix Time scale only aligns single point #4600
    • This is easier if we allow buildTicks to return ticks outside the min/max range. Then we can remove ticks outside the min/max range after calling buildTicks. This is very similar to how the time scale's generate returns ticks outside the min/max range and buildTicks removes ticks outside the range. But if we move the auto-pruning logic to happen in the auto-skipper instead of buildTicks then it'd make sense to move the min/max enforcement as well
    • Attempt to split major ticks into sub-divisions that make sense similar to time scale's interval. Can have different division for integer and time scales. These divisions could possibly be auto-generated by doing a prime factorization and then finding all ways to divide factors into two groups. E.g. the prime factorization of 24 is 2*2*2*3. You could choose the following subsets of factors: 2, 3, 2*2, 3*2, 2*2*2, 3*2*2, 3*2*2*2. A manual divisions table might look something like like:
    // key is number of minor units between major units
    // value is number of minor units to include between major units
    divisions: {
      "1000": [1000, 500, 200, 100, 50, 25, 20, 10, 5, 4, 2],
      "60": [60, 30, 12, 6, 4, 3, 2],
      "24": [24, 12, 8, 6, 4, 3, 2],
    }
  • Use the auto skipper in the time scale
    • Remove autoSkip: false from the time scale (source)
    • source: 'auto' should generate a tick at every minor unit. generate should not attempt to do anything smart
    • generate should not generate more than 1 tick per pixel

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions