@@ -64,8 +64,10 @@ module.exports = function calc(gd, trace) {
6464 z = [ ] ;
6565 var onecol = [ ] ,
6666 zerocol = [ ] ,
67- xbins = ( typeof ( trace . xbins . size ) === 'string' ) ? [ ] : trace . xbins ,
68- ybins = ( typeof ( trace . xbins . size ) === 'string' ) ? [ ] : trace . ybins ,
67+ nonuniformBinsX = ( typeof ( trace . xbins . size ) === 'string' ) ,
68+ nonuniformBinsY = ( typeof ( trace . ybins . size ) === 'string' ) ,
69+ xbins = nonuniformBinsX ? [ ] : trace . xbins ,
70+ ybins = nonuniformBinsY ? [ ] : trace . ybins ,
6971 total = 0 ,
7072 n ,
7173 m ,
@@ -103,10 +105,10 @@ module.exports = function calc(gd, trace) {
103105
104106 for ( i = binStart ; i < binEnd ; i = Axes . tickIncrement ( i , binspec . size ) ) {
105107 onecol . push ( sizeinit ) ;
106- if ( Array . isArray ( xbins ) ) xbins . push ( i ) ;
108+ if ( nonuniformBinsX ) xbins . push ( i ) ;
107109 if ( doavg ) zerocol . push ( 0 ) ;
108110 }
109- if ( Array . isArray ( xbins ) ) xbins . push ( i ) ;
111+ if ( nonuniformBinsX ) xbins . push ( i ) ;
110112
111113 var nx = onecol . length ;
112114 x0 = trace . xbins . start ;
@@ -121,10 +123,10 @@ module.exports = function calc(gd, trace) {
121123
122124 for ( i = binStart ; i < binEnd ; i = Axes . tickIncrement ( i , binspec . size ) ) {
123125 z . push ( onecol . concat ( ) ) ;
124- if ( Array . isArray ( ybins ) ) ybins . push ( i ) ;
126+ if ( nonuniformBinsY ) ybins . push ( i ) ;
125127 if ( doavg ) counts . push ( zerocol . concat ( ) ) ;
126128 }
127- if ( Array . isArray ( ybins ) ) ybins . push ( i ) ;
129+ if ( nonuniformBinsY ) ybins . push ( i ) ;
128130
129131 var ny = z . length ;
130132 y0 = trace . ybins . start ;
@@ -134,15 +136,32 @@ module.exports = function calc(gd, trace) {
134136
135137 if ( densitynorm ) {
136138 xinc = onecol . map ( function ( v , i ) {
137- if ( Array . isArray ( xbins ) ) return 1 / ( xbins [ i + 1 ] - xbins [ i ] ) ;
139+ if ( nonuniformBinsX ) return 1 / ( xbins [ i + 1 ] - xbins [ i ] ) ;
138140 return 1 / dx ;
139141 } ) ;
140142 yinc = z . map ( function ( v , i ) {
141- if ( Array . isArray ( ybins ) ) return 1 / ( ybins [ i + 1 ] - ybins [ i ] ) ;
143+ if ( nonuniformBinsY ) return 1 / ( ybins [ i + 1 ] - ybins [ i ] ) ;
142144 return 1 / dy ;
143145 } ) ;
144146 }
145147
148+ // for date axes we need bin bounds to be calcdata. For nonuniform bins
149+ // we already have this, but uniform with start/end/size they're still strings.
150+ if ( ! nonuniformBinsX && xa . type === 'date' ) {
151+ xbins = {
152+ start : xa . r2c ( xbins . start ) ,
153+ end : xa . r2c ( xbins . end ) ,
154+ size : xbins . size
155+ } ;
156+ }
157+ if ( ! nonuniformBinsY && ya . type === 'date' ) {
158+ ybins = {
159+ start : ya . r2c ( ybins . start ) ,
160+ end : ya . r2c ( ybins . end ) ,
161+ size : ybins . size
162+ } ;
163+ }
164+
146165
147166 // put data into bins
148167 for ( i = 0 ; i < serieslen ; i ++ ) {
0 commit comments