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

Histogram Redraw: replace numeric array with string array breaks redraw function #710

Closed
scottwittenburg opened this issue Jun 30, 2016 · 2 comments

Comments

@scottwittenburg
Copy link

I'm using plotly.js 1.12.0, and in my browser console I type:

container = document.querySelector('.plotly-container')
Plotly.newPlot(container, [{type: 'histogram', x: [1,3,1,1,2,3,1]}])

this works as expected. Now, according to the documentation I can completely replace the data and then redraw, so I do:

container.data = [{type: 'histogram', x:['one', 'two', 'one', 'one']}]
Plotly.redraw(container)

Which does not update the plot, but generates the following console error:

Error: ax.dtick error: NaN

For me, this is happening on Ubuntu 14.04 in both Chrome (51) and Firefox (47).

Perhaps it is expected that if you replace the numeric data values with strings, then redraw will not work?

Thank you for maintaining an open source project!

@etpinard
Copy link
Contributor

etpinard commented Jun 30, 2016

Here's the solution: http://codepen.io/etpinard/pen/Vjbpbz

In brief, plotly.js mutates a few parts of the user data during a .plot call in order to skip a few auto-type routines in subsequent plot / restyle / relayout calls.

For example, layout.xaxis.type if not set by the user during the first .plot call gets filled to its auto-type value. Therefore subsequent .plot call won't have to dive into the data arrays to try to figure out what axis type the user is trying to plot.

This user data mutation paradigm is confusing, not ideal or even flat-out wrong, but it will stay us until at least v2.0.0. So I will close this issue. Our apologies.

@scottwittenburg
Copy link
Author

No worries, thanks for the workaround!

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