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.
right now the public API is split into
xandysections, but internally they're merged to keep the loops uniform, with just a sprinkling ofif (i ==0)branching to split offx.the public API accepts
ithat 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.uPlot/src/Line.js
Line 174 in 589d1dd
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.
xis 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:
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 isy, and then we just use a flatias we do now and everything becomes logically aligned. yes, there will beaxes: [null, {}, {}]but it's easy to reason about.