Skip to content

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

Closed
@danieljblinick

Description

@danieljblinick

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions