@@ -228,14 +228,17 @@ var dimple = {
228228 origin ,
229229 getOrderedCategories = function ( self , axPos , oppPos ) {
230230 var category = self . categoryFields [ 0 ] ,
231+ chartData = self . chart . _getAllData ( ) ,
231232 sortBy = category ,
232233 desc = false ,
233234 isDate = true ,
235+ currentValue = null ,
234236 i ,
235237 definitions = [ ] ;
236238 // Check whether this field is a date
237- for ( i = 0 ; i < self . chart . data . length ; i += 1 ) {
238- if ( isNaN ( self . _parseDate ( self . chart . data [ i ] [ category ] ) ) ) {
239+ for ( i = 0 ; i < chartData . length ; i += 1 ) {
240+ currentValue = self . _parseDate ( chartData [ i ] [ category ] ) ;
241+ if ( currentValue !== null && currentValue !== undefined && isNaN ( currentValue ) ) {
239242 isDate = false ;
240243 break ;
241244 }
@@ -250,7 +253,7 @@ var dimple = {
250253 } , this ) ;
251254 }
252255 definitions = self . _orderRules . concat ( { ordering : sortBy , desc : desc } ) ;
253- return dimple . _getOrderedList ( self . chart . data , category , definitions ) ;
256+ return dimple . _getOrderedList ( chartData , category , definitions ) ;
254257 } ;
255258
256259 // If the axis is a percentage type axis the bounds must be between -1 and 1. Sometimes
@@ -495,6 +498,30 @@ var dimple = {
495498 } ;
496499
497500
501+ // Copyright: 2013 PMSI-AlignAlytics
502+ // License: "https://github.com/PMSI-AlignAlytics/dimple/blob/master/MIT-LICENSE.txt"
503+ // Source: /src/objects/chart/methods/_getAllData.js
504+ // Mash together all of the datasets
505+ this . _getAllData = function ( ) {
506+ // The return array will include all data for chart as well as an series
507+ var returnData = [ ] ;
508+ // If there is data at the chart level
509+ if ( this . data !== null && this . data !== undefined && this . data . length > 0 ) {
510+ returnData = returnData . concat ( this . data ) ;
511+ }
512+ // If there are series defined
513+ if ( this . series !== null && this . series !== undefined && this . series . length > 0 ) {
514+ this . series . forEach ( function ( s ) {
515+ if ( s . data !== null && s . data !== undefined && s . data . length > 0 ) {
516+ returnData = returnData . concat ( s . data ) ;
517+ }
518+ } ) ;
519+ }
520+ // Return the final dataset
521+ return returnData ;
522+ } ;
523+
524+
498525 // Copyright: 2013 PMSI-AlignAlytics
499526 // License: "https://github.com/PMSI-AlignAlytics/dimple/blob/master/MIT-LICENSE.txt"
500527 // Source: /src/objects/chart/methods/_getSeriesData.js
@@ -544,22 +571,22 @@ var dimple = {
544571 yCat = "" ,
545572 ySortArray = [ ] ,
546573 rules = [ ] ,
547- sortedData = series . data || this . data ,
574+ sortedData = series . data || this . data ,
548575 groupRules = [ ] ;
549576
550577 if ( this . storyboard !== null && this . storyboard !== undefined && this . storyboard . categoryFields . length > 0 ) {
551578 storyCat = this . storyboard . categoryFields [ 0 ] ;
552- orderedStoryboardArray = dimple . _getOrderedList ( this . data , storyCat , this . storyboard . _orderRules ) ;
579+ orderedStoryboardArray = dimple . _getOrderedList ( sortedData , storyCat , this . storyboard . _orderRules ) ;
553580 }
554581
555582 // Deal with mekkos
556583 if ( series . x . _hasCategories ( ) && series . x . _hasMeasure ( ) ) {
557584 xCat = series . x . categoryFields [ 0 ] ;
558- xSortArray = dimple . _getOrderedList ( this . data , xCat , series . x . _orderRules . concat ( [ { ordering : series . x . measure , desc : true } ] ) ) ;
585+ xSortArray = dimple . _getOrderedList ( sortedData , xCat , series . x . _orderRules . concat ( [ { ordering : series . x . measure , desc : true } ] ) ) ;
559586 }
560587 if ( series . y . _hasCategories ( ) && series . y . _hasMeasure ( ) ) {
561588 yCat = series . y . categoryFields [ 0 ] ;
562- ySortArray = dimple . _getOrderedList ( this . data , yCat , series . y . _orderRules . concat ( [ { ordering : series . y . measure , desc : true } ] ) ) ;
589+ ySortArray = dimple . _getOrderedList ( sortedData , yCat , series . y . _orderRules . concat ( [ { ordering : series . y . measure , desc : true } ] ) ) ;
563590 }
564591
565592 if ( series . categoryFields !== null && series . categoryFields !== undefined && series . categoryFields . length > 0 ) {
@@ -576,7 +603,7 @@ var dimple = {
576603 } else if ( series . y . _hasMeasure ( ) ) {
577604 rules . push ( { ordering : series . y . measure , desc : true } ) ;
578605 }
579- orderedSeriesArray = dimple . _getOrderedList ( this . data , seriesCat , rules ) ;
606+ orderedSeriesArray = dimple . _getOrderedList ( sortedData , seriesCat , rules ) ;
580607 }
581608
582609 sortedData . sort ( function ( a , b ) {
@@ -721,14 +748,14 @@ var dimple = {
721748 if ( series . y . _hasMeasure ( ) ) {
722749 groupRules . push ( { ordering : series . y . measure , desc : true } ) ;
723750 }
724- secondaryElements . x = dimple . _getOrderedList ( this . data , series . x . categoryFields [ 1 ] , series . x . _groupOrderRules . concat ( groupRules ) ) ;
751+ secondaryElements . x = dimple . _getOrderedList ( sortedData , series . x . categoryFields [ 1 ] , series . x . _groupOrderRules . concat ( groupRules ) ) ;
725752 }
726753 if ( series . y !== null && series . y !== undefined && series . y . _hasCategories ( ) && series . y . categoryFields . length > 1 && secondaryElements . y !== undefined ) {
727754 groupRules = [ ] ;
728755 if ( series . x . _hasMeasure ( ) ) {
729756 groupRules . push ( { ordering : series . x . measure , desc : true } ) ;
730757 }
731- secondaryElements . y = dimple . _getOrderedList ( this . data , series . y . categoryFields [ 1 ] , series . y . _groupOrderRules . concat ( groupRules ) ) ;
758+ secondaryElements . y = dimple . _getOrderedList ( sortedData , series . y . categoryFields [ 1 ] , series . y . _groupOrderRules . concat ( groupRules ) ) ;
732759 secondaryElements . y . reverse ( ) ;
733760 }
734761 returnData . forEach ( function ( ret ) {
@@ -1147,7 +1174,7 @@ var dimple = {
11471174 // in a real context, but when developing it is nice to see axes before any series have
11481175 // been added.
11491176 if ( ! linked ) {
1150- this . data . forEach ( function ( d ) {
1177+ this . _getAllData ( ) . forEach ( function ( d ) {
11511178 if ( axis . _min > d [ axis . measure ] ) { axis . _min = d [ axis . measure ] ; }
11521179 if ( axis . _max < d [ axis . measure ] ) { axis . _max = d [ axis . measure ] ; }
11531180 } , this ) ;
@@ -1156,7 +1183,7 @@ var dimple = {
11561183 // Parse the dates and assign the min and max
11571184 axis . _min = null ;
11581185 axis . _max = null ;
1159- this . data . forEach ( function ( d ) {
1186+ this . _getAllData ( ) . forEach ( function ( d ) {
11601187 var dt = axis . _parseDate ( d [ axis . timeField ] ) ;
11611188 if ( axis . _min === null || dt < axis . _min ) {
11621189 axis . _min = dt ;
@@ -1169,7 +1196,7 @@ var dimple = {
11691196 // A category axis is just set to show the number of categories
11701197 axis . _min = 0 ;
11711198 distinctCats = [ ] ;
1172- this . data . forEach ( function ( d ) {
1199+ this . _getAllData ( ) . forEach ( function ( d ) {
11731200 if ( distinctCats . indexOf ( d [ axis . categoryFields [ 0 ] ] ) === - 1 ) {
11741201 distinctCats . push ( d [ axis . categoryFields [ 0 ] ] ) ;
11751202 }
@@ -2122,7 +2149,7 @@ var dimple = {
21222149 // Clear the array
21232150 this . _categories = [ ] ;
21242151 // Iterate every row in the data
2125- this . chart . data . forEach ( function ( d ) {
2152+ this . chart . _getAllData ( ) . forEach ( function ( d ) {
21262153 // Initialise the index of the categories array matching the current row
21272154 var index = - 1 ,
21282155 field = "" ;
@@ -4260,4 +4287,4 @@ var dimple = {
42604287
42614288
42624289} ( ) ) ;
4263- // End dimple
4290+ // End dimple
0 commit comments