Skip to content

Commit ffc4ee2

Browse files
committed
aggregations.array -> target
and (lint) style -> aggregation
1 parent 317938f commit ffc4ee2

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

src/transforms/aggregate.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ var attrs = exports.attributes = {
4747
].join(' ')
4848
},
4949
aggregations: {
50-
_isLinkedToArray: 'style',
51-
array: {
50+
_isLinkedToArray: 'aggregation',
51+
target: {
5252
valType: 'string',
5353
role: 'info',
5454
description: [
@@ -67,7 +67,7 @@ var attrs = exports.attributes = {
6767
role: 'info',
6868
description: [
6969
'Sets the aggregation function.',
70-
'All values from the linked `array`, corresponding to the same value',
70+
'All values from the linked `target`, corresponding to the same value',
7171
'in the `groups` array, are collected and reduced by this function.',
7272
'*count* is simply the number of values in the `groups` array, so does',
7373
'not even require the linked array to exist. *first* (*last*) is just',
@@ -134,13 +134,13 @@ exports.supplyDefaults = function(transformIn, traceOut) {
134134
if(aggregationsIn) {
135135
for(i = 0; i < aggregationsIn.length; i++) {
136136
var aggregationOut = {};
137-
var array = Lib.coerce(aggregationsIn[i], aggregationOut, attrs.aggregations, 'array');
137+
var target = Lib.coerce(aggregationsIn[i], aggregationOut, attrs.aggregations, 'target');
138138
var func = Lib.coerce(aggregationsIn[i], aggregationOut, attrs.aggregations, 'func');
139139

140140
// add this aggregation to the output only if it's the first instance
141-
// of a valid array attribute - or an unused array attribute with "count"
142-
if(array && (arrayAttrs[array] || (func === 'count' && arrayAttrs[array] === undefined))) {
143-
arrayAttrs[array] = 0;
141+
// of a valid target attribute - or an unused target attribute with "count"
142+
if(target && (arrayAttrs[target] || (func === 'count' && arrayAttrs[target] === undefined))) {
143+
arrayAttrs[target] = 0;
144144
aggregationsOut.push(aggregationOut);
145145
}
146146
}
@@ -150,7 +150,7 @@ exports.supplyDefaults = function(transformIn, traceOut) {
150150
for(i = 0; i < arrayAttrArray.length; i++) {
151151
if(arrayAttrs[arrayAttrArray[i]]) {
152152
aggregationsOut.push({
153-
array: arrayAttrArray[i],
153+
target: arrayAttrArray[i],
154154
func: attrs.aggregations.func.dflt
155155
});
156156
}
@@ -189,12 +189,12 @@ exports.calcTransform = function(gd, trace, opts) {
189189
}
190190

191191
if(typeof groups === 'string') {
192-
aggregateOneArray(gd, trace, groupings, {array: groups, func: 'first'});
192+
aggregateOneArray(gd, trace, groupings, {target: groups, func: 'first'});
193193
}
194194
};
195195

196196
function aggregateOneArray(gd, trace, groupings, aggregation) {
197-
var attr = aggregation.array;
197+
var attr = aggregation.target;
198198
var targetNP = Lib.nestedProperty(trace, attr);
199199
var arrayIn = targetNP.get();
200200
var conversions = Axes.getDataConversions(gd, trace, attr, arrayIn);

test/jasmine/tests/transform_aggregate_test.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ describe('aggregate', function() {
3131
groups: ['a', 'b', 'a', 'a', 'a'],
3232
aggregations: [
3333
// missing array - the entry is ignored
34-
{array: '', func: 'avg'},
35-
{array: 'x', func: 'sum'},
34+
{target: '', func: 'avg'},
35+
{target: 'x', func: 'sum'},
3636
// non-numerics will not count toward numerator or denominator for avg
37-
{array: 'y', func: 'avg'},
38-
{array: 'marker.size', func: 'min'},
39-
{array: 'marker.color', func: 'max'},
37+
{target: 'y', func: 'avg'},
38+
{target: 'marker.size', func: 'min'},
39+
{target: 'marker.color', func: 'max'},
4040
// marker.opacity doesn't have an entry, but it will default to first
41-
// as if it were {array: 'marker.opacity', func: 'first'},
42-
{array: 'marker.line.color', func: 'last'},
41+
// as if it were {target: 'marker.opacity', func: 'first'},
42+
{target: 'marker.line.color', func: 'last'},
4343
// not present in data, but that's OK for count
44-
{array: 'marker.line.width', func: 'count'},
44+
{target: 'marker.line.width', func: 'count'},
4545
// duplicate entry - discarded
46-
{array: 'x', func: 'min'}
46+
{target: 'x', func: 'min'}
4747
]
4848
}]
4949
}], {
@@ -76,16 +76,16 @@ describe('aggregate', function() {
7676
// will always compare as strings = so 1 === '1' === 1.0 !== '1.0'
7777
groups: [1, 2, '1', 1.0, 1],
7878
aggregations: [
79-
{array: 'x', func: 'avg'},
80-
{array: 'y', func: 'min'},
81-
{array: 'text', func: 'max'},
79+
{target: 'x', func: 'avg'},
80+
{target: 'y', func: 'min'},
81+
{target: 'text', func: 'max'},
8282
// hovertext doesn't have a func, default to first
83-
{array: 'hovertext'},
84-
{array: 'customdata', func: 'last'},
83+
{target: 'hovertext'},
84+
{target: 'customdata', func: 'last'},
8585
// not present in data, but that's OK for count
86-
{array: 'marker.line.width', func: 'count'},
86+
{target: 'marker.line.width', func: 'count'},
8787
// duplicate entry - discarded
88-
{array: 'x', func: 'min'}
88+
{target: 'x', func: 'min'}
8989
]
9090
}]
9191
}]);
@@ -111,14 +111,14 @@ describe('aggregate', function() {
111111
type: 'aggregate',
112112
groups: [1, 2, 1, 1, 1],
113113
aggregations: [
114-
{array: 'x', func: 'min'},
115-
{array: 'y', func: 'max'},
116-
{array: 'text', func: 'last'},
114+
{target: 'x', func: 'min'},
115+
{target: 'y', func: 'max'},
116+
{target: 'text', func: 'last'},
117117
// hovertext doesn't have an entry, but it will default to first
118118
// not present in data, but that's OK for count
119-
{array: 'marker.line.width', func: 'count'},
119+
{target: 'marker.line.width', func: 'count'},
120120
// duplicate entry - discarded
121-
{array: 'x', func: 'max'}
121+
{target: 'x', func: 'max'}
122122
]
123123
}]
124124
}], {
@@ -148,9 +148,9 @@ describe('aggregate', function() {
148148
type: 'aggregate',
149149
groups: [1, 1, 2, 2],
150150
aggregations: [
151-
{array: 'x', func: 'sum'},
152-
{array: 'y', func: 'sum'},
153-
{array: 'text', func: 'avg'}
151+
{target: 'x', func: 'sum'},
152+
{target: 'y', func: 'sum'},
153+
{target: 'text', func: 'avg'}
154154
]
155155
}]
156156
}]);
@@ -175,8 +175,8 @@ describe('aggregate', function() {
175175
type: 'aggregate',
176176
groups: 'marker.size',
177177
aggregations: [
178-
{array: 'x', func: 'sum'},
179-
{array: 'y', func: 'avg'}
178+
{target: 'x', func: 'sum'},
179+
{target: 'y', func: 'avg'}
180180
]
181181
}]
182182
}]);

test/jasmine/tests/transform_multi_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ describe('multiple transforms:', function() {
449449
type: 'aggregate',
450450
groups: [1, 2, 2, 1, 1],
451451
aggregations: [
452-
{array: 'x', func: 'sum'},
453-
{array: 'y', func: 'avg'}
452+
{target: 'x', func: 'sum'},
453+
{target: 'y', func: 'avg'}
454454
]
455455
}, {
456456
type: 'filter',
@@ -488,8 +488,8 @@ describe('multiple transforms:', function() {
488488
type: 'aggregate',
489489
groups: [1, 2, 2, 1, 1],
490490
aggregations: [
491-
{array: 'x', func: 'sum'},
492-
{array: 'y', func: 'avg'}
491+
{target: 'x', func: 'sum'},
492+
{target: 'y', func: 'avg'}
493493
]
494494
}]
495495
};

0 commit comments

Comments
 (0)