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

scattergl can't resolve date with sub-minute precision #995

Closed
etpinard opened this issue Sep 29, 2016 · 8 comments
Closed

scattergl can't resolve date with sub-minute precision #995

etpinard opened this issue Sep 29, 2016 · 8 comments
Assignees
Labels
bug something broken
Milestone

Comments

@etpinard
Copy link
Contributor

See http://codepen.io/etpinard/pen/ORjbkR

Probably because time stamps that long can't fit on the GPU. We'll probably have to rescale to data arrays about the xy axis range.

@etpinard etpinard added the bug something broken label Sep 29, 2016
@etpinard etpinard added this to the On-par gl2d milestone Sep 29, 2016
@monfera
Copy link
Contributor

monfera commented Oct 4, 2016

@etpinard I see sub-minute precision (in this case, seconds) on both versions in the codepen example:
image

@etpinard
Copy link
Contributor Author

etpinard commented Oct 6, 2016

This is what I'm seeing

image

The top figure (which is a scattergl trace) has no drawn marker points.

@monfera
Copy link
Contributor

monfera commented Oct 6, 2016

Indeed, I initially misinterpreted it as a tick label rendering issue. In this case I'd look into #413 first, because it's useful to solve this issue in combination with making the non-fancy scattergl work with dates, and then consider rolling the date resolution approach to the fancy version.

@monfera
Copy link
Contributor

monfera commented Oct 12, 2016

@jackparmer a question for you at the end: having a PR for #413, we now have a PoC solution for this issue. The root cause was that the data path from the plotly.js through gl-vis to the GPU is of a 32 bit resolution, and

new Date('2016-10-10').valueOf() i.e. time from the epoch as an integral multiple of milliseconds is much larger than Math.pow(2, 24)

I broadened the pipeline to 64 bits up till the (32-bit) WebGL renderer, where an offset is introduced. This works well for arbitrary start dates (e.g. in 2016) as long as the span of time domain is not too long, for example, 10/29/2016 to 10/30/2016 can be represented with very fine resolution. But the current PoC can't cover e.g. 2016 ... 2026 with a fine temporal resolution, as we still have a 32 bit (actually 24 bit) representation. Examples:

  • At an exact millisecond resolution, this covers 4.66 hours (2 ** 24) / 1000 / 3600
  • At a second resolution, this covers half a year (*)
  • At a minute resolution, this covers 32 years (*)

(*) with the last two examples, there's some dithering - eg. at the second resolution, maybe we don't get an exact 10/10/2016 21:58:47 but more like 10/10/2016 21:58:47.23429 - which may not matter in practice if values are shown with precision that's limited to second (I don't think we automatically have such resolution-aware decimal rounding though).

This 32 bit resolution limit is native to WebGL. With more work, it'd be possible to pass on two 32 bit arrays and combine them in the vertex shader. It slows down the vertex shader a bit, though it's unlikely to be a bottleneck. Still, there might be unexpected complications.

I'd add that this resolution limitation isn't inherent to dates/times. It applies for plain numbers as well.

What do we know about the expected combination of the span of time domain and the expected temporal resolution, should we shoot for a software based 64 bit solution in the shader or let's get feedback first?

@monfera
Copy link
Contributor

monfera commented Oct 12, 2016

Example: millisecond resolution over one second
image

@etpinard
Copy link
Contributor Author

Slightly unrelated, but looking at the above screenshot, we should try to address gl2d date axis ticks formatting as discussed here.

@monfera
Copy link
Contributor

monfera commented Oct 15, 2016

@etpinard @jackparmer doubling the available WebGL precision has worked out, giving us a millisecond-level resolution even over years or millennia: gl-vis/gl-scatter2d#1

gl-vis/gl-scatter2d-fancy and its constituents are also covered.

@etpinard
Copy link
Contributor Author

etpinard commented Nov 4, 2016

done in #1079

@etpinard etpinard closed this as completed Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants