Skip to content

The Open Standard for Generative UI

add isAnimationActive prop to chart component (#35)

Aditya-thesys3d63d216683f
diff --git a/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx b/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx
index e083b6965..914f7d93e 100644
--- a/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/AreaChart/AreaChart.tsx
@@ -26,6 +26,7 @@ export interface AreaChartProps<T extends AreaChartData> {
height?: number;
opacity?: number;
icons?: Partial<Record<keyof T[number], React.ComponentType>>;
+ isAnimationActive?: boolean;
}
export const AreaChart = <T extends AreaChartData>({
@@ -40,6 +41,7 @@ export const AreaChart = <T extends AreaChartData>({
height = 400,
opacity = 0.5,
icons = {},
+ isAnimationActive = true,
}: AreaChartProps<T>) => {
// excluding the categoryKey
const dataKeys = Object.keys(data[0] || {}).filter((key) => key !== categoryKey);
@@ -111,6 +113,7 @@ export const AreaChart = <T extends AreaChartData>({
activeDot={{
r: 6,
}}
+ isAnimationActive={isAnimationActive}
>
{label && (
<LabelList
@@ -138,6 +141,7 @@ export const AreaChart = <T extends AreaChartData>({
activeDot={{
r: 6,
}}
+ isAnimationActive={isAnimationActive}
/>
);
})}
diff --git a/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx b/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx
index d3a590adb..72d86277e 100644
--- a/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/BarChart/BarChart.tsx
@@ -26,6 +26,7 @@ export interface BarChartProps<T extends BarChartData> {
height?: number;
radius?: number;
icons?: Partial<Record<keyof T[number], React.ComponentType>>;
+ isAnimationActive?: boolean;
}
export const BarChart = <T extends BarChartData>({
@@ -40,6 +41,7 @@ export const BarChart = <T extends BarChartData>({
height = 400,
icons = {},
radius = 4,
+ isAnimationActive = true,
}: BarChartProps<T>) => {
// excluding the categoryKey
const dataKeys = Object.keys(data[0] || {}).filter((key) => key !== categoryKey);
@@ -101,6 +103,7 @@ export const BarChart = <T extends BarChartData>({
fill={color}
radius={radius}
stackId={variant === "stacked" ? "a" : undefined}
+ isAnimationActive={isAnimationActive}
>
{label && (
<LabelList
@@ -120,6 +123,7 @@ export const BarChart = <T extends BarChartData>({
fill={color}
radius={radius}
stackId={variant === "stacked" ? "a" : undefined}
+ isAnimationActive={isAnimationActive}
/>
);
})}
diff --git a/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx b/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx
index 36c5616bf..d731799d4 100644
--- a/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/LineChart/LineChart.tsx
@@ -26,6 +26,7 @@ export interface LineChartProps<T extends LineChartData> {
height?: number;
strokeWidth?: number;
icons?: Partial<Record<keyof T[number], React.ComponentType>>;
+ isAnimationActive?: boolean;
}
export const LineChart = <T extends LineChartData>({
@@ -40,6 +41,7 @@ export const LineChart = <T extends LineChartData>({
height = 400,
strokeWidth = 2,
icons = {},
+ isAnimationActive = true,
}: LineChartProps<T>) => {
// excluding the categoryKey
const dataKeys = Object.keys(data[0] || {}).filter((key) => key !== categoryKey);
@@ -109,6 +111,7 @@ export const LineChart = <T extends LineChartData>({
activeDot={{
r: 6,
}}
+ isAnimationActive={isAnimationActive}
>
{label && (
<LabelList
@@ -132,6 +135,7 @@ export const LineChart = <T extends LineChartData>({
dot={{
fill: color,
}}
+ isAnimationActive={isAnimationActive}
/>
);
})}
diff --git a/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx b/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx
index 6801e970f..77d4b51c8 100644
--- a/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/PieChart/PieChart.tsx
@@ -26,6 +26,7 @@ export interface PieChartProps<T extends PieChartData> {
label?: boolean;
width?: number;
height?: number;
+ isAnimationActive?: boolean;
}
const layoutMap: Record<string, string> = {
@@ -54,6 +55,7 @@ export const PieChart = <T extends PieChartData>({
label = true,
width = 800,
height = 400,
+ isAnimationActive = true,
}: PieChartProps<T>) => {
const { layout } = useLayoutContext();
const [calculatedOuterRadius, setCalculatedOuterRadius] = useState(120);
@@ -165,6 +167,7 @@ export const PieChart = <T extends PieChartData>({
outerRadius={calculatedOuterRadius}
innerRadius={calculatedInnerRadius}
label={label ? renderCustomLabel : false}
+ isAnimationActive={isAnimationActive}
>
{Object.entries(chartConfig).map(([key, config]) => (
<Cell key={key} fill={config.color} />
diff --git a/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx b/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx
index 15d105aac..a03958d34 100644
--- a/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/RadarChart/RadarChart.tsx
@@ -25,6 +25,7 @@ export interface RadarChartProps<T extends RadarChartData> {
strokeWidth?: number;
areaOpacity?: number;
icons?: Partial<Record<keyof T[number], React.ComponentType>>;
+ isAnimationActive?: boolean;
}
export const RadarChart = <T extends RadarChartData>({
@@ -39,6 +40,7 @@ export const RadarChart = <T extends RadarChartData>({
strokeWidth = 2,
areaOpacity = 0.5,
icons = {},
+ isAnimationActive = true,
}: RadarChartProps<T>) => {
// excluding the categoryKey
const dataKeys = Object.keys(data[0] || {}).filter((key) => key !== categoryKey);
@@ -83,10 +85,19 @@ export const RadarChart = <T extends RadarChartData>({
fillOpacity={0}
stroke={color}
strokeWidth={strokeWidth}
+ isAnimationActive={isAnimationActive}
/>
);
} else {
- return <Radar key={key} dataKey={key} fill={color} fillOpacity={areaOpacity} />;
+ return (
+ <Radar
+ key={key}
+ dataKey={key}
+ fill={color}
+ fillOpacity={areaOpacity}
+ isAnimationActive={isAnimationActive}
+ />
+ );
}
})}
diff --git a/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx b/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx
index 1b9d99407..da05b2b89 100644
--- a/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/RadialChart/RadialChart.tsx
@@ -27,6 +27,7 @@ export interface RadialChartProps<T extends RadialChartData> {
grid?: boolean;
width?: number;
height?: number;
+ isAnimationActive?: boolean;
}
const layoutMap: Record<string, string> = {
@@ -54,6 +55,7 @@ export const RadialChart = <T extends RadialChartData>({
grid = true,
width = 800,
height = 400,
+ isAnimationActive = true,
}: RadialChartProps<T>) => {
const { layout } = useLayoutContext();
const [calculatedOuterRadius, setCalculatedOuterRadius] = useState(110);
@@ -175,6 +177,7 @@ export const RadialChart = <T extends RadialChartData>({
dataKey={format === "percentage" ? "percentage" : String(dataKey)}
background={!grid}
cornerRadius={10}
+ isAnimationActive={isAnimationActive}
>
{Object.entries(chartConfig).map(([key, config]) => (
<Cell key={key} fill={config.color} />