Feature: allow typed arrays to be used for the data.transforms.groups value #4397
Copy link
Copy link
Closed
Labels
featuresomething newsomething new
Description
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!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featuresomething newsomething new
Activity
etpinard commentedon Dec 2, 2019
Yes that would be doable. Thanks for pointing this out.
I would personally vote for accepting all typed arrays using
Lib.isArrayOrTypedArrayfor consistency with the other array-typed-array logic in this library.@danieljblinick would you be interested in making a PR for us?
danieljblinick commentedon Dec 3, 2019
@etpinard okay great! yeah ill give it a shot, thanks 👍
etpinard commentedon Dec 16, 2019
This one got done in #4410