Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new "justify" scale type #928

Open
leeoniya opened this issue Feb 26, 2024 · 0 comments
Open

add new "justify" scale type #928

leeoniya opened this issue Feb 26, 2024 · 0 comments
Labels
feature New feature or request

Comments

@leeoniya
Copy link
Owner

there are several viz types that can benefit from a built-in scale that is ordinal with respect to the number of datapoints and/or number of visible series.

grouped bars demo does its own scale math internally to distribute the bars correctly. it does a 2-level distribution -- first groups are spread based on number of datapoints and then then bars within those groups are spread based on number of series. this is done along x axis: https://leeoniya.github.io/uPlot/demos/multi-bars.html

state timeline and status history distribute lanes along y axis based on number of series. the y "values" represent the color, so it's pretty weird: https://leeoniya.github.io/uPlot/demos/timeline-discrete.html

it's time to internalize at least the scale math properly. dealing with these bits externally is a huge headache.

  • the scale settings need to account for both spacing and sizing along series and/or values counts. it will follow the css justify-content distributed alignment:
    /* Distributed alignment */
    justify-content: space-between; /* Distribute items evenly
                                     The first item is flush with the start,
                                     the last is flush with the end */
    justify-content: space-around; /* Distribute items evenly
                                     Start and end gaps are half the size of the space
                                     between each item */
    justify-content: space-evenly; /* Distribute items evenly
                                     Start, in-between, and end gaps have equal sizes */
  • this scale type will likely not be zoom-able. the scale.range function will be force-set to an appropriate calc function which allows integer index positions to land at the correct pixels. there will need to be a new api for these scales that accepts series index, value index, and whether to return left, center, or right positions of an item.
  • series visibility toggle will need to internally re-distribute these scales and be able to skip the disabled series in the apis while maintaining index associativity.
  • do something sensible for the axes tick labels

this is a significant undertaking that will likely touch 70% of the codebase. with many unknowns still...

@leeoniya leeoniya added the feature New feature or request label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant