Skip to content

Commit 502c37f

Browse files
committed
Enable chart animations
1 parent ec91581 commit 502c37f

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

src/components/ChartContainer.jsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ const ChartWrapper = ({ data, options, chartId, onRegisterChart, onSyncHover })
5454
}, [onSyncHover, chartId]);
5555

5656
return (
57-
<div onMouseLeave={handleContainerMouseLeave} style={{ width: '100%', height: '100%' }}>
57+
<div
58+
onMouseLeave={handleContainerMouseLeave}
59+
style={{ width: '100%', height: '100%' }}
60+
className="fade-slide-in"
61+
>
5862
<Line ref={handleChartRef} data={data} options={enhancedOptions} />
5963
</div>
6064
);
@@ -196,8 +200,10 @@ export default function ChartContainer({
196200
pointHoverBackgroundColor: color,
197201
pointHoverBorderColor: color,
198202
pointHoverBorderWidth: 1,
199-
animation: false,
200-
animations: { colors: false, x: false, y: false },
203+
animation: {
204+
duration: 500,
205+
easing: 'easeOutQuart'
206+
},
201207
};
202208
})
203209
});
@@ -253,10 +259,10 @@ export default function ChartContainer({
253259
const chartOptions = useMemo(() => ({
254260
responsive: true,
255261
maintainAspectRatio: false,
256-
animation: { duration: 0 },
257-
animations: { colors: false, x: false, y: false },
258-
hover: { animationDuration: 0 },
259-
responsiveAnimationDuration: 0,
262+
animation: {
263+
duration: 500,
264+
easing: 'easeOutQuart'
265+
},
260266
interaction: { mode: 'index', intersect: false },
261267
plugins: {
262268
zoom: {
@@ -308,7 +314,6 @@ export default function ChartContainer({
308314
tooltip: {
309315
mode: 'index',
310316
intersect: false,
311-
animation: false,
312317
backgroundColor: 'rgba(15, 23, 42, 0.92)',
313318
titleColor: '#f1f5f9',
314319
bodyColor: '#cbd5e1',
@@ -392,8 +397,10 @@ export default function ChartContainer({
392397
pointHoverBackgroundColor: '#dc2626',
393398
pointHoverBorderColor: '#dc2626',
394399
pointHoverBorderWidth: 1,
395-
animation: false,
396-
animations: { colors: false, x: false, y: false },
400+
animation: {
401+
duration: 500,
402+
easing: 'easeOutQuart'
403+
},
397404
},
398405
];
399406
if (baseline > 0 && (compareMode === 'relative' || compareMode === 'absolute')) {
@@ -415,8 +422,10 @@ export default function ChartContainer({
415422
pointHoverBackgroundColor: '#10b981',
416423
pointHoverBorderColor: '#10b981',
417424
pointHoverBorderWidth: 1,
418-
animation: false,
419-
animations: { colors: false, x: false, y: false },
425+
animation: {
426+
duration: 500,
427+
easing: 'easeOutQuart'
428+
},
420429
});
421430
}
422431
return { datasets };

0 commit comments

Comments
 (0)