File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,20 +147,7 @@ class DataBarCellRenderer extends CellRenderer {
147147
148148 context . save ( ) ;
149149 context . textAlign = textAlign ;
150-
151- // Use explicit text color if set.
152- // Otherwise, fall back to the databar color for text.
153- if ( textColor != null ) {
154- context . fillStyle = textColor ;
155- } else if ( hasGradient ) {
156- const color =
157- value >= 0 ? dataBarColor [ dataBarColor . length - 1 ] : dataBarColor [ 0 ] ;
158- context . fillStyle = color ;
159- } else {
160- context . fillStyle = Array . isArray ( dataBarColor )
161- ? dataBarColor [ 0 ]
162- : dataBarColor ;
163- }
150+ context . fillStyle = textColor ;
164151 context . textBaseline = 'middle' ;
165152 context . font = theme . font ;
166153
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ export interface DataBarOptions {
3535 columnMax : number ;
3636 axis : AxisOption ;
3737 color : GridColor | GridColor [ ] ;
38- textColor ? : GridColor ;
38+ textColor : GridColor ;
3939 valuePlacement : ValuePlacementOption ;
4040 opacity : number ;
4141 markers : Marker [ ] ;
Original file line number Diff line number Diff line change @@ -143,11 +143,23 @@ class MockDataBarGridModel extends GridModel implements DataBarGridModel {
143143 const color = value >= 0 ? positiveColor : negativeColor ;
144144 const markers = this . markers . get ( column ) ?? [ ] ;
145145
146+ const hasGradient = Array . isArray ( color ) && color . length > 1 ;
147+ let textColor : string ;
148+ if ( hasGradient ) {
149+ textColor = value >= 0 ? color [ color . length - 1 ] : color [ 0 ] ;
150+ } else if ( Array . isArray ( color ) ) {
151+ const [ first ] = color ;
152+ textColor = first ;
153+ } else {
154+ textColor = color ;
155+ }
156+
146157 return {
147158 columnMin,
148159 columnMax,
149160 axis,
150161 color,
162+ textColor,
151163 valuePlacement,
152164 opacity,
153165 markers,
You can’t perform that action at this time.
0 commit comments