11import React from 'react' ;
22import { 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' ;
44import { useAppSelector } from '@app/hooks/reduxHooks' ;
55import { themeObject } from '@app/styles/themes/themeVariables' ;
66import { BASE_COLORS } from '@app/styles/themes/constants' ;
77import { useTranslation } from 'react-i18next' ;
8+ import { graphic } from 'echarts' ;
89
910interface 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