question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

should `i` be relative to the internal flattened array?

See original GitHub issue

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.

https://github.com/leeoniya/uPlot/blob/589d1dd2a17d7fdc33aef176b837678131b460c2/src/Line.js#L174

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
thinhdev97commented, Jul 29, 2020

a sample demo of what?

multiple x-axes like image. I want to render a time-series chart with 2 lines. But they have different x.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jagged array and flatten array, which performs better?
In a jagged array, there's no guarantee that each sub-array is allocated nearby in memory, and would limit the benefits of cache locality....
Read more >
Array.prototype.flat() - JavaScript - MDN Web Docs
The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.
Read more >
How to flatten arrays, especially for plotting - Awkward Array
Encountering an Awkward Array, they may try to call np.asarray on it, which only works if the array can be made rectilinear or...
Read more >
How to Use the flat() and flatMap() Methods to Flatten Arrays ...
You use the flat() method for concatenating sub-arrays recursively into a single array. The flat() method takes a depth value as its parameter ......
Read more >
How to Flatten a Nested Javascript Array | by Cynthia Okoliezeh
Array.flat() works in all modern browsers, but not IE. To support all browsers, you can use Babel to transpile your code to a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found