Skip to content

Commit

Permalink
Fix HistogramWidget with one non-zero bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
zbigg committed Sep 11, 2024
1 parent 04b9491 commit 6c97ebb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Not released

- Fix HistogramWidget with one non-zero bucket [#901](https://github.com/CartoDB/carto-react/pull/901)
- Spatial Index Sources use remote widgets calculation [#898](https://github.com/CartoDB/carto-react/pull/898)
- Support for `hiddenColumnFields` parameter and `onRowClick` handler for Table Widget [#900](https://github.com/CartoDB/carto-react/pull/900)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ function HistogramWidgetUI({
// Series
const seriesOptions = useMemo(() => {
// We check if we have just one different value
const isUniqueDataRow = formattedData.filter((row) => row[2] !== 0).length === 1;
const isUniqueDataRow =
min === max && formattedData.filter((row) => row[2] !== 0).length === 1;

const data = isUniqueDataRow
? [formattedData[0], formattedData[formattedData.length - 1]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,22 @@ const LoadingProps = {
isLoading: true
};
Loading.args = LoadingProps;

export const OneNonZeroBinMid = LoadingTemplate.bind({});
OneNonZeroBinMid.args = {
...defaultProps,
data: [0, 300, 0, 0, 0, 0, 0]
};

export const OneNonZeroBinStart = LoadingTemplate.bind({});
OneNonZeroBinStart.args = {
...defaultProps,
data: [100, 0, 0, 0, 0, 0, 0]
};


export const OneNonZeroBinEnd = LoadingTemplate.bind({});
OneNonZeroBinEnd.args = {
...defaultProps,
data: [0, 0, 0, 0, 0, 0, 100]
};

0 comments on commit 6c97ebb

Please sign in to comment.