Skip to content

Typed array not accepted as colorbar.tickvals #2537

Closed
@jonmmease

Description

@jonmmease

If I set the colorbar.tickvals property to an array of numbers, ticks are placed at the locations specified by the array. If I do the same with a typed array, the typed array seems to be ignored.

codepen: https://codepen.io/anon/pen/VXVyQr

Plotly.d3.json('https://raw.githubusercontent.com/plotly/datasets/master/custom_heatmap_colorscale.json', function(figure) {
var data = [{
    z: figure.z,
    colorscale: 'Blackbody',
    type: 'heatmap',
    colorbar: {
      tickvals: [25, 50, 75]  // Works fine
      // tickvals: new Float32Array([25, 50, 75]) // Gets ignored
    }
  }
];
var layout = {title: 'Blackbody'};
Plotly.newPlot('myDiv', data, layout);
});

I know this isn't a situation where there would be a performance gain from using a typed array, but I came across this during the plotly.py ipywidget effort (plotly/plotly.py#942) where numpy arrays are converted into typed arrays before being passed to the Plotly.js library (for all properties with valType of "data_array" and properties with arrayOk of true). Is the goal for all such properties in Plotly.js to accept typed arrays?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions