Skip to content

Add a nice error message when people animate before plotting #1088

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

Merged
merged 1 commit into from
Oct 27, 2016

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Oct 26, 2016

This change expands on the current bad div message:

This element is not a Plotly plot: [object HTMLDivElement].

with more info:

This element is not a Plotly plot: [object HTMLDivElement]. It's likely that you've failed to create a plot before animating it. For more details, see https://plot.ly/javascript/animations/

Which people who are used to other libraries will probably run into very quickly. See: http://stackoverflow.com/questions/39415791/using-plotly-js-animation-feature/39457872#39457872

For anyone else's reference it appears that you can't initialize animate on an empty plot and have it animate with the function. It's only intended to change data that already exists

@@ -2156,7 +2156,11 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
gd = helpers.getGraphDiv(gd);

if(!Lib.isPlotDiv(gd)) {
throw new Error('This element is not a Plotly plot: ' + gd);
throw new Error(
'This element is not a Plotly plot: ' + gd + '. It\'s likely that you\'ve failed ' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really start putting all these error messages in a some src/constants/ file.

But, for now, this is great !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think it'd be nice in general to beef up the error messages, particularly when the input looks fishy—like passing an object where an an array is expected and instead of failing it just doesn't get any props from it.

@etpinard etpinard added this to the v1.19.0 milestone Oct 26, 2016
@etpinard
Copy link
Contributor

💃

@rreusser rreusser merged commit 35bbb86 into master Oct 27, 2016
@rreusser rreusser deleted the animation-nice-message branch October 27, 2016 14:57
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

Successfully merging this pull request may close these issues.

2 participants