diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a41b322e..aba349f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Not released - Use Material-UI createTheme instead of deprecated createMuiTheme [#187](https://github.com/CartoDB/carto-react/pull/187) +- Fix error formatting FormulaWidget (AVG) values with no features in current viewport [#186](https://github.com/CartoDB/carto-react/pull/186) - Add TimeSeriesWidget [#168](https://github.com/CartoDB/carto-react/pull/168) - Add NoDataAlert component [#188](https://github.com/CartoDB/carto-react/pull/188) and [#191](https://github.com/CartoDB/carto-react/pull/191) - Update echarts to v5 [#167](https://github.com/CartoDB/carto-react/pull/167) diff --git a/packages/react-core/src/operations/aggregation/values.js b/packages/react-core/src/operations/aggregation/values.js index cdcebe55e..8a7879f01 100644 --- a/packages/react-core/src/operations/aggregation/values.js +++ b/packages/react-core/src/operations/aggregation/values.js @@ -20,5 +20,5 @@ export const aggregationFunctions = { [AggregationTypes.MIN]: (values, key) => min(values, key), [AggregationTypes.MAX]: (values, key) => max(values, key), [AggregationTypes.SUM]: (values, key) => sum(values, key), - [AggregationTypes.AVG]: (values, key) => sum(values, key) / values.length + [AggregationTypes.AVG]: (values, key) => sum(values, key) / (values.length || 1) };