diff --git a/src/components/PivotTable/PivotTableValueCell.js b/src/components/PivotTable/PivotTableValueCell.js index 9013a0a83..78d204f2c 100644 --- a/src/components/PivotTable/PivotTableValueCell.js +++ b/src/components/PivotTable/PivotTableValueCell.js @@ -2,7 +2,10 @@ import PropTypes from 'prop-types' import React, { useRef } from 'react' import { applyLegendSet } from '../../modules/pivotTable/applyLegendSet.js' import { CELL_TYPE_VALUE } from '../../modules/pivotTable/pivotTableConstants.js' -import { VALUE_TYPE_NUMBER } from '../../modules/valueTypes.js' +import { + isNumericValueType, + isBooleanValueType, +} from '../../modules/valueTypes.js' import { PivotTableCell } from './PivotTableCell.js' import { PivotTableEmptyCell } from './PivotTableEmptyCell.js' import { usePivotTableEngine } from './PivotTableEngineContext.js' @@ -43,10 +46,10 @@ export const PivotTableValueCell = ({ ) } - // TODO: Add support for 'INTEGER' type (requires server changes) const legendStyle = cellContent.cellType === CELL_TYPE_VALUE && - cellContent.valueType === VALUE_TYPE_NUMBER + (isNumericValueType(cellContent.valueType) || + isBooleanValueType(cellContent.valueType)) ? applyLegendSet( cellContent.rawValue, cellContent.dxDimension, diff --git a/src/modules/renderValue.js b/src/modules/renderValue.js index a65d8a6d8..5e87629f1 100644 --- a/src/modules/renderValue.js +++ b/src/modules/renderValue.js @@ -2,7 +2,7 @@ import { NUMBER_TYPE_ROW_PERCENTAGE, NUMBER_TYPE_COLUMN_PERCENTAGE, } from './pivotTable/pivotTableConstants.js' -import { isNumericValueType } from './valueTypes.js' +import { isNumericValueType, isBooleanValueType } from './valueTypes.js' const trimTrailingZeros = (stringValue) => stringValue.replace(/\.?0+$/, '') @@ -53,7 +53,10 @@ const toFixedPrecisionString = (value, skipRounding) => { } export const renderValue = (value, valueType, visualization) => { - if (!isNumericValueType(valueType) || value === undefined) { + if ( + !(isNumericValueType(valueType) || isBooleanValueType(valueType)) || + value === undefined + ) { return String(value).replace(/[^\S\n]+/, ' ') } diff --git a/src/modules/valueTypes.js b/src/modules/valueTypes.js index cf5dc01f0..69b7f76b1 100644 --- a/src/modules/valueTypes.js +++ b/src/modules/valueTypes.js @@ -34,4 +34,7 @@ const NUMERIC_VALUE_TYPES = [ VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE, ] +const BOOLEAN_VALUE_TYPES = [VALUE_TYPE_BOOLEAN, VALUE_TYPE_TRUE_ONLY] + export const isNumericValueType = (type) => NUMERIC_VALUE_TYPES.includes(type) +export const isBooleanValueType = (type) => BOOLEAN_VALUE_TYPES.includes(type) \ No newline at end of file