Thanks to visit codestin.com
Credit goes to github.com

Skip to content

should i be relative to the internal flattened array? #77

Description

@leeoniya

right now the public API is split into x and y sections, but internally they're merged to keep the loops uniform, with just a sprinkling of if (i ==0) branching to split off x.

the public API accepts i that is against the internal flattened array, but this is not terribly intuitive, especially since uPlot goes to additional lengths to make it look like the internals match the externals, e.g.

self.series = splitXY(series);

this can probably be improved.

i've considered dropping the x/y and simply making the lists flat but it results in awkwardness elsewhere. e.g. x is required, but if nothing needs to be customized for the x axis, you need to provide options that start with null: axes: [null, {values}]. also, there can be multiple x axes (let's say different units), then what?

i guess one route can be to attach an extra required property to each option item in a flat list, eg. dir: 'x', but that's not great either.

considerations:

  • data[0] is always the x-series data and there can only be a single x series
  • there could be multiple x axes (alt units)

if we simply disallow multiple x axes, then this whole situation becomes easier. we can use flat lists and simply say that data[0], series[0] and axes[0] are all x, everything else is y, and then we just use a flat i as we do now and everything becomes logically aligned. yes, there will be axes: [null, {}, {}] but it's easy to reason about.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions