@@ -39,11 +39,11 @@ exports.attributes = {
3939 valType : 'string' ,
4040 description : [
4141 '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' ,
4545 '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)".'
4747 ] . join ( ' ' )
4848 } ,
4949 groupnames : {
@@ -100,7 +100,7 @@ exports.attributes = {
100100 * @return {object } transformOut
101101 * copy of transformIn that contains attribute defaults
102102 */
103- exports . supplyDefaults = function ( transformIn , traceOut , layout , traceIn ) {
103+ exports . supplyDefaults = function ( transformIn , traceOut , layout ) {
104104 var i ;
105105 var transformOut = { } ;
106106
@@ -113,7 +113,7 @@ exports.supplyDefaults = function(transformIn, traceOut, layout, traceIn) {
113113 if ( ! enabled ) return transformOut ;
114114
115115 coerce ( 'groups' ) ;
116- coerce ( 'nameformat' , layout . _dataLength > 1 ? '%g (%t )' : '%g ' ) ;
116+ coerce ( 'nameformat' , layout . _dataLength > 1 ? '%{group} (%{trace} )' : '%{group} ' ) ;
117117
118118 var nameFormatIn = transformIn . groupnames ;
119119 var nameFormatOut = transformOut . groupnames = [ ] ;
@@ -172,12 +172,6 @@ exports.transform = function(data, state) {
172172 return newData ;
173173} ;
174174
175- function computeName ( pattern , traceName , groupName ) {
176- return pattern . replace ( / % g / g, groupName )
177- . replace ( / % t / g, traceName ) ;
178- }
179-
180-
181175function transformOne ( trace , state ) {
182176 var i , j , k , attr , srcArray , groupName , newTrace , transforms , arrayLookup ;
183177 var groupNameObj ;
@@ -224,7 +218,10 @@ function transformOne(trace, state) {
224218 if ( suppliedName ) {
225219 newTrace . name = suppliedName ;
226220 } 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+ } ) ;
228225 }
229226
230227 // In order for groups to apply correctly to other transform data (e.g.
0 commit comments