Skip to content

Typed array not accepted as colorbar.tickvals #2537

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

Closed
jonmmease opened this issue Apr 7, 2018 · 2 comments
Closed

Typed array not accepted as colorbar.tickvals #2537

jonmmease opened this issue Apr 7, 2018 · 2 comments

Comments

@jonmmease
Copy link
Contributor

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?

@etpinard
Copy link
Contributor

etpinard commented Apr 9, 2018

If I do the same with a typed array, the typed array seems to be ignored.

Yeah, that's on purpose. This issue is essentially a duplicate of #1894

Personally, attributes like colorbar.tickvals shouldn't be declared as "data_array" in the first place.

So to answer your question

Is the goal for all such properties in Plotly.js to accept typed arrays?

I'd vote for no.

@jonmmease
Copy link
Contributor Author

Yeah, that makes sense. I can add some special handling for tickvals and other uncorrelated data_arrays as we find them. An eventual schema change like you discuss in #1894 would be nice in the long run.

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

No branches or pull requests

2 participants