@@ -17,11 +17,6 @@ var filterUnique = require('../../lib/filter_unique.js');
17
17
var Drawing = require ( '../../components/drawing' ) ;
18
18
var Lib = require ( '../../lib' ) ;
19
19
20
-
21
- function visible ( dimension ) { return ! ( 'visible' in dimension ) || dimension . visible ; }
22
-
23
- // Exports
24
- // =======
25
20
/**
26
21
* Create a wrapped ParcatsModel object from trace
27
22
*
@@ -31,24 +26,18 @@ function visible(dimension) { return !('visible' in dimension) || dimension.visi
31
26
* @return {Array.<ParcatsModel> }
32
27
*/
33
28
module . exports = function calc ( gd , trace ) {
29
+ var visibleDims = Lib . filterVisible ( trace . dimensions ) ;
34
30
35
- // Process inputs
36
- // --------------
37
- if ( trace . dimensions . filter ( visible ) . length === 0 ) {
38
- // No visible dimensions specified. Nothing to compute
39
- return [ ] ;
40
- }
31
+ if ( visibleDims . length === 0 ) return [ ] ;
41
32
42
- // Compute unique information
43
- // --------------------------
44
- // UniqueInfo per dimension
45
- var uniqueInfoDims = trace . dimensions . filter ( visible ) . map ( function ( dim ) {
33
+ var uniqueInfoDims = visibleDims . map ( function ( dim ) {
46
34
var categoryValues ;
47
35
if ( dim . categoryorder === 'trace' ) {
48
36
// Use order of first occurrence in trace
49
37
categoryValues = null ;
50
38
} else if ( dim . categoryorder === 'array' ) {
51
- // Use categories specified in `categoryarray` first, then add extra to the end in trace order
39
+ // Use categories specified in `categoryarray` first,
40
+ // then add extra to the end in trace order
52
41
categoryValues = dim . categoryarray ;
53
42
} else {
54
43
// Get all categories up front so we can order them
@@ -61,8 +50,6 @@ module.exports = function calc(gd, trace) {
61
50
return getUniqueInfo ( dim . values , categoryValues ) ;
62
51
} ) ;
63
52
64
- // Process counts
65
- // --------------
66
53
var counts ,
67
54
count ,
68
55
totalCount ;
@@ -72,13 +59,9 @@ module.exports = function calc(gd, trace) {
72
59
counts = [ trace . counts ] ;
73
60
}
74
61
75
- // Validate dimension display order
76
- // --------------------------------
77
- validateDimensionDisplayInds ( trace ) ;
62
+ validateDimensionDisplayInds ( visibleDims ) ;
78
63
79
- // Validate category display order
80
- // -------------------------------
81
- trace . dimensions . filter ( visible ) . forEach ( function ( dim , dimInd ) {
64
+ visibleDims . forEach ( function ( dim , dimInd ) {
82
65
validateCategoryProperties ( dim , uniqueInfoDims [ dimInd ] ) ;
83
66
} ) ;
84
67
@@ -111,7 +94,7 @@ module.exports = function calc(gd, trace) {
111
94
112
95
// Number of values and counts
113
96
// ---------------------------
114
- var numValues = trace . dimensions . filter ( visible ) [ 0 ] . values . length ;
97
+ var numValues = visibleDims [ 0 ] . values . length ;
115
98
116
99
// Build path info
117
100
// ---------------
@@ -155,11 +138,7 @@ module.exports = function calc(gd, trace) {
155
138
updatePathModel ( pathModels [ pathKey ] , valueInd , count ) ;
156
139
}
157
140
158
- // Build categories info
159
- // ---------------------
160
-
161
- // Array of DimensionModel objects
162
- var dimensionModels = trace . dimensions . filter ( visible ) . map ( function ( di , i ) {
141
+ var dimensionModels = visibleDims . map ( function ( di , i ) {
163
142
return createDimensionModel ( i , di . _index , di . _displayindex , di . label , totalCount ) ;
164
143
} ) ;
165
144
@@ -216,7 +195,6 @@ module.exports = function calc(gd, trace) {
216
195
*/
217
196
function createParcatsModel ( dimensions , paths , count ) {
218
197
var maxCats = dimensions
219
- . filter ( visible )
220
198
. map ( function ( d ) { return d . categories . length ; } )
221
199
. reduce ( function ( v1 , v2 ) { return Math . max ( v1 , v2 ) ; } ) ;
222
200
return { dimensions : dimensions , paths : paths , trace : undefined , maxCats : maxCats , count : count } ;
@@ -460,8 +438,7 @@ function getUniqueInfo(values, uniqueValues) {
460
438
* Otherwise, replace the display order with the dimension order
461
439
* @param {Object } trace
462
440
*/
463
- function validateDimensionDisplayInds ( trace ) {
464
- var visibleDims = Lib . filterVisible ( trace . dimensions ) ;
441
+ function validateDimensionDisplayInds ( visibleDims ) {
465
442
var displayInds = visibleDims . map ( function ( d ) { return d . displayindex ; } ) ;
466
443
var i ;
467
444
0 commit comments