Skip to content

Commit

Permalink
Fix box chart empty condition
Browse files Browse the repository at this point in the history
  • Loading branch information
puranban committed Feb 22, 2024
1 parent 01b5dbc commit a24bb25
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/components/charts/BoxBarChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
sum,
getColorOnBgColor,
isDefined,
isNotDefined,
} from '@togglecorp/fujs';
import {
ContainerCard,
Expand Down Expand Up @@ -70,6 +71,9 @@ function BoxBarChart<
} = props;

const finalData = useMemo(() => {
if (isNotDefined(data) || data?.length <= 0) {
return [];
}
const itemsGroupedByRow = listToGroupList(
data ?? [],
rowSelector,
Expand Down Expand Up @@ -144,7 +148,7 @@ function BoxBarChart<
{isDefined(data) && (
<div className={styles.row}>
<div />
{columns.map((column) => (
{columns?.map((column) => (
<div
className={_cs(
styles.cell,
Expand All @@ -159,15 +163,15 @@ function BoxBarChart<
<div />
</div>
)}
{finalData.map((item) => (
{finalData?.map((item) => (
<div
key={item.rowLabel}
className={styles.row}
>
<div className={_cs(styles.cell, styles.label)}>
{item.rowLabel}
</div>
{item.columnsForRow.map((countItem, index) => {
{item.columnsForRow?.map((countItem, index) => {
const bgColor = getColorForValue(countItem);

return (
Expand Down

0 comments on commit a24bb25

Please sign in to comment.