Skip to content

add fallback in autobin routine #1284

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 3 commits into from
Jan 9, 2017
Merged

add fallback in autobin routine #1284

merged 3 commits into from
Jan 9, 2017

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Jan 6, 2017

so that trying to plot a histogram with categorical sample pts on a linear axis result in blank plot instead of ax.dtick exception.

For example,

Plotly.plot('graph', [{
  type: 'histogram',
  x: ['orange', 'apple']
}], {
  xaxis: {
     type: 'linear'
  }
}

currently lead to:

image

with this patch, the above snippet generates a blank graph.

- so that trying to plot a histogram with categorical sample pts
  on a linear axis result in blank plot instead
  of `ax.dtick` exception.
@etpinard etpinard added status: in progress bug something broken labels Jan 6, 2017
@etpinard
Copy link
Contributor Author

etpinard commented Jan 6, 2017

This bug was discovered while debugging for #1231 but does not resolve #1231

@alexcjohnson looks ok?

// fallback if ax.d2c output BADNUMs
// e.g. when user try to plot categorical bins
// on a layout.xaxis.type: 'linear'
if(!isNumeric(size0)) size0 = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If a bin size of 0 made it through, this could lead to infinite loops or divide-by-zero errors somewhere else. It looks like Axes.autoTicks has its own fallback for this so dummyAx.dtick won't be zero, which is why this works for now, but perhaps it would be better to use size0 = 1 instead so we don't have to depend on this behavior from autoTicks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 755c143

- for better protection from infinity loops in Axes.autoTicks
});
});

it('should not error out for categories on linear axis', function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case and the two below resulted in errors previously.

@alexcjohnson
Copy link
Collaborator

💃

@etpinard etpinard merged commit d70fc9a into master Jan 9, 2017
@etpinard etpinard deleted the histogram-nan-fallback branch January 9, 2017 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants