@@ -39,11 +39,11 @@ exports.attributes = {
39
39
valType : 'string' ,
40
40
description : [
41
41
'Pattern by which grouped traces are named. If only one trace is present,' ,
42
- 'defaults to the group name (`"%g "`), otherwise defaults to the group name' ,
43
- 'with trace name (`"%g (%t )"`). Available escape sequences are `%g `, which' ,
44
- 'inserts the group name, and `%t `, which inserts the trace name. If grouping' ,
42
+ 'defaults to the group name (`"%{group} "`), otherwise defaults to the group name' ,
43
+ 'with trace name (`"%{group} (%{trace} )"`). Available escape sequences are `%{group} `, which' ,
44
+ 'inserts the group name, and `%{trace} `, which inserts the trace name. If grouping' ,
45
45
'GDP data by country when more than one trace is present, for example, the' ,
46
- 'default "%g (%t )" would return "Monaco (GDP per capita)".'
46
+ 'default "%{group} (%{trace} )" would return "Monaco (GDP per capita)".'
47
47
] . join ( ' ' )
48
48
} ,
49
49
groupnames : {
@@ -100,7 +100,7 @@ exports.attributes = {
100
100
* @return {object } transformOut
101
101
* copy of transformIn that contains attribute defaults
102
102
*/
103
- exports . supplyDefaults = function ( transformIn , traceOut , layout , traceIn ) {
103
+ exports . supplyDefaults = function ( transformIn , traceOut , layout ) {
104
104
var i ;
105
105
var transformOut = { } ;
106
106
@@ -113,7 +113,7 @@ exports.supplyDefaults = function(transformIn, traceOut, layout, traceIn) {
113
113
if ( ! enabled ) return transformOut ;
114
114
115
115
coerce ( 'groups' ) ;
116
- coerce ( 'nameformat' , layout . _dataLength > 1 ? '%g (%t )' : '%g ' ) ;
116
+ coerce ( 'nameformat' , layout . _dataLength > 1 ? '%{group} (%{trace} )' : '%{group} ' ) ;
117
117
118
118
var nameFormatIn = transformIn . groupnames ;
119
119
var nameFormatOut = transformOut . groupnames = [ ] ;
@@ -172,12 +172,6 @@ exports.transform = function(data, state) {
172
172
return newData ;
173
173
} ;
174
174
175
- function computeName ( pattern , traceName , groupName ) {
176
- return pattern . replace ( / % g / g, groupName )
177
- . replace ( / % t / g, traceName ) ;
178
- }
179
-
180
-
181
175
function transformOne ( trace , state ) {
182
176
var i , j , k , attr , srcArray , groupName , newTrace , transforms , arrayLookup ;
183
177
var groupNameObj ;
@@ -224,7 +218,10 @@ function transformOne(trace, state) {
224
218
if ( suppliedName ) {
225
219
newTrace . name = suppliedName ;
226
220
} else {
227
- newTrace . name = computeName ( opts . nameformat , trace . name , groupName ) ;
221
+ newTrace . name = Lib . templateString ( opts . nameformat , {
222
+ trace : trace . name ,
223
+ group : groupName
224
+ } ) ;
228
225
}
229
226
230
227
// In order for groups to apply correctly to other transform data (e.g.
0 commit comments