@@ -184,13 +184,11 @@ function setGroupPositionsInStackOrRelativeMode(gd, pa, sa, calcTraces) {
184
184
185
185
function setOffsetAndWidth ( gd , pa , sieve ) {
186
186
var fullLayout = gd . _fullLayout ,
187
- pLetter = getAxisLetter ( pa ) ,
188
187
bargap = fullLayout . bargap ,
189
188
bargroupgap = fullLayout . bargroupgap ,
190
189
minDiff = sieve . minDiff ,
191
190
calcTraces = sieve . traces ,
192
191
i , calcTrace , calcTrace0 ,
193
- j , calcBar ,
194
192
t ;
195
193
196
194
// set bar offsets and widths
@@ -199,8 +197,7 @@ function setOffsetAndWidth(gd, pa, sieve) {
199
197
barWidth = barWidthPlusGap * ( 1 - bargroupgap ) ;
200
198
201
199
// computer bar group center and bar offset
202
- var offsetFromCenter = - barWidth / 2 ,
203
- barCenter = 0 ;
200
+ var offsetFromCenter = - barWidth / 2 ;
204
201
205
202
for ( i = 0 ; i < calcTraces . length ; i ++ ) {
206
203
calcTrace = calcTraces [ i ] ;
@@ -211,12 +208,6 @@ function setOffsetAndWidth(gd, pa, sieve) {
211
208
t . barwidth = barWidth ;
212
209
t . poffset = offsetFromCenter ;
213
210
t . bargroupwidth = barGroupWidth ;
214
-
215
- // store the bar center in each calcdata item
216
- for ( j = 0 ; j < calcTrace . length ; j ++ ) {
217
- calcBar = calcTrace [ j ] ;
218
- calcBar [ pLetter ] = calcBar . p + barCenter ;
219
- }
220
211
}
221
212
222
213
// stack bars that only differ by rounding
@@ -225,22 +216,23 @@ function setOffsetAndWidth(gd, pa, sieve) {
225
216
// if defined, apply trace offset and width
226
217
applyAttributes ( sieve ) ;
227
218
219
+ // store the bar center in each calcdata item
220
+ setBarCenter ( gd , pa , sieve ) ;
221
+
228
222
// update position axes
229
223
updatePositionAxis ( gd , pa , sieve ) ;
230
224
}
231
225
232
226
233
227
function setOffsetAndWidthInGroupMode ( gd , pa , sieve ) {
234
228
var fullLayout = gd . _fullLayout ,
235
- pLetter = getAxisLetter ( pa ) ,
236
229
bargap = fullLayout . bargap ,
237
230
bargroupgap = fullLayout . bargroupgap ,
238
231
positions = sieve . positions ,
239
232
distinctPositions = sieve . distinctPositions ,
240
233
minDiff = sieve . minDiff ,
241
234
calcTraces = sieve . traces ,
242
235
i , calcTrace , calcTrace0 ,
243
- j , calcBar ,
244
236
t ;
245
237
246
238
// if there aren't any overlapping positions,
@@ -259,20 +251,13 @@ function setOffsetAndWidthInGroupMode(gd, pa, sieve) {
259
251
// computer bar group center and bar offset
260
252
var offsetFromCenter = ( overlap ) ?
261
253
( ( 2 * i + 1 - nTraces ) * barWidthPlusGap - barWidth ) / 2 :
262
- - barWidth / 2 ,
263
- barCenter = offsetFromCenter + barWidth / 2 ;
254
+ - barWidth / 2 ;
264
255
265
256
// store bar width and offset for this trace
266
257
t = calcTrace0 . t ;
267
258
t . barwidth = barWidth ;
268
259
t . poffset = offsetFromCenter ;
269
260
t . bargroupwidth = barGroupWidth ;
270
-
271
- // store the bar center in each calcdata item
272
- for ( j = 0 ; j < calcTrace . length ; j ++ ) {
273
- calcBar = calcTrace [ j ] ;
274
- calcBar [ pLetter ] = calcBar . p + barCenter ;
275
- }
276
261
}
277
262
278
263
// stack bars that only differ by rounding
@@ -281,6 +266,9 @@ function setOffsetAndWidthInGroupMode(gd, pa, sieve) {
281
266
// if defined, apply trace width
282
267
applyAttributes ( sieve ) ;
283
268
269
+ // store the bar center in each calcdata item
270
+ setBarCenter ( gd , pa , sieve ) ;
271
+
284
272
// update position axes
285
273
updatePositionAxis ( gd , pa , sieve , overlap ) ;
286
274
}
@@ -370,6 +358,29 @@ function applyAttributes(sieve) {
370
358
}
371
359
372
360
361
+ function setBarCenter ( gd , pa , sieve ) {
362
+ var calcTraces = sieve . traces ,
363
+ pLetter = getAxisLetter ( pa ) ;
364
+
365
+ for ( var i = 0 ; i < calcTraces . length ; i ++ ) {
366
+ var calcTrace = calcTraces [ i ] ,
367
+ t = calcTrace [ 0 ] . t ,
368
+ poffset = t . poffset ,
369
+ poffsetIsArray = Array . isArray ( poffset ) ,
370
+ barwidth = t . barwidth ,
371
+ barwidthIsArray = Array . isArray ( barwidth ) ;
372
+
373
+ for ( var j = 0 ; j < calcTrace . length ; j ++ ) {
374
+ var calcBar = calcTrace [ j ] ;
375
+
376
+ calcBar [ pLetter ] = calcBar . p +
377
+ ( ( poffsetIsArray ) ? poffset [ j ] : poffset ) +
378
+ ( ( barwidthIsArray ) ? barwidth [ j ] : barwidth ) / 2 ;
379
+ }
380
+ }
381
+ }
382
+
383
+
373
384
function updatePositionAxis ( gd , pa , sieve , allowMinDtick ) {
374
385
var calcTraces = sieve . traces ,
375
386
distinctPositions = sieve . distinctPositions ,
0 commit comments