@agions/taroviz 1.11.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +245 -0
- package/README.md +104 -302
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/vendors.js +1 -0
- package/dist/cjs/vendors~echarts.js +1 -0
- package/dist/esm/index.js +1 -58151
- package/dist/esm/vendors.js +1 -0
- package/dist/esm/vendors~echarts.js +1 -0
- package/package.json +19 -25
- package/src/adapters/MiniAppAdapter.ts +136 -0
- package/src/adapters/__tests__/index.test.ts +1 -1
- package/src/adapters/h5/__tests__/index.test.ts +4 -2
- package/src/adapters/h5/index.ts +63 -64
- package/src/adapters/harmony/index.ts +23 -245
- package/src/adapters/index.ts +49 -45
- package/src/adapters/swan/index.ts +6 -69
- package/src/adapters/tt/index.ts +7 -70
- package/src/adapters/types.ts +25 -58
- package/src/adapters/weapp/index.ts +6 -69
- package/src/charts/__tests__/testUtils.tsx +87 -0
- package/src/charts/boxplot/__tests__/index.test.tsx +49 -103
- package/src/charts/boxplot/index.tsx +2 -1
- package/src/charts/boxplot/types.ts +17 -16
- package/src/charts/common/BaseChartWrapper.tsx +90 -82
- package/src/charts/common/__mocks__/BaseChartWrapper.tsx +17 -0
- package/src/charts/createChartComponent.tsx +36 -0
- package/src/charts/createOptionChartComponent.tsx +32 -0
- package/src/charts/funnel/__tests__/index.test.tsx +99 -0
- package/src/charts/funnel/index.tsx +60 -10
- package/src/charts/funnel/types.ts +6 -0
- package/src/charts/graph/__tests__/index.test.tsx +102 -33
- package/src/charts/graph/index.tsx +66 -9
- package/src/charts/graph/types.ts +6 -0
- package/src/charts/heatmap/__tests__/index.test.tsx +139 -0
- package/src/charts/heatmap/index.tsx +103 -10
- package/src/charts/heatmap/types.ts +6 -0
- package/src/charts/index.ts +74 -26
- package/src/charts/liquid/__tests__/index.test.tsx +52 -0
- package/src/charts/liquid/index.tsx +239 -182
- package/src/charts/liquid/types.ts +11 -11
- package/src/charts/parallel/__tests__/index.test.tsx +40 -67
- package/src/charts/parallel/index.tsx +2 -1
- package/src/charts/parallel/types.ts +19 -18
- package/src/charts/radar/__tests__/index.test.tsx +210 -0
- package/src/charts/radar/index.tsx +143 -10
- package/src/charts/radar/types.ts +13 -0
- package/src/charts/sankey/__tests__/index.test.tsx +124 -0
- package/src/charts/sankey/index.tsx +62 -10
- package/src/charts/sankey/types.ts +6 -0
- package/src/charts/tree/__tests__/index.test.tsx +71 -0
- package/src/charts/tree/index.tsx +5 -2
- package/src/charts/tree/types.ts +9 -9
- package/src/charts/types.ts +208 -106
- package/src/charts/utils.ts +9 -7
- package/src/charts/wordcloud/__tests__/index.test.tsx +98 -31
- package/src/charts/wordcloud/index.tsx +75 -9
- package/src/charts/wordcloud/types.ts +6 -0
- package/src/components/DataFilter/index.tsx +32 -10
- package/src/core/animation/types.ts +6 -6
- package/src/core/components/Annotation.tsx +6 -7
- package/src/core/components/BaseChart.tsx +110 -168
- package/src/core/components/ErrorBoundary.tsx +17 -4
- package/src/core/components/LazyChart.tsx +54 -55
- package/src/core/components/hooks/index.ts +6 -2
- package/src/core/components/hooks/useChartInit.ts +6 -3
- package/src/core/components/hooks/usePerformance.ts +8 -2
- package/src/core/components/hooks/useVirtualScroll.ts +2 -1
- package/src/core/index.ts +1 -1
- package/src/core/themes/ThemeManager.ts +1 -1
- package/src/core/types/common.ts +2 -1
- package/src/core/types/index.ts +0 -12
- package/src/core/types/platform.ts +3 -5
- package/src/core/utils/__tests__/deepClone.test.ts +317 -0
- package/src/core/utils/__tests__/index.test.ts +2 -1
- package/src/core/utils/chartInstances.ts +13 -0
- package/src/core/utils/common.ts +20 -29
- package/src/core/utils/deepClone.ts +114 -0
- package/src/core/utils/download.ts +128 -0
- package/src/core/utils/drillDown.ts +34 -353
- package/src/core/utils/drillDownHelpers.ts +426 -0
- package/src/core/utils/events.ts +12 -0
- package/src/core/utils/export/ExportUtils.ts +36 -67
- package/src/core/utils/format.ts +44 -0
- package/src/core/utils/index.ts +21 -154
- package/src/core/utils/merge.ts +25 -0
- package/src/core/utils/performance/PerformanceAnalyzer.ts +38 -21
- package/src/core/utils/performance/hooks.ts +7 -0
- package/src/core/utils/performance/index.ts +2 -0
- package/src/{hooks → core/utils/performance}/useAnimation.ts +45 -41
- package/src/core/utils/performance/useDataZoom.ts +324 -0
- package/src/{hooks → core/utils/performance}/usePerformance.ts +49 -41
- package/src/core/utils/performance/usePerformanceHooks.ts +278 -0
- package/src/core/utils/performanceUtils.ts +310 -0
- package/src/core/utils/runtime.ts +190 -0
- package/src/core/utils/setOptionUtils.ts +59 -0
- package/src/core/version.ts +14 -0
- package/src/editor/EnhancedThemeEditor.tsx +362 -540
- package/src/editor/ThemeEditor.tsx +55 -321
- package/src/editor/components/ThemeBasicSettings.tsx +113 -0
- package/src/editor/components/ThemeColorEditor.tsx +105 -0
- package/src/editor/components/ThemeSelector.tsx +70 -0
- package/src/editor/hooks/useThemeEditorState.ts +201 -0
- package/src/editor/index.ts +10 -2
- package/src/hooks/__tests__/index.test.tsx +3 -1
- package/src/hooks/chartConnectHelpers.ts +341 -0
- package/src/hooks/index.ts +55 -660
- package/src/hooks/types.ts +189 -0
- package/src/hooks/useChartAutoResize.ts +73 -0
- package/src/hooks/useChartConnect.ts +92 -238
- package/src/hooks/useChartDownload.ts +25 -27
- package/src/hooks/useChartHistory.ts +34 -49
- package/src/hooks/useChartInit.ts +59 -0
- package/src/hooks/useChartOptions.ts +259 -0
- package/src/hooks/useChartPerformance.ts +109 -0
- package/src/hooks/useChartSelection.ts +52 -49
- package/src/hooks/useChartTheme.ts +51 -0
- package/src/hooks/useDataTransform.ts +19 -4
- package/src/hooks/utils/chartDownloadUtils.ts +40 -53
- package/src/hooks/utils/dataTransformUtils.ts +22 -0
- package/src/index.ts +48 -34
- package/src/main.tsx +4 -9
- package/src/react-dom.d.ts +3 -3
- package/src/themes/index.ts +30 -855
- package/src/themes/palettes/blue-green.ts +13 -0
- package/src/themes/palettes/chalk.ts +13 -0
- package/src/themes/palettes/cyber.ts +44 -0
- package/src/themes/palettes/dark.ts +52 -0
- package/src/themes/palettes/default.ts +52 -0
- package/src/themes/palettes/elegant.ts +34 -0
- package/src/themes/palettes/forest.ts +13 -0
- package/src/themes/palettes/glass.ts +49 -0
- package/src/themes/palettes/golden.ts +13 -0
- package/src/themes/palettes/neon.ts +43 -0
- package/src/themes/palettes/ocean.ts +39 -0
- package/src/themes/palettes/pastel.ts +37 -0
- package/src/themes/palettes/purple-passion.ts +13 -0
- package/src/themes/palettes/retro.ts +33 -0
- package/src/themes/palettes/sunset.ts +40 -0
- package/src/themes/palettes/walden.ts +13 -0
- package/src/themes/registry.ts +184 -0
- package/src/themes/types.ts +213 -0
- package/src/charts/bar/__tests__/index.test.tsx +0 -113
- package/src/charts/bar/index.tsx +0 -14
- package/src/charts/candlestick/__tests__/index.test.tsx +0 -40
- package/src/charts/candlestick/index.tsx +0 -13
- package/src/charts/gauge/index.tsx +0 -14
- package/src/charts/line/__tests__/index.test.tsx +0 -107
- package/src/charts/line/index.tsx +0 -15
- package/src/charts/pie/__tests__/index.test.tsx +0 -112
- package/src/charts/pie/index.tsx +0 -14
- package/src/charts/scatter/index.tsx +0 -14
- package/src/charts/sunburst/index.tsx +0 -18
- package/src/charts/treemap/index.tsx +0 -18
- package/src/core/utils/codeGenerator/CodeGenerator.ts +0 -669
- package/src/core/utils/codeGenerator/index.ts +0 -13
- package/src/core/utils/codeGenerator/types.ts +0 -198
- package/src/core/utils/configGenerator/ConfigGenerator.ts +0 -583
- package/src/core/utils/configGenerator/index.ts +0 -13
- package/src/core/utils/configGenerator/types.ts +0 -445
- package/src/core/utils/debug/DebugPanel.tsx +0 -637
- package/src/core/utils/debug/debugger.ts +0 -322
- package/src/core/utils/debug/index.ts +0 -21
- package/src/core/utils/debug/types.ts +0 -142
- package/src/hooks/useDataZoom.ts +0 -323
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 折线图组件
|
|
3
|
-
*/
|
|
4
|
-
import React, { memo } from 'react';
|
|
5
|
-
import BaseChartWrapper from '../common/BaseChartWrapper';
|
|
6
|
-
import { LineChartProps } from '../types';
|
|
7
|
-
|
|
8
|
-
import '@/core/echarts';
|
|
9
|
-
|
|
10
|
-
const LineChart: React.FC<LineChartProps> = memo((props) => (
|
|
11
|
-
<BaseChartWrapper {...props} chartType="line-chart" />
|
|
12
|
-
));
|
|
13
|
-
LineChart.displayName = 'LineChart';
|
|
14
|
-
|
|
15
|
-
export default LineChart;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import PieChart from '../index';
|
|
5
|
-
|
|
6
|
-
// Mock ECharts and adapters
|
|
7
|
-
jest.mock('echarts/core', () => ({
|
|
8
|
-
use: jest.fn(),
|
|
9
|
-
init: jest.fn(() => ({
|
|
10
|
-
setOption: jest.fn(),
|
|
11
|
-
showLoading: jest.fn(),
|
|
12
|
-
hideLoading: jest.fn(),
|
|
13
|
-
on: jest.fn(),
|
|
14
|
-
off: jest.fn(),
|
|
15
|
-
dispose: jest.fn(),
|
|
16
|
-
resize: jest.fn(),
|
|
17
|
-
})),
|
|
18
|
-
getInstanceByDom: jest.fn(),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
// Mock specific ECharts chart imports
|
|
22
|
-
jest.mock('echarts/charts', () => ({
|
|
23
|
-
PieChart: jest.fn(),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
jest.mock('echarts/components', () => ({
|
|
27
|
-
GridComponent: jest.fn(),
|
|
28
|
-
TooltipComponent: jest.fn(),
|
|
29
|
-
TitleComponent: jest.fn(),
|
|
30
|
-
LegendComponent: jest.fn(),
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
jest.mock('../../common/BaseChartWrapper', () => ({
|
|
34
|
-
__esModule: true,
|
|
35
|
-
default: (props: any) => (
|
|
36
|
-
<div
|
|
37
|
-
data-testid="base-chart-wrapper"
|
|
38
|
-
className={`taroviz-${props.chartType} ${props.className || ''}`}
|
|
39
|
-
style={{ width: props.width, height: props.height }}
|
|
40
|
-
>
|
|
41
|
-
<div data-testid="chart-option">{JSON.stringify(props.option)}</div>
|
|
42
|
-
</div>
|
|
43
|
-
),
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
describe('PieChart Component', () => {
|
|
47
|
-
const mockOption = {
|
|
48
|
-
series: [
|
|
49
|
-
{
|
|
50
|
-
type: 'pie' as const,
|
|
51
|
-
data: [
|
|
52
|
-
{ value: 1048, name: 'Search Engine' },
|
|
53
|
-
{ value: 735, name: 'Direct' },
|
|
54
|
-
{ value: 580, name: 'Email' },
|
|
55
|
-
{ value: 484, name: 'Union Ads' },
|
|
56
|
-
{ value: 300, name: 'Video Ads' },
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
it('should render correctly with default props', () => {
|
|
63
|
-
const { getByTestId } = render(<PieChart option={mockOption} />);
|
|
64
|
-
|
|
65
|
-
const chartWrapper = getByTestId('base-chart-wrapper');
|
|
66
|
-
expect(chartWrapper).toBeInTheDocument();
|
|
67
|
-
expect(chartWrapper).toHaveClass('taroviz-pie-chart');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should pass the correct option to BaseChartWrapper', () => {
|
|
71
|
-
const { getByTestId } = render(<PieChart option={mockOption} />);
|
|
72
|
-
|
|
73
|
-
const chartOption = getByTestId('chart-option');
|
|
74
|
-
expect(JSON.parse(chartOption.textContent || '')).toEqual(mockOption);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should render with custom width and height', () => {
|
|
78
|
-
const customWidth = '400px';
|
|
79
|
-
const customHeight = '400px';
|
|
80
|
-
|
|
81
|
-
const { getByTestId } = render(
|
|
82
|
-
<PieChart option={mockOption} width={customWidth} height={customHeight} />
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const chartWrapper = getByTestId('base-chart-wrapper');
|
|
86
|
-
expect(chartWrapper).toHaveStyle(`width: ${customWidth}`);
|
|
87
|
-
expect(chartWrapper).toHaveStyle(`height: ${customHeight}`);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should render with custom className', () => {
|
|
91
|
-
const customClass = 'custom-pie-chart';
|
|
92
|
-
|
|
93
|
-
const { getByTestId } = render(<PieChart option={mockOption} className={customClass} />);
|
|
94
|
-
|
|
95
|
-
const chartWrapper = getByTestId('base-chart-wrapper');
|
|
96
|
-
expect(chartWrapper).toHaveClass(customClass);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should render with loading state', () => {
|
|
100
|
-
const { getByTestId } = render(<PieChart option={mockOption} loading={true} />);
|
|
101
|
-
|
|
102
|
-
const chartWrapper = getByTestId('base-chart-wrapper');
|
|
103
|
-
expect(chartWrapper).toBeInTheDocument();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should render with theme', () => {
|
|
107
|
-
const { getByTestId } = render(<PieChart option={mockOption} theme="dark" />);
|
|
108
|
-
|
|
109
|
-
const chartWrapper = getByTestId('base-chart-wrapper');
|
|
110
|
-
expect(chartWrapper).toBeInTheDocument();
|
|
111
|
-
});
|
|
112
|
-
});
|
package/src/charts/pie/index.tsx
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PieChart组件
|
|
3
|
-
*/
|
|
4
|
-
import React, { memo } from 'react';
|
|
5
|
-
import BaseChartWrapper from '../common/BaseChartWrapper';
|
|
6
|
-
import { BaseChartProps } from '../types';
|
|
7
|
-
import '@/core/echarts';
|
|
8
|
-
|
|
9
|
-
const PieChart: React.FC<BaseChartProps> = memo((props) => (
|
|
10
|
-
<BaseChartWrapper {...props} chartType="pie-chart" />
|
|
11
|
-
));
|
|
12
|
-
PieChart.displayName = 'PieChart';
|
|
13
|
-
|
|
14
|
-
export default PieChart;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ScatterChart组件
|
|
3
|
-
*/
|
|
4
|
-
import React, { memo } from 'react';
|
|
5
|
-
import BaseChartWrapper from '../common/BaseChartWrapper';
|
|
6
|
-
import { ScatterChartProps } from '../types';
|
|
7
|
-
import '@/core/echarts';
|
|
8
|
-
|
|
9
|
-
const ScatterChart: React.FC<ScatterChartProps> = memo((props) => (
|
|
10
|
-
<BaseChartWrapper {...props} chartType="scatter-chart" />
|
|
11
|
-
));
|
|
12
|
-
ScatterChart.displayName = 'ScatterChart';
|
|
13
|
-
|
|
14
|
-
export default ScatterChart;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sunburst 旭日图组件
|
|
3
|
-
* 用于展示带有层级结构的数据,以同心圆的形式展示
|
|
4
|
-
*/
|
|
5
|
-
import React, { memo } from 'react';
|
|
6
|
-
import BaseChartWrapper from '../common/BaseChartWrapper';
|
|
7
|
-
import { SunburstChartProps } from '../types';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Sunburst 旭日图组件
|
|
11
|
-
*/
|
|
12
|
-
const SunburstChart: React.FC<SunburstChartProps> = memo((props) => (
|
|
13
|
-
<BaseChartWrapper {...props} chartType="sunburst-chart" />
|
|
14
|
-
));
|
|
15
|
-
|
|
16
|
-
SunburstChart.displayName = 'SunburstChart';
|
|
17
|
-
|
|
18
|
-
export default SunburstChart;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TreeMap 图表组件
|
|
3
|
-
* 用于展示带有层级结构的数据,通过矩形面积表示数据大小
|
|
4
|
-
*/
|
|
5
|
-
import React, { memo } from 'react';
|
|
6
|
-
import BaseChartWrapper from '../common/BaseChartWrapper';
|
|
7
|
-
import { TreeMapChartProps } from '../types';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* TreeMap 图表组件
|
|
11
|
-
*/
|
|
12
|
-
const TreeMapChart: React.FC<TreeMapChartProps> = memo((props) => (
|
|
13
|
-
<BaseChartWrapper {...props} chartType="treemap-chart" />
|
|
14
|
-
));
|
|
15
|
-
|
|
16
|
-
TreeMapChart.displayName = 'TreeMapChart';
|
|
17
|
-
|
|
18
|
-
export default TreeMapChart;
|