Skip to content

scattergl lazy init #1444

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

Merged
merged 7 commits into from
Mar 14, 2017
Merged

scattergl lazy init #1444

merged 7 commits into from
Mar 14, 2017

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Mar 3, 2017

Instead of initialising 1 gl-line2d, 2 gl-error2d, 1 gl-scatter2d and 1 gl-scatter2d-(fancy|sdf) object per scattergl why not intialize only the part(s) we need?

On a 5-trace graph of 10,000 pts each, that amounts to a ~300ms-faster plot call 🐎

image

etpinard added 3 commits March 3, 2017 16:09
- instead, create them on update when needed
- this should speed up scattergl plotting
  especially when multiple traces are present
- TODO: we'll need to reorder the trace object when adding a
  a 'mode' or an error bar to make sure e.g. lines are always
  drawn below scatter pts.
- at end of .update step
- to preserve order on updates
// - errorX
// - errorY
// - markers
this.scene.glplot.objects.sort(function(a, b) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part isn't quite right. We'll have to consider trace order too, fix coming on Monday.

The same technique might be extended to 3D to fix #1267

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 81d3bf6

obj._index = objIndex;
}
obj.update(options);
return obj;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the return obj statements for? Seems like it's meant for method chaining, but then wouldn't it be return _this? This way seems dangerous to me since obj can be (and very often is) null.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or no, I guess not _this, but the object you create and return below

Copy link
Contributor Author

@etpinard etpinard Mar 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha good eyes. I should've 🔪ed before pushing. We don't need to support method chaining here (why we anyone clear and/or update and/or dispose in the same statement?)

🔪 🔪 🔪

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 34ea31e

@alexcjohnson
Copy link
Collaborator

💃 nice 🐎 !

@etpinard etpinard merged commit 25057d6 into master Mar 14, 2017
@etpinard etpinard deleted the scattergl-lazy-init branch March 14, 2017 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants