diff --git a/CHANGELOG.md b/CHANGELOG.md index 7747c73fb..3f19f2c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Migrate multiples components from storybook away from makeStyles [#652](https://github.com/CartoDB/carto-react/pull/652) - Remove makeStyles leftovers [#669](https://github.com/CartoDB/carto-react/pull/669) - FormulaWidgetUI component migrated from makeStyles to styled-components + cleanup [#666](https://github.com/CartoDB/carto-react/pull/666) +- Fix histogram widget filter for max/min values [#671](https://github.com/CartoDB/carto-react/pull/671) ## 2.0 diff --git a/packages/react-widgets/src/widgets/HistogramWidget.js b/packages/react-widgets/src/widgets/HistogramWidget.js index 3ecd7aacf..b1952d130 100644 --- a/packages/react-widgets/src/widgets/HistogramWidget.js +++ b/packages/react-widgets/src/widgets/HistogramWidget.js @@ -119,7 +119,7 @@ function HistogramWidget({ dataSource, id, column, - type: FilterTypes.CLOSED_OPEN + type: FilterTypes.BETWEEN }); const selectedBars = useMemo(() => { @@ -131,7 +131,7 @@ function HistogramWidget({ return ticks.length; } else { const idx = ticks.indexOf(from); - return idx !== -1 ? idx + 1 : null; + return idx !== -1 ? idx + 1 : 0; } }) .filter((v) => v !== null); @@ -141,8 +141,8 @@ function HistogramWidget({ (selectedBars) => { if (selectedBars?.length) { const thresholds = selectedBars.map((i) => { - let left = ticks[i - 1]; - let right = ticks.length !== i ? ticks[i] : undefined; + let left = ticks[i - 1] || min; + let right = ticks.length !== i ? ticks[i] : max; return [left, right]; }); @@ -150,7 +150,7 @@ function HistogramWidget({ addFilter({ id: dataSource, column, - type: FilterTypes.CLOSED_OPEN, + type: FilterTypes.BETWEEN, values: thresholds, owner: id }) @@ -165,7 +165,7 @@ function HistogramWidget({ ); } }, - [column, dataSource, id, dispatch, ticks] + [column, dataSource, id, dispatch, ticks, min, max] ); return (