@@ -2314,7 +2314,23 @@ class graphly extends EventEmitter {
2314
2314
calculateExtent ( selection ) {
2315
2315
let currExt , resExt ;
2316
2316
for ( var i = selection . length - 1 ; i >= 0 ; i -- ) {
2317
- currExt = d3 . extent ( this . data [ selection [ i ] ] ) ;
2317
+ // Check if null value has been defined
2318
+ if ( this . dataSettings [ selection [ i ] ] . hasOwnProperty ( 'nullValue' ) ) {
2319
+ let nV = this . dataSettings [ selection [ i ] ] . nullValue ;
2320
+ // If parameter has nullvalue defined ignore it
2321
+ // when calculating extent
2322
+ currExt = d3 . extent (
2323
+ this . data [ selection [ i ] ] , ( v ) => {
2324
+ if ( v !== nV ) {
2325
+ return v ;
2326
+ } else {
2327
+ return null ;
2328
+ }
2329
+ }
2330
+ ) ;
2331
+ } else {
2332
+ currExt = d3 . extent ( this . data [ selection [ i ] ] ) ;
2333
+ }
2318
2334
if ( resExt ) {
2319
2335
if ( currExt [ 0 ] < resExt [ 0 ] ) {
2320
2336
resExt [ 0 ] = currExt [ 0 ] ;
@@ -2329,10 +2345,19 @@ class graphly extends EventEmitter {
2329
2345
if ( selection . length === 0 ) {
2330
2346
return [ 0 , 1 ] ;
2331
2347
}
2348
+ if ( isNaN ( resExt [ 0 ] ) ) {
2349
+ resExt [ 0 ] = 0 ;
2350
+ }
2351
+ if ( isNaN ( resExt [ 1 ] ) ) {
2352
+ resExt [ 1 ] = resExt [ 0 ] + 1 ;
2353
+ }
2332
2354
if ( resExt [ 0 ] == resExt [ 1 ] ) {
2333
2355
resExt [ 0 ] -= 1 ;
2334
2356
resExt [ 1 ] += 1 ;
2335
2357
}
2358
+ if ( resExt [ 0 ] > resExt [ 1 ] ) {
2359
+ resExt = resExt . reverse ( ) ;
2360
+ }
2336
2361
return resExt ;
2337
2362
}
2338
2363
@@ -2426,10 +2451,18 @@ class graphly extends EventEmitter {
2426
2451
} else {
2427
2452
domain = d3 . extent ( this . data [ cAxis [ ca ] ] ) ;
2428
2453
}
2429
- // Check if domain start and ed is equal
2430
- if ( domain [ 0 ] === domain [ 1 ] ) {
2454
+ if ( isNaN ( domain [ 0 ] ) ) {
2455
+ domain [ 0 ] = 0 ;
2456
+ }
2457
+ if ( isNaN ( domain [ 1 ] ) ) {
2458
+ domain [ 1 ] = domain [ 0 ] + 1 ;
2459
+ }
2460
+ if ( domain [ 0 ] == domain [ 1 ] ) {
2431
2461
domain [ 0 ] -= 1 ;
2432
- domain [ 0 ] += 1 ;
2462
+ domain [ 1 ] += 1 ;
2463
+ }
2464
+ if ( domain [ 0 ] > domain [ 1 ] ) {
2465
+ domain = domain . reverse ( ) ;
2433
2466
}
2434
2467
// Set current calculated extent to settings
2435
2468
this . dataSettings [ cAxis [ ca ] ] . extent = domain ;
@@ -5044,8 +5077,38 @@ class graphly extends EventEmitter {
5044
5077
if ( ca !== null ) {
5045
5078
if ( this . dataSettings . hasOwnProperty ( ca ) ) {
5046
5079
if ( ! this . dataSettings [ ca ] . hasOwnProperty ( 'extent' ) ) {
5080
+ let domain ;
5047
5081
// Set current calculated extent to settings
5048
- this . dataSettings [ ca ] . extent = d3 . extent ( this . currentData [ ca ] ) ;
5082
+ if ( this . dataSettings [ ca ] . hasOwnProperty ( 'nullValue' ) ) {
5083
+ let nV = this . dataSettings [ ca ] . nullValue ;
5084
+ // If parameter has nullvalue defined ignore it
5085
+ // when calculating extent
5086
+ domain = d3 . extent (
5087
+ this . currentData [ ca ] , ( v ) => {
5088
+ if ( v !== nV ) {
5089
+ return v ;
5090
+ } else {
5091
+ return null ;
5092
+ }
5093
+ }
5094
+ ) ;
5095
+ } else {
5096
+ domain = d3 . extent ( this . currentData [ ca ] ) ;
5097
+ }
5098
+ if ( isNaN ( domain [ 0 ] ) ) {
5099
+ domain [ 0 ] = 0 ;
5100
+ }
5101
+ if ( isNaN ( domain [ 1 ] ) ) {
5102
+ domain [ 1 ] = domain [ 0 ] + 1 ;
5103
+ }
5104
+ if ( domain [ 0 ] == domain [ 1 ] ) {
5105
+ domain [ 0 ] -= 1 ;
5106
+ domain [ 1 ] += 1 ;
5107
+ }
5108
+ if ( domain [ 0 ] > domain [ 1 ] ) {
5109
+ domain = domain . reverse ( ) ;
5110
+ }
5111
+ this . dataSettings [ ca ] . extent = domain ;
5049
5112
this . createColorScales ( ) ;
5050
5113
}
5051
5114
}
0 commit comments