Skip to content

Commit 19a9813

Browse files
committed
Update UI components: Fix TypeScript errors and improve chart animations
1 parent b5f479e commit 19a9813

2 files changed

Lines changed: 71 additions & 20 deletions

File tree

src/components/charts/BarAnimationDelayChart/BarAnimationDelayChart.tsx

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { BaseCard } from '@app/components/common/BaseCard/BaseCard';
4-
import { BaseChart } from '@app/components/common/charts/BaseChart';
4+
import { BaseChart, getDefaultTooltipStyles } from '@app/components/common/charts/BaseChart';
55
import { useAppSelector } from '@app/hooks/reduxHooks';
66
import { themeObject } from '@app/styles/themes/themeVariables';
77
import useBarChartData from '@app/hooks/useBarChartData';
88
import { useResponsive } from '@app/hooks/useResponsive';
9+
import { graphic } from 'echarts';
910

1011
// Helper function to get the last six months from the current date
1112
const getLastSixMonths = () => {
@@ -88,9 +89,10 @@ export const BarAnimationDelayChart: React.FC = () => {
8889
containLabel: true,
8990
},
9091
tooltip: {
92+
...getDefaultTooltipStyles(themeObject[theme]),
9193
trigger: 'axis',
9294
formatter: function (params: any[]) {
93-
return params.map((param) => `${param.seriesName}: ${param.data} GB`).join('<br/>');
95+
return params.map((param) => `${param.seriesName}: ${param.data.toFixed(3)} GB`).join('<br/>');
9496
},
9597
},
9698
xAxis: {
@@ -126,25 +128,51 @@ export const BarAnimationDelayChart: React.FC = () => {
126128
name: t('charts.notes'),
127129
type: 'bar',
128130
data: data1,
129-
color: themeObject[theme].chartColor2,
131+
barMaxWidth: 40,
132+
itemStyle: {
133+
borderRadius: 7,
134+
color: new graphic.LinearGradient(0, 0, 0, 1, [
135+
{
136+
offset: 0,
137+
color: 'rgba(51, 156, 253, 0.7)',
138+
},
139+
{
140+
offset: 1,
141+
color: 'rgba(51, 156, 253, 0.15)',
142+
},
143+
]),
144+
},
130145
legendHoverLink: isDesktop ? true : false,
131146
emphasis: {
132147
disable: true,
133148
},
134-
barGap: '-10%', // Slightly overlap bars
149+
barGap: '10%',
135150
barCategoryGap: '30%',
136151
animationDelay: (idx: number) => idx * 10,
137152
},
138153
{
139154
name: t('charts.media'),
140155
type: 'bar',
141156
data: data2,
142-
color: themeObject[theme].chartColor3,
157+
barMaxWidth: 40,
158+
itemStyle: {
159+
borderRadius: 7,
160+
color: new graphic.LinearGradient(0, 0, 0, 1, [
161+
{
162+
offset: 0,
163+
color: 'rgba(253, 156, 51, 0.7)',
164+
},
165+
{
166+
offset: 1,
167+
color: 'rgba(253, 156, 51, 0.15)',
168+
},
169+
]),
170+
},
143171
emphasis: {
144172
disable: true,
145173
},
146174
legendHoverLink: isDesktop ? true : false,
147-
barGap: '-10%', // Slightly overlap bars
175+
barGap: '10%',
148176
barCategoryGap: '30%',
149177
animationDelay: (idx: number) => idx * 10 + 100,
150178
},

src/components/common/charts/PieChart.tsx

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
22
import { EChartsOption } from 'echarts-for-react';
3-
import { BaseChart, BaseChartProps } from '@app/components/common/charts/BaseChart';
3+
import { BaseChart, BaseChartProps, getDefaultTooltipStyles } from '@app/components/common/charts/BaseChart';
44
import { useAppSelector } from '@app/hooks/reduxHooks';
55
import { themeObject } from '@app/styles/themes/themeVariables';
66
import { BASE_COLORS } from '@app/styles/themes/constants';
77
import { useTranslation } from 'react-i18next';
8+
import { graphic } from 'echarts';
89

910
interface PieChartProps extends BaseChartProps {
1011
option?: EChartsOption;
@@ -35,14 +36,27 @@ export const PieChart: React.FC<PieChartProps> = ({ option, data, name, showLege
3536

3637
const logTransformedData = applyLogTransform(data);
3738

38-
// Define a set of colors for the pie chart
39-
const colors: Record<DataCategory, string> = {
40-
kinds: '#8e30eb', // Purple
41-
photos: '#F7931A', // Satoshi Orange
42-
videos: '#2196f3', // Blue
43-
gitNestr: '#19E68D', // Cyan
44-
audio: '#E94B2F', // Red
45-
misc: '#F5D149', // Yellow
39+
// Define gradient colors for the pie chart with liquid glass theme
40+
const getGradientColor = (color1: string, color2: string) => {
41+
return new graphic.LinearGradient(0, 0, 1, 1, [
42+
{
43+
offset: 0,
44+
color: color1,
45+
},
46+
{
47+
offset: 1,
48+
color: color2,
49+
},
50+
]);
51+
};
52+
53+
const colors: Record<DataCategory, any> = {
54+
kinds: getGradientColor('rgba(142, 48, 235, 0.9)', 'rgba(142, 48, 235, 0.4)'), // Purple gradient
55+
photos: getGradientColor('rgba(247, 147, 26, 0.9)', 'rgba(247, 147, 26, 0.4)'), // Orange gradient
56+
videos: getGradientColor('rgba(33, 150, 243, 0.9)', 'rgba(33, 150, 243, 0.4)'), // Blue gradient
57+
gitNestr: getGradientColor('rgba(25, 230, 141, 0.9)', 'rgba(25, 230, 141, 0.4)'), // Cyan gradient
58+
audio: getGradientColor('rgba(233, 75, 47, 0.9)', 'rgba(233, 75, 47, 0.4)'), // Red gradient
59+
misc: getGradientColor('rgba(245, 209, 73, 0.9)', 'rgba(245, 209, 73, 0.4)'), // Yellow gradient
4660
};
4761

4862
// Map translated names to DataCategory keys
@@ -57,8 +71,9 @@ export const PieChart: React.FC<PieChartProps> = ({ option, data, name, showLege
5771

5872
const defaultPieOption = {
5973
tooltip: {
74+
...getDefaultTooltipStyles(themeObject[theme]),
6075
trigger: 'item',
61-
formatter: (params: any) => `${params.name}: ${params.data.originalValue} (${params.percent}%)`,
76+
formatter: (params: any) => `${params.name}: ${params.data.originalValue.toFixed(3)} GB (${params.percent}%)`,
6277
},
6378
legend: {
6479
show: showLegend,
@@ -77,24 +92,32 @@ export const PieChart: React.FC<PieChartProps> = ({ option, data, name, showLege
7792
radius: ['100%', '70%'], // Donut chart effect
7893
avoidLabelOverlap: false,
7994
itemStyle: {
80-
borderRadius: 5,
81-
borderColor: BASE_COLORS.white,
95+
borderRadius: 10,
96+
borderColor: 'rgba(255, 255, 255, 0.2)',
8297
borderWidth: 2,
98+
shadowBlur: 15,
99+
shadowColor: 'rgba(0, 255, 255, 0.3)',
100+
shadowOffsetX: 0,
101+
shadowOffsetY: 0,
83102
},
84103
label: {
85104
show: false,
86105
},
87106
emphasis: {
88107
itemStyle: {
89-
shadowBlur: 10,
108+
shadowBlur: 25,
90109
shadowOffsetX: 0,
91-
shadowColor: 'rgba(0, 0, 0, 0.5)',
110+
shadowColor: 'rgba(0, 255, 255, 0.5)',
111+
borderWidth: 3,
112+
borderColor: 'rgba(255, 255, 255, 0.8)',
92113
},
93114
label: {
94115
show: true,
95116
fontSize: '18',
96117
fontWeight: 'bold',
97118
color: themeObject[theme].textMain,
119+
textShadowBlur: 3,
120+
textShadowColor: 'rgba(0, 0, 0, 0.8)',
98121
},
99122
},
100123
labelLine: {

0 commit comments

Comments
 (0)