Skip to content

Commit

Permalink
feat(DW): gray donuts for empty data top-consuming charts
Browse files Browse the repository at this point in the history
Signed-off-by: gitdallas <[email protected]>

feat(dw): add emptystate for statusoverview chart

Signed-off-by: gitdallas <[email protected]>

lint fixes

Signed-off-by: gitdallas <[email protected]>
  • Loading branch information
gitdallas committed Apr 10, 2024
1 parent aceb751 commit a4c94b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,20 @@ const TopResourceConsumingWorkloadsChart: React.FC<TopResourceConsumingWorkloads
<ChartDonut
ariaTitle={`${metricLabel} chart`}
constrainToVisibleArea
data={data.topWorkloads.map(({ workload, usage }) => ({
x: getWorkloadName(workload),
y: roundNumber(convertUnits(usage), 3),
}))}
data={
data.topWorkloads.length
? data.topWorkloads.map(({ workload, usage }) => ({
x: getWorkloadName(workload),
y: roundNumber(convertUnits(usage), 3),
}))
: [{ x: `No workload is consuming ${unitLabel}`, y: 1 }]
}
height={150}
labels={({ datum }) => `${datum.x}: ${datum.y} ${unitLabel}`}
labels={
data.topWorkloads.length
? ({ datum }) => `${datum.x}: ${datum.y} ${unitLabel}`
: ({ datum }) => datum.x
}
legendComponent={
<ChartLegend
data={data.topWorkloads.map(({ workload }) => ({
Expand All @@ -57,7 +65,7 @@ const TopResourceConsumingWorkloadsChart: React.FC<TopResourceConsumingWorkloads
}}
subTitle={unitLabel}
title={String(roundNumber(convertUnits(data.totalUsage)))}
themeColor={ChartThemeColor.multi}
themeColor={data.topWorkloads.length ? ChartThemeColor.multi : ChartThemeColor.gray}
width={375}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getStatusCounts,
} from '~/concepts/distributedWorkloads/utils';
import { LoadingState } from '~/pages/distributedWorkloads/components/LoadingState';
import { NoWorkloadState } from '~/pages/distributedWorkloads/components/NoWorkloadState';

export const DWStatusOverviewDonutChart: React.FC = () => {
const { workloads } = React.useContext(DistributedWorkloadsContext);
Expand All @@ -32,6 +33,11 @@ export const DWStatusOverviewDonutChart: React.FC = () => {
(statusType) => statusCounts[statusType] > 0,
);

if (workloads.data.length) {
return (
<NoWorkloadState subTitle="Select another project or create a distributed workload in the selected project." />
);
}
return (
<ChartDonut
ariaDesc="Distributed workload status overview"
Expand Down

0 comments on commit a4c94b0

Please sign in to comment.