Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c93dcb1

Browse files
committed
add fallback in autobin routine
- so that trying to plot a histogram with categorical sample pts on a linear axis result in blank plot instead of `ax.dtick` exception.
1 parent 2638c19 commit c93dcb1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/plots/cartesian/axes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,11 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar) {
514514
distinctData.minDiff / msexp, [0.9, 1.9, 4.9, 9.9], true);
515515
size0 = Math.max(minSize, 2 * Lib.stdev(data) /
516516
Math.pow(data.length, is2d ? 0.25 : 0.4));
517+
518+
// fallback if ax.d2c output BADNUMs
519+
// e.g. when user try to plot categorical bins
520+
// on a layout.xaxis.type: 'linear'
521+
if(!isNumeric(size0)) size0 = 0;
517522
}
518523

519524
// piggyback off autotick code to make "nice" bin sizes

0 commit comments

Comments
 (0)