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

Feature: allow typed arrays to be used for the data.transforms.groups value #4397

Closed
danieljblinick opened this issue Dec 2, 2019 · 3 comments
Labels
feature something new

Comments

@danieljblinick
Copy link
Contributor

I have a very high cardinality data set that I am trying to store only in typed arrays. Plotly already accepts typed arrays for the data.x and data.y values, which is great. However, I want to color the points based on the groups they belong to, and I would like to store those groups in a typed array as well. So instead of:

{
      type: 'scattergl',
      mode: 'markers',
      transforms: [{
        type: 'groupby',
        groups: [1, 2, 3]
      }]
}

it would be

{
      type: 'scattergl',
      mode: 'markers',
      transforms: [{
        type: 'groupby',
        groups: new Uint8Array([1, 2, 3])
      }]
}

I looked at the code, and it seems to be as easy as changing the line 175 in groupby.js from:
if(!(Array.isArray(groups)) || groups.length === 0) {
to something like:
if(!(Array.isArray(groups) || groups.constructor === Uint8Array) || groups.length === 0) {

would this be doable? Thanks!

@etpinard
Copy link
Contributor

etpinard commented Dec 2, 2019

Yes that would be doable. Thanks for pointing this out.

I would personally vote for accepting all typed arrays using Lib.isArrayOrTypedArray for consistency with the other array-typed-array logic in this library.

@danieljblinick would you be interested in making a PR for us?

@etpinard etpinard added the feature something new label Dec 2, 2019
@danieljblinick
Copy link
Contributor Author

@etpinard okay great! yeah ill give it a shot, thanks 👍

@etpinard
Copy link
Contributor

This one got done in #4410

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

No branches or pull requests

2 participants