11
11
var Lib = require ( '../lib' ) ;
12
12
var PlotSchema = require ( '../plot_api/plot_schema' ) ;
13
13
var Plots = require ( '../plots/plots' ) ;
14
+ var pointsAccessorFunction = require ( './helpers' ) . pointsAccessorFunction ;
14
15
15
16
exports . moduleType = 'transform' ;
16
17
@@ -161,6 +162,7 @@ function transformOne(trace, state) {
161
162
162
163
var opts = state . transform ;
163
164
var groups = trace . transforms [ state . transformIndex ] . groups ;
165
+ var originalPointsAccessor = pointsAccessorFunction ( trace . transforms , opts ) ;
164
166
165
167
if ( ! ( Array . isArray ( groups ) ) || groups . length === 0 ) {
166
168
return [ trace ] ;
@@ -184,14 +186,17 @@ function transformOne(trace, state) {
184
186
185
187
// An index to map group name --> expanded trace index
186
188
var indexLookup = { } ;
189
+ var indexCnts = { } ;
187
190
188
191
for ( i = 0 ; i < groupNames . length ; i ++ ) {
189
192
groupName = groupNames [ i ] ;
190
193
indexLookup [ groupName ] = i ;
194
+ indexCnts [ groupName ] = 0 ;
191
195
192
196
// Start with a deep extend that just copies array references.
193
197
newTrace = newData [ i ] = Lib . extendDeepNoArrays ( { } , trace ) ;
194
198
newTrace . _group = groupName ;
199
+ newTrace . transforms [ state . transformIndex ] . _indexToPoints = { } ;
195
200
196
201
var suppliedName = null ;
197
202
if ( groupNameObj ) {
@@ -246,6 +251,14 @@ function transformOne(trace, state) {
246
251
}
247
252
}
248
253
254
+ for ( j = 0 ; j < len ; j ++ ) {
255
+ newTrace = newData [ indexLookup [ groups [ j ] ] ] ;
256
+
257
+ var indexToPoints = newTrace . transforms [ state . transformIndex ] . _indexToPoints ;
258
+ indexToPoints [ indexCnts [ groups [ j ] ] ] = originalPointsAccessor ( j ) ;
259
+ indexCnts [ groups [ j ] ] ++ ;
260
+ }
261
+
249
262
for ( i = 0 ; i < groupNames . length ; i ++ ) {
250
263
groupName = groupNames [ i ] ;
251
264
newTrace = newData [ i ] ;
0 commit comments