@@ -319,10 +319,34 @@ class Bar {
319
319
const graphics = new Graphics ( this . ctx )
320
320
321
321
if ( ! lineFill ) {
322
+ // if user provided a function in colors, we need to eval here
323
+ // Note: the position of this function logic (ex. stroke: { colors: ["",function(){}] }) i.e array index 1 depicts the realIndex/seriesIndex.
324
+ function fetchColor ( i ) {
325
+ const exp = w . config . stroke . colors
326
+ let c
327
+ if ( Array . isArray ( exp ) && exp . length > 0 ) {
328
+ c = exp [ i ]
329
+ if ( ! c ) c = ''
330
+ if ( typeof c === 'function' ) {
331
+ return c ( {
332
+ value : w . globals . series [ i ] [ j ] ,
333
+ dataPointIndex : j ,
334
+ w,
335
+ } )
336
+ }
337
+ }
338
+ return c
339
+ }
340
+
341
+ const checkAvailableColor =
342
+ typeof w . globals . stroke . colors [ realIndex ] === 'function'
343
+ ? fetchColor ( realIndex )
344
+ : w . globals . stroke . colors [ realIndex ]
345
+
322
346
/* fix apexcharts#341 */
323
347
lineFill = this . barOptions . distributed
324
348
? w . globals . stroke . colors [ j ]
325
- : w . globals . stroke . colors [ realIndex ]
349
+ : checkAvailableColor
326
350
}
327
351
328
352
if ( w . config . series [ i ] . data [ j ] && w . config . series [ i ] . data [ j ] . strokeColor ) {
@@ -545,7 +569,11 @@ class Bar {
545
569
}
546
570
}
547
571
548
- y = this . barHelpers . getYForValue ( this . series [ i ] [ j ] , zeroH , translationsIndex )
572
+ y = this . barHelpers . getYForValue (
573
+ this . series [ i ] [ j ] ,
574
+ zeroH ,
575
+ translationsIndex
576
+ )
549
577
550
578
const paths = this . barHelpers . getColumnPaths ( {
551
579
barXPosition,
@@ -578,7 +606,14 @@ class Bar {
578
606
pathFrom : paths . pathFrom ,
579
607
x,
580
608
y,
581
- goalY : this . barHelpers . getGoalValues ( 'y' , null , zeroH , i , j , translationsIndex ) ,
609
+ goalY : this . barHelpers . getGoalValues (
610
+ 'y' ,
611
+ null ,
612
+ zeroH ,
613
+ i ,
614
+ j ,
615
+ translationsIndex
616
+ ) ,
582
617
barXPosition,
583
618
barWidth,
584
619
}
0 commit comments