Skip to content

Commit 952e4ea

Browse files
committed
Fix groupby groupnames supplyDefaults
1 parent 4e6a0aa commit 952e4ea

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

src/transforms/groupby.js

+29-8
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,22 @@ exports.attributes = {
4646
].join(' ')
4747
},
4848
groupnames: {
49-
valType: 'any',
50-
description: [
51-
'An array of trace names based on group name. Each entry must be an',
52-
'object `{name: "group", value: "trace name"}` which is then applied',
53-
'to the particular group, overriding the name derived from `nameformat`.'
54-
].join(' ')
49+
_isLinkedToArray: 'groupname',
50+
group: {
51+
valType: 'string',
52+
role: 'info',
53+
description: [
54+
'An group to which this name applies. If a `group` and `name` are specified,',
55+
'that name overrides the `nameformat` for that group\'s trace.'
56+
].join(' ')
57+
},
58+
name: {
59+
valType: 'string',
60+
role: 'info',
61+
description: [
62+
'Trace names assigned to the grouped traces of the corresponding `group`.'
63+
].join(' ')
64+
}
5565
},
5666
styles: {
5767
_isLinkedToArray: 'style',
@@ -90,6 +100,7 @@ exports.attributes = {
90100
* copy of transformIn that contains attribute defaults
91101
*/
92102
exports.supplyDefaults = function(transformIn) {
103+
var i;
93104
var transformOut = {};
94105

95106
function coerce(attr, dflt) {
@@ -101,14 +112,24 @@ exports.supplyDefaults = function(transformIn) {
101112
if(!enabled) return transformOut;
102113

103114
coerce('groups');
104-
coerce('groupnames');
105115
coerce('nameformat');
106116

117+
var nameFormatIn = transformIn.groupnames;
118+
var nameFormatOut = transformOut.groupnames = [];
119+
120+
if(nameFormatIn) {
121+
for(i = 0; i < nameFormatIn.length; i++) {
122+
nameFormatOut[i] = {};
123+
Lib.coerce(nameFormatIn[i], nameFormatOut[i], exports.attributes.groupnames, 'group');
124+
Lib.coerce(nameFormatIn[i], nameFormatOut[i], exports.attributes.groupnames, 'name');
125+
}
126+
}
127+
107128
var styleIn = transformIn.styles;
108129
var styleOut = transformOut.styles = [];
109130

110131
if(styleIn) {
111-
for(var i = 0; i < styleIn.length; i++) {
132+
for(i = 0; i < styleIn.length; i++) {
112133
styleOut[i] = {};
113134
Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'target');
114135
Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'value');

0 commit comments

Comments
 (0)