Skip to content

Commit 3891437

Browse files
authored
feat(RadialChart): introduce loading & loadingDelay props (#6028)
1 parent 71fcb40 commit 3891437

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/charts/src/components/RadialChart/RadialChart.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { CSSProperties } from 'react';
66
import { forwardRef } from 'react';
77
import { PolarAngleAxis, RadialBar, RadialBarChart } from 'recharts';
88
import { useOnClickInternal } from '../../hooks/useOnClickInternal.js';
9+
import type { IChartBaseProps } from '../../interfaces/IChartBaseProps.js';
910
import { ChartContainer } from '../../internal/ChartContainer.js';
1011
import { PieChartPlaceholder } from '../PieChart/Placeholder.js';
1112

@@ -17,8 +18,9 @@ interface RadialChartConfig {
1718

1819
[rest: string]: any;
1920
}
20-
//todo expose `loading`
21-
export interface RadialChartProps extends Omit<CommonProps, 'onClick' | 'children' | 'onLegendClick'> {
21+
export interface RadialChartProps
22+
extends Omit<CommonProps, 'onClick' | 'children' | 'onLegendClick'>,
23+
Pick<IChartBaseProps, 'loading' | 'loadingDelay'> {
2224
/**
2325
* The actual value which defines how much the ring is filled.
2426
*/
@@ -92,6 +94,8 @@ const defaultDisplayValueStyles = {
9294
*/
9395
const RadialChart = forwardRef<HTMLDivElement, RadialChartProps>((props, ref) => {
9496
const {
97+
loading,
98+
loadingDelay,
9599
maxValue = 100,
96100
value,
97101
displayValue,
@@ -108,7 +112,7 @@ const RadialChart = forwardRef<HTMLDivElement, RadialChartProps>((props, ref) =>
108112
} = props;
109113

110114
const range = [0, maxValue];
111-
const dataset = [{ value }];
115+
const dataset = typeof value === 'number' ? [{ value }] : [];
112116

113117
const onDataPointClickInternal = (payload, i, event) => {
114118
if (payload && onDataPointClick) {
@@ -126,8 +130,8 @@ const RadialChart = forwardRef<HTMLDivElement, RadialChartProps>((props, ref) =>
126130

127131
return (
128132
<ChartContainer
129-
loading={undefined}
130-
loadingDelay={undefined}
133+
loading={loading}
134+
loadingDelay={loadingDelay}
131135
dataset={dataset}
132136
ref={ref}
133137
Placeholder={PieChartPlaceholder}

0 commit comments

Comments
 (0)