@@ -7,6 +7,7 @@ import type {
7
7
} from '../../../../../../../../shared' ;
8
8
import {
9
9
ApiV2Annotations ,
10
+ GradientNullModes ,
10
11
PseudoFieldTitle ,
11
12
getFakeTitleOrTitle ,
12
13
} from '../../../../../../../../shared' ;
@@ -231,8 +232,19 @@ export const prepareBackgroundColorSettings = (args: PrepareBackgroundColorSetti
231
232
const fieldColorValues = Array . from ( colorValues ) ;
232
233
233
234
continuousColorsByField [ guid ] = { } ;
235
+ const nilValue =
236
+ backgroundSettings . settings . gradientState . nullMode === GradientNullModes . AsZero
237
+ ? 0
238
+ : null ;
239
+
240
+ const colorValuesWithoutNull = fieldColorValues . reduce < number [ ] > ( ( acc , cv ) => {
241
+ const colorValue = cv === null ? nilValue : cv ;
242
+ if ( colorValue !== null ) {
243
+ acc . push ( Number ( colorValue ) ) ;
244
+ }
234
245
235
- const colorValuesWithoutNull = fieldColorValues . filter ( ( cv ) : cv is number => cv !== null ) ;
246
+ return acc ;
247
+ } , [ ] ) ;
236
248
237
249
const min = Math . min ( ...colorValuesWithoutNull ) ;
238
250
const max = Math . max ( ...colorValuesWithoutNull ) ;
@@ -250,12 +262,15 @@ export const prepareBackgroundColorSettings = (args: PrepareBackgroundColorSetti
250
262
251
263
fieldColorValues . forEach ( ( value ) => {
252
264
const colorValue = getContinuousColorValue ( value ) ;
253
- if ( colorValue === null ) {
265
+ if (
266
+ colorValue === null &&
267
+ backgroundSettings . settings . gradientState . nullMode !== GradientNullModes . AsZero
268
+ ) {
254
269
return ;
255
270
}
256
271
257
272
const color = colorizePivotTableCell ( colorValue , chartColorsConfig , [ min , max ] ) ;
258
- continuousColorsByField [ guid ] [ String ( value ) ] = color ?. backgroundColor || null ;
273
+ continuousColorsByField [ guid ] [ String ( colorValue ) ] = color ?. backgroundColor || null ;
259
274
} ) ;
260
275
} ) ;
261
276
@@ -317,7 +332,10 @@ export const colorizePivotTableByFieldBackgroundSettings = (
317
332
const { settings, colorFieldGuid} = backgroundColorSettings ;
318
333
const colorKey = cell . colorKey ;
319
334
320
- if ( ! colorKey ) {
335
+ if (
336
+ ! colorKey &&
337
+ backgroundColorSettings . settings . gradientState . nullMode !== GradientNullModes . AsZero
338
+ ) {
321
339
continue ;
322
340
}
323
341
0 commit comments