@visactor/react-vchart 2.0.0-alpha.0 → 2.0.0-alpha.1
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/README.md +18 -26
- package/cjs/VChart.d.ts +1 -1
- package/cjs/VChartSimple.d.ts +1 -1
- package/cjs/charts/AreaChart.d.ts +1 -1
- package/cjs/charts/Bar3dChart.d.ts +2 -2
- package/cjs/charts/Bar3dChart.js +2 -2
- package/cjs/charts/Bar3dChart.js.map +1 -1
- package/cjs/charts/BarChart.d.ts +1 -1
- package/cjs/charts/BaseChart.d.ts +1 -2
- package/cjs/charts/BaseChart.js +16 -17
- package/cjs/charts/BaseChart.js.map +1 -1
- package/cjs/charts/BoxPlotChart.d.ts +1 -1
- package/cjs/charts/CirclePackingChart.d.ts +1 -1
- package/cjs/charts/CircularProgressChart.d.ts +1 -1
- package/cjs/charts/CommonChart.d.ts +1 -1
- package/cjs/charts/CorrelationChart.d.ts +1 -1
- package/cjs/charts/Funnel3dChart.d.ts +2 -2
- package/cjs/charts/Funnel3dChart.js +2 -2
- package/cjs/charts/Funnel3dChart.js.map +1 -1
- package/cjs/charts/FunnelChart.d.ts +1 -1
- package/cjs/charts/GaugeChart.d.ts +1 -1
- package/cjs/charts/HeatmapChart.d.ts +1 -1
- package/cjs/charts/Histogram3dChart.d.ts +2 -2
- package/cjs/charts/Histogram3dChart.js +2 -2
- package/cjs/charts/Histogram3dChart.js.map +1 -1
- package/cjs/charts/HistogramChart.d.ts +1 -1
- package/cjs/charts/LineChart.d.ts +1 -1
- package/cjs/charts/LinearProgressChart.d.ts +1 -1
- package/cjs/charts/LiquidChart.d.ts +1 -1
- package/cjs/charts/MapChart.d.ts +1 -1
- package/cjs/charts/MosaicChart.d.ts +1 -1
- package/cjs/charts/PictogramChart.d.ts +1 -1
- package/cjs/charts/Pie3dChart.d.ts +2 -2
- package/cjs/charts/Pie3dChart.js +2 -2
- package/cjs/charts/Pie3dChart.js.map +1 -1
- package/cjs/charts/PieChart.d.ts +1 -1
- package/cjs/charts/RadarChart.d.ts +1 -1
- package/cjs/charts/RangeAreaChart.d.ts +1 -1
- package/cjs/charts/RangeColumn3dChart.d.ts +2 -2
- package/cjs/charts/RangeColumn3dChart.js +2 -2
- package/cjs/charts/RangeColumn3dChart.js.map +1 -1
- package/cjs/charts/RangeColumnChart.d.ts +1 -1
- package/cjs/charts/RoseChart.d.ts +1 -1
- package/cjs/charts/SankeyChart.d.ts +1 -1
- package/cjs/charts/ScatterChart.d.ts +1 -1
- package/cjs/charts/SequenceChart.d.ts +1 -1
- package/cjs/charts/SunburstChart.d.ts +1 -1
- package/cjs/charts/TreemapChart.d.ts +1 -1
- package/cjs/charts/TreemapChart.js +2 -2
- package/cjs/charts/TreemapChart.js.map +1 -1
- package/cjs/charts/VennChart.d.ts +1 -1
- package/cjs/charts/WaterfallChart.d.ts +1 -1
- package/cjs/charts/WordCloud3dChart.d.ts +2 -2
- package/cjs/charts/WordCloud3dChart.js +2 -2
- package/cjs/charts/WordCloud3dChart.js.map +1 -1
- package/cjs/charts/WordCloudChart.d.ts +1 -1
- package/cjs/charts/index.d.ts +1 -0
- package/cjs/charts/index.js +2 -1
- package/cjs/charts/index.js.map +1 -1
- package/cjs/components/BaseComponent.js +1 -1
- package/cjs/components/BaseComponent.js.map +1 -1
- package/cjs/containers/withContainer.d.ts +1 -1
- package/cjs/containers/withContainer.js +1 -1
- package/cjs/containers/withContainer.js.map +1 -1
- package/cjs/context/chart.d.ts +3 -1
- package/cjs/context/chart.js +5 -4
- package/cjs/context/chart.js.map +1 -1
- package/cjs/context/stage.d.ts +5 -1
- package/cjs/context/stage.js +17 -6
- package/cjs/context/stage.js.map +1 -1
- package/cjs/index.d.ts +3 -2
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/series/Bar3d.d.ts +2 -2
- package/cjs/series/Bar3d.js +2 -2
- package/cjs/series/Bar3d.js.map +1 -1
- package/cjs/series/Funnel3d.d.ts +2 -2
- package/cjs/series/Funnel3d.js +2 -2
- package/cjs/series/Funnel3d.js.map +1 -1
- package/cjs/series/Pie3d.d.ts +2 -2
- package/cjs/series/Pie3d.js +2 -2
- package/cjs/series/Pie3d.js.map +1 -1
- package/cjs/series/RangeColumn3d.d.ts +2 -2
- package/cjs/series/RangeColumn3d.js +2 -2
- package/cjs/series/RangeColumn3d.js.map +1 -1
- package/cjs/series/WordCloud3d.d.ts +2 -2
- package/cjs/series/WordCloud3d.js +2 -2
- package/cjs/series/WordCloud3d.js.map +1 -1
- package/esm/VChart.d.ts +1 -1
- package/esm/VChartSimple.d.ts +1 -1
- package/esm/charts/AreaChart.d.ts +1 -1
- package/esm/charts/Bar3dChart.d.ts +2 -2
- package/esm/charts/Bar3dChart.js +3 -1
- package/esm/charts/Bar3dChart.js.map +1 -1
- package/esm/charts/BarChart.d.ts +1 -1
- package/esm/charts/BaseChart.d.ts +1 -2
- package/esm/charts/BaseChart.js +14 -17
- package/esm/charts/BaseChart.js.map +1 -1
- package/esm/charts/BoxPlotChart.d.ts +1 -1
- package/esm/charts/CirclePackingChart.d.ts +1 -1
- package/esm/charts/CircularProgressChart.d.ts +1 -1
- package/esm/charts/CommonChart.d.ts +1 -1
- package/esm/charts/CorrelationChart.d.ts +1 -1
- package/esm/charts/Funnel3dChart.d.ts +2 -2
- package/esm/charts/Funnel3dChart.js +3 -1
- package/esm/charts/Funnel3dChart.js.map +1 -1
- package/esm/charts/FunnelChart.d.ts +1 -1
- package/esm/charts/GaugeChart.d.ts +1 -1
- package/esm/charts/HeatmapChart.d.ts +1 -1
- package/esm/charts/Histogram3dChart.d.ts +2 -2
- package/esm/charts/Histogram3dChart.js +3 -1
- package/esm/charts/Histogram3dChart.js.map +1 -1
- package/esm/charts/HistogramChart.d.ts +1 -1
- package/esm/charts/LineChart.d.ts +1 -1
- package/esm/charts/LinearProgressChart.d.ts +1 -1
- package/esm/charts/LiquidChart.d.ts +1 -1
- package/esm/charts/MapChart.d.ts +1 -1
- package/esm/charts/MosaicChart.d.ts +1 -1
- package/esm/charts/PictogramChart.d.ts +1 -1
- package/esm/charts/Pie3dChart.d.ts +2 -2
- package/esm/charts/Pie3dChart.js +3 -1
- package/esm/charts/Pie3dChart.js.map +1 -1
- package/esm/charts/PieChart.d.ts +1 -1
- package/esm/charts/RadarChart.d.ts +1 -1
- package/esm/charts/RangeAreaChart.d.ts +1 -1
- package/esm/charts/RangeColumn3dChart.d.ts +2 -2
- package/esm/charts/RangeColumn3dChart.js +3 -1
- package/esm/charts/RangeColumn3dChart.js.map +1 -1
- package/esm/charts/RangeColumnChart.d.ts +1 -1
- package/esm/charts/RoseChart.d.ts +1 -1
- package/esm/charts/SankeyChart.d.ts +1 -1
- package/esm/charts/ScatterChart.d.ts +1 -1
- package/esm/charts/SequenceChart.d.ts +1 -1
- package/esm/charts/SunburstChart.d.ts +1 -1
- package/esm/charts/TreemapChart.d.ts +1 -1
- package/esm/charts/TreemapChart.js +1 -3
- package/esm/charts/TreemapChart.js.map +1 -1
- package/esm/charts/VennChart.d.ts +1 -1
- package/esm/charts/WaterfallChart.d.ts +1 -1
- package/esm/charts/WordCloud3dChart.d.ts +2 -2
- package/esm/charts/WordCloud3dChart.js +3 -1
- package/esm/charts/WordCloud3dChart.js.map +1 -1
- package/esm/charts/WordCloudChart.d.ts +1 -1
- package/esm/charts/index.d.ts +1 -0
- package/esm/charts/index.js +2 -0
- package/esm/charts/index.js.map +1 -1
- package/esm/components/BaseComponent.js +1 -1
- package/esm/components/BaseComponent.js.map +1 -1
- package/esm/containers/withContainer.d.ts +1 -1
- package/esm/containers/withContainer.js +1 -1
- package/esm/containers/withContainer.js.map +1 -1
- package/esm/context/chart.d.ts +3 -1
- package/esm/context/chart.js +5 -4
- package/esm/context/chart.js.map +1 -1
- package/esm/context/stage.d.ts +5 -1
- package/esm/context/stage.js +18 -5
- package/esm/context/stage.js.map +1 -1
- package/esm/index.d.ts +3 -2
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/series/Bar3d.d.ts +2 -2
- package/esm/series/Bar3d.js +1 -1
- package/esm/series/Bar3d.js.map +1 -1
- package/esm/series/Funnel3d.d.ts +2 -2
- package/esm/series/Funnel3d.js +1 -1
- package/esm/series/Funnel3d.js.map +1 -1
- package/esm/series/Pie3d.d.ts +2 -2
- package/esm/series/Pie3d.js +1 -1
- package/esm/series/Pie3d.js.map +1 -1
- package/esm/series/RangeColumn3d.d.ts +2 -2
- package/esm/series/RangeColumn3d.js +1 -1
- package/esm/series/RangeColumn3d.js.map +1 -1
- package/esm/series/WordCloud3d.d.ts +2 -2
- package/esm/series/WordCloud3d.js +1 -1
- package/esm/series/WordCloud3d.js.map +1 -1
- package/package.json +8 -8
- package/cjs/context/view.d.ts +0 -5
- package/cjs/context/view.js +0 -24
- package/cjs/context/view.js.map +0 -1
- package/esm/context/view.d.ts +0 -5
- package/esm/context/view.js +0 -16
- package/esm/context/view.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# @visactor/react-vchart
|
|
2
2
|
|
|
3
|
-
`@visactor/react-vchart`
|
|
3
|
+
`@visactor/react-vchart` is a React wrapper version of the VChart library provided by [VisActor](visactor.io). It offers a series of easy-to-use React components for creating various types of charts in a React development environment, including line charts, bar charts, pie charts, and more. The components in `@visactor/react-vchart` are highly customizable and extensible, allowing you to achieve different chart effects through various parameters and configurations.
|
|
4
4
|
|
|
5
|
-
`@visactor/react-vchart`
|
|
5
|
+
Key features of `@visactor/react-vchart` include:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- **Easy to Use**: `@visactor/react-vchart` provides a series of user-friendly React components for quickly creating various types of charts.
|
|
8
|
+
- **Highly Customizable**: The components in `@visactor/react-vchart` are highly customizable, allowing you to achieve different chart effects through various parameters and configurations.
|
|
9
|
+
- **Extensible**: `@visactor/react-vchart` components can be easily extended and customized, allowing you to add new functionalities and features as needed.
|
|
10
|
+
- **Good Compatibility**: `@visactor/react-vchart` fully inherits VChart's visualization capabilities and can run on different browsers and devices.
|
|
11
|
+
- **Support for Multiple Chart Types**: `@visactor/react-vchart` supports various types of charts, including line charts, bar charts, pie charts, radar charts, and more.
|
|
12
12
|
|
|
13
|
-
`@visactor/react-vchart`
|
|
13
|
+
`@visactor/react-vchart` is fully aligned with VChart in terms of capabilities, and its API configuration is almost identical to VChart. For chart definitions and configurations, please refer to [VChart](https://www.visactor.io/vchart).
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Development Guide
|
|
16
16
|
|
|
17
17
|
### Build
|
|
18
18
|
|
|
@@ -35,20 +35,12 @@ $ cd packages/react-vchart
|
|
|
35
35
|
$ rushx start
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
##
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
2. 入门
|
|
48
|
-
- [API 设计](./docs/2.1%20API%E8%AE%BE%E8%AE%A1.md)
|
|
49
|
-
- [统一图表标签](./docs//2.2%20%E7%BB%9F%E4%B8%80%E5%9B%BE%E8%A1%A8%E6%A0%87%E7%AD%BE.md)
|
|
50
|
-
- [语法化标签](./docs/2.3%20%E8%AF%AD%E6%B3%95%E5%8C%96%E6%A0%87%E7%AD%BE.md)
|
|
51
|
-
3. [事件交互](./docs/3.%20%E4%BA%8B%E4%BB%B6%E4%BA%A4%E4%BA%92.md)
|
|
52
|
-
4. [主题样式](./docs/4.%20%E4%B8%BB%E9%A2%98%E6%A0%B7%E5%BC%8F.md)
|
|
53
|
-
5. [FAQ](./docs/5.%20FAQ.md)
|
|
54
|
-
6. [更新日志](./docs/6.%20%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97.md)
|
|
38
|
+
## Documentation Guide
|
|
39
|
+
|
|
40
|
+
[guide](https://github.com/VisActor/VChart/blob/develop/docs/assets/guide/zh/tutorial_docs/Cross-terminal_and_Developer_Ecology/react.md)
|
|
41
|
+
|
|
42
|
+
[demo](https://github.com/VisActor/VChart/tree/develop/docs/assets/examples-react)
|
|
43
|
+
|
|
44
|
+
[online guide](https://www.visactor.io/vchart/guide/tutorial_docs/Cross-terminal_and_Developer_Ecology/react)
|
|
45
|
+
|
|
46
|
+
[online demo](https://www.visactor.io/vchart/example-react)
|
package/cjs/VChart.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BaseChartProps } from './charts/BaseChart';
|
|
2
2
|
export type VChartProps = Omit<BaseChartProps, 'container' | 'width' | 'height' | 'type'>;
|
|
3
|
-
export declare const VChart: import("react").ForwardRefExoticComponent<VChartProps & import("
|
|
3
|
+
export declare const VChart: import("react").ForwardRefExoticComponent<VChartProps & import("react").RefAttributes<any>>;
|
package/cjs/VChartSimple.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { BaseChartProps } from './charts/BaseChart';
|
|
|
3
3
|
export type VChartSimpleProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'vchartConstrouctor'>;
|
|
4
4
|
export declare const VChartSimple: import("react").ForwardRefExoticComponent<VChartSimpleProps & {
|
|
5
5
|
vchartConstrouctor: IVChartConstructor;
|
|
6
|
-
} & import("
|
|
6
|
+
} & import("react").RefAttributes<any>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { IBar3dChartSpec } from '@visactor/vchart';
|
|
2
|
+
import type { IBar3dChartSpec } from '@visactor/vchart-extension';
|
|
3
3
|
import type { BaseChartProps } from './BaseChart';
|
|
4
4
|
export interface Bar3dChartProps extends Omit<BaseChartProps, 'container' | 'type' | 'data'>, Omit<Partial<IBar3dChartSpec>, 'type'> {
|
|
5
5
|
}
|
|
@@ -7,4 +7,4 @@ export declare const Bar3dChart: React.ForwardRefExoticComponent<Bar3dChartProps
|
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
} & {
|
|
9
9
|
type?: 'bar3d';
|
|
10
|
-
} &
|
|
10
|
+
} & React.RefAttributes<any>>;
|
package/cjs/charts/Bar3dChart.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Bar3dChart = void 0;
|
|
6
6
|
|
|
7
|
-
const vchart_1 = require("@visactor/vchart"), BaseChart_1 = require("./BaseChart"), cartesian_1 = require("./registers/cartesian");
|
|
7
|
+
const vchart_1 = require("@visactor/vchart"), vchart_extension_1 = require("@visactor/vchart-extension"), BaseChart_1 = require("./BaseChart"), cartesian_1 = require("./registers/cartesian");
|
|
8
8
|
|
|
9
9
|
exports.Bar3dChart = (0, BaseChart_1.createChart)("Bar3dChart", {
|
|
10
10
|
type: "bar3d",
|
|
11
11
|
vchartConstrouctor: vchart_1.VChart
|
|
12
|
-
}, [
|
|
12
|
+
}, [ vchart_extension_1.registerBar3dChart, vchart_1.registerLabel, vchart_1.registerTotalLabel, ...cartesian_1.registers ]);
|
|
13
13
|
//# sourceMappingURL=Bar3dChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/Bar3dChart.tsx"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"sources":["../src/charts/Bar3dChart.tsx"],"names":[],"mappings":";;;AAEA,6CAA6E;AAC7E,iEAAgE;AAGhE,2CAA0C;AAC1C,qDAAkD;AAQrC,QAAA,UAAU,GAAG,IAAA,uBAAW,EACnC,YAAY,EACZ;IACE,IAAI,EAAE,OAAO;IACb,kBAAkB,EAAE,eAA4B;CACjD,EACD,CAAC,qCAAkB,EAAE,sBAAa,EAAE,2BAAkB,EAAE,GAAG,qBAAS,CAAC,CACtE,CAAC","file":"Bar3dChart.js","sourcesContent":["import type React from 'react';\nimport type { IVChartConstructor } from '@visactor/vchart';\nimport { VChart, registerLabel, registerTotalLabel } from '@visactor/vchart';\nimport { registerBar3dChart } from '@visactor/vchart-extension';\nimport type { IBar3dChartSpec } from '@visactor/vchart-extension';\nimport type { BaseChartProps } from './BaseChart';\nimport { createChart } from './BaseChart';\nimport { registers } from './registers/cartesian';\n\nexport interface Bar3dChartProps\n extends Omit<BaseChartProps, 'container' | 'type' | 'data'>,\n Omit<Partial<IBar3dChartSpec>, 'type'> {\n //\n}\n\nexport const Bar3dChart = createChart<React.PropsWithChildren<Bar3dChartProps> & { type?: 'bar3d' }>(\n 'Bar3dChart',\n {\n type: 'bar3d',\n vchartConstrouctor: VChart as IVChartConstructor\n },\n [registerBar3dChart, registerLabel, registerTotalLabel, ...registers]\n);\n"]}
|
package/cjs/charts/BarChart.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor, IHierarchyData, IVChartRenderOption } from '@visactor/vchart';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { ContainerProps } from '../containers/withContainer';
|
|
4
3
|
import type { EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps } from '../eventsUtils';
|
|
5
4
|
import type { IReactTooltipProps } from '../components/tooltip/interface';
|
|
6
5
|
export type ChartOptions = Omit<IInitOption, 'dom'>;
|
|
@@ -20,5 +19,5 @@ export interface BaseChartProps extends EventsProps, LegendEventProps, ScrollBar
|
|
|
20
19
|
useSyncRender?: boolean;
|
|
21
20
|
}
|
|
22
21
|
type Props = React.PropsWithChildren<BaseChartProps>;
|
|
23
|
-
export declare const createChart: <T extends Props>(componentName: string, defaultProps?: Partial<T>, registers?: (() => void)[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<T
|
|
22
|
+
export declare const createChart: <T extends Props>(componentName: string, defaultProps?: Partial<T>, registers?: (() => void)[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<T> & React.RefAttributes<any>>;
|
|
24
23
|
export {};
|
package/cjs/charts/BaseChart.js
CHANGED
|
@@ -33,7 +33,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
33
33
|
value: !0
|
|
34
34
|
}), exports.createChart = void 0;
|
|
35
35
|
|
|
36
|
-
const react_1 = __importStar(require("react")), withContainer_1 = __importDefault(require("../containers/withContainer")), chart_1 = __importDefault(require("../context/chart")), vutils_1 = require("@visactor/vutils"),
|
|
36
|
+
const react_1 = __importStar(require("react")), withContainer_1 = __importDefault(require("../containers/withContainer")), chart_1 = __importDefault(require("../context/chart")), vutils_1 = require("@visactor/vutils"), util_1 = require("../util"), constants_1 = require("../constants"), eventsUtils_1 = require("../eventsUtils"), util_2 = require("../components/tooltip/util"), notSpecKeys = [ ...constants_1.REACT_PRIVATE_PROPS, ...eventsUtils_1.CHART_EVENTS_KEYS, "vchartConstrouctor", "useSyncRender", "skipFunctionDiff", "onError", "onReady", "spec", "container", "options", "morphConfig" ], defaultMorphConfig = {
|
|
37
37
|
morph: !1,
|
|
38
38
|
enableExitAnimation: !1
|
|
39
39
|
}, getComponentId = (child, index) => `${child && child.type && (child.type.displayName || child.type.name)}-${index}`, parseSpecFromChildren = props => {
|
|
@@ -54,8 +54,8 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
|
|
|
54
54
|
var _a;
|
|
55
55
|
return null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart;
|
|
56
56
|
}));
|
|
57
|
-
const hasSpec = !!props.spec,
|
|
58
|
-
react_1.useRef)(
|
|
57
|
+
const hasSpec = !!props.spec, isUnmount = (0, react_1.useRef)(!1), prevSpec = (0,
|
|
58
|
+
react_1.useRef)((0, vutils_1.pickWithout)(props, notSpecKeys)), specFromChildren = (0,
|
|
59
59
|
react_1.useRef)(null), eventsBinded = react_1.default.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, [tooltipNode, setTooltipNode] = (0,
|
|
60
60
|
react_1.useState)(null), parseSpec = props => {
|
|
61
61
|
let spec;
|
|
@@ -64,13 +64,11 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
|
|
|
64
64
|
}))) : spec = Object.assign(Object.assign({}, prevSpec.current), specFromChildren.current);
|
|
65
65
|
const tooltipSpec = (0, util_2.initCustomTooltip)(setTooltipNode, props, spec.tooltip);
|
|
66
66
|
return tooltipSpec && (spec.tooltip = tooltipSpec), spec;
|
|
67
|
-
}, handleChartRender =
|
|
67
|
+
}, handleChartRender = rebindEvent => {
|
|
68
68
|
if (!isUnmount.current) {
|
|
69
69
|
if (!chartContext.current || !chartContext.current.chart) return;
|
|
70
|
-
(0, eventsUtils_1.bindEventsToChart)(chartContext.current.chart, props, eventsBinded.current, eventsUtils_1.CHART_EVENTS)
|
|
71
|
-
|
|
72
|
-
setUpdateId(updateId + 1), props.onReady && props.onReady(chartContext.current.chart, 0 === updateId),
|
|
73
|
-
setView(newView);
|
|
70
|
+
rebindEvent && (0, eventsUtils_1.bindEventsToChart)(chartContext.current.chart, props, eventsBinded.current, eventsUtils_1.CHART_EVENTS),
|
|
71
|
+
setUpdateId(updateId + 1), props.onReady && props.onReady(chartContext.current.chart, 0 === updateId);
|
|
74
72
|
}
|
|
75
73
|
};
|
|
76
74
|
return (0, react_1.useEffect)((() => {
|
|
@@ -86,27 +84,28 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
|
|
|
86
84
|
chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
|
|
87
85
|
chart: cs
|
|
88
86
|
}), isUnmount.current = !1;
|
|
89
|
-
})(props), chartContext.current.chart && (chartContext.current.chart.
|
|
87
|
+
})(props), chartContext.current.chart && ((0, eventsUtils_1.bindEventsToChart)(chartContext.current.chart, props, eventsBinded.current, eventsUtils_1.CHART_EVENTS),
|
|
88
|
+
chartContext.current.chart.renderSync({
|
|
90
89
|
reuse: !1
|
|
91
90
|
}), handleChartRender()), void (eventsBinded.current = props);
|
|
92
91
|
if (hasSpec) return void ((0, vutils_1.isEqual)(eventsBinded.current.spec, props.spec, {
|
|
93
92
|
skipFunction: skipFunctionDiff
|
|
94
93
|
}) ? eventsBinded.current.data !== props.data && (chartContext.current.chart.updateFullDataSync(props.data),
|
|
95
|
-
handleChartRender(), eventsBinded.current = props) : (chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, null !== (_b = props.morphConfig) && void 0 !== _b ? _b : defaultMorphConfig),
|
|
96
|
-
handleChartRender(), eventsBinded.current = props));
|
|
94
|
+
handleChartRender(!0), eventsBinded.current = props) : (chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, null !== (_b = props.morphConfig) && void 0 !== _b ? _b : defaultMorphConfig),
|
|
95
|
+
handleChartRender(!0), eventsBinded.current = props));
|
|
97
96
|
const newSpec = (0, vutils_1.pickWithout)(props, notSpecKeys);
|
|
98
97
|
(0, vutils_1.isEqual)(newSpec, prevSpec.current, {
|
|
99
98
|
skipFunction: skipFunctionDiff
|
|
100
|
-
}) && (0, vutils_1.isEqual)(newSpecFromChildren, specFromChildren.current
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
}) && (0, vutils_1.isEqual)(newSpecFromChildren, specFromChildren.current, {
|
|
100
|
+
skipFunction: skipFunctionDiff
|
|
101
|
+
}) || (prevSpec.current = newSpec, specFromChildren.current = newSpecFromChildren,
|
|
102
|
+
chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, null !== (_c = props.morphConfig) && void 0 !== _c ? _c : defaultMorphConfig),
|
|
103
|
+
handleChartRender(!0), eventsBinded.current = props);
|
|
103
104
|
}), [ props ]), (0, react_1.useEffect)((() => () => {
|
|
104
105
|
chartContext && chartContext.current && chartContext.current.chart && (chartContext.current.chart.release(),
|
|
105
106
|
chartContext.current.chart = null), eventsBinded.current = null, isUnmount.current = !0;
|
|
106
107
|
}), []), react_1.default.createElement(chart_1.default.Provider, {
|
|
107
108
|
value: chartContext.current
|
|
108
|
-
}, react_1.default.createElement(view_1.default.Provider, {
|
|
109
|
-
value: view
|
|
110
109
|
}, (0, util_1.toArray)(props.children).map(((child, index) => {
|
|
111
110
|
if ("string" == typeof child) return null;
|
|
112
111
|
const childId = getComponentId(child, index);
|
|
@@ -116,7 +115,7 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
|
|
|
116
115
|
updateId: updateId,
|
|
117
116
|
componentId: childId
|
|
118
117
|
}));
|
|
119
|
-
})), tooltipNode)
|
|
118
|
+
})), tooltipNode);
|
|
120
119
|
})), createChart = (componentName, defaultProps, registers) => {
|
|
121
120
|
registers && registers.length && defaultProps.vchartConstrouctor && defaultProps.vchartConstrouctor.useRegisters(registers);
|
|
122
121
|
const Com = (0, withContainer_1.default)(BaseChart, componentName, (props => defaultProps ? Object.assign(props, defaultProps) : props));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/BaseChart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,+CAAgF;AAEhF,gFAAwD;AAExD,6DAAgD;AAEhD,6CAAwE;AACxE,2DAA0C;AAC1C,kCAAkC;AAClC,4CAAmD;AAYnD,gDAAoF;AAEpF,qDAA+D;AAqD/D,MAAM,WAAW,GAAG;IAClB,GAAG,+BAAmB;IACtB,GAAG,+BAAiB;IACpB,oBAAoB;IACpB,eAAe;IACf,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,MAAM;IACN,WAAW;IACX,SAAS;IACT,aAAa;CACd,CAAC;AACF,MAAM,kBAAkB,GAAG;IACzB,KAAK,EAAE,KAAK;IACZ,mBAAmB,EAAE,KAAK;CAC3B,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAE,KAAa,EAAE,EAAE;IAC/D,MAAM,aAAa,GAAG,KAAK,IAAK,KAAa,CAAC,IAAI,IAAI,CAAE,KAAa,CAAC,IAAI,CAAC,WAAW,IAAK,KAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpH,OAAO,GAAG,aAAa,IAAI,KAAK,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,qBAA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AC9B,IAAA,cAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;oBAC7B,OAAO,IAAI,CAAC;iBACb;gBAED,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAE7C,OAAO,CACL,8BAAC,eAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,OAAO,IACzB,eAAK,CAAC,YAAY,CAAC,KAAkE,EAAE;oBACtF,QAAQ,EAAE,QAAQ;oBAClB,WAAW,EAAE,OAAO;iBACrB,CAAC,CACa,CAClB,CAAC;YACJ,CAAC,CAAC;YACD,WAAW,CACS,CACG,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,MAAM,WAAW,GAAG,CACzB,aAAqB,EACrB,YAAyB,EACzB,SAA0B,EAC1B,EAAE;IACF,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,IAAI,YAAY,CAAC,kBAAkB,EAAE;QACpE,YAAY,CAAC,kBAAkB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;KACzD;IAED,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAQ,EAAE,EAAE;QACzF,IAAI,YAAY,EAAE;YAChB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAjBW,QAAA,WAAW,eAiBtB","file":"BaseChart.js","sourcesContent":["import type {\n IVChart,\n IData,\n IInitOption,\n ISpec,\n IVChartConstructor,\n IHierarchyData,\n IVChartRenderOption\n} from '@visactor/vchart';\nimport type { ReactNode } from 'react';\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react';\nimport type { ContainerProps } from '../containers/withContainer';\nimport withContainer from '../containers/withContainer';\nimport type { ChartContextType } from '../context/chart';\nimport RootChartContext from '../context/chart';\nimport type { IView } from '@visactor/vgrammar-core';\nimport { isEqual, isNil, isValid, pickWithout } from '@visactor/vutils';\nimport ViewContext from '../context/view';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport type {\n EventsProps,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps\n} from '../eventsUtils';\nimport { bindEventsToChart, CHART_EVENTS_KEYS, CHART_EVENTS } from '../eventsUtils';\nimport type { IReactTooltipProps } from '../components/tooltip/interface';\nimport { initCustomTooltip } from '../components/tooltip/util';\n\nexport type ChartOptions = Omit<IInitOption, 'dom'>;\n\nexport interface BaseChartProps\n extends EventsProps,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps,\n IReactTooltipProps {\n vchartConstrouctor?: IVChartConstructor;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: ISpec;\n /** 数据 */\n data?: IData | IHierarchyData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n /** skip function diff when component update */\n skipFunctionDiff?: boolean;\n /**\n * add `morphConfig` for chart\n * @since 1.12.7\n */\n morphConfig?: IVChartRenderOption['morphConfig'];\n /** 图表渲染完成事件 */\n onReady?: (instance: IVChart, isInitial: boolean) => void;\n /** throw error when chart run into an error */\n onError?: (err: Error) => void;\n /**\n * use sync render\n *\n * @since 1.8.3\n * @deprecated 1.9.0\n **/\n useSyncRender?: boolean;\n}\n\ntype Props = React.PropsWithChildren<BaseChartProps>;\n\nconst notSpecKeys = [\n ...REACT_PRIVATE_PROPS,\n ...CHART_EVENTS_KEYS,\n 'vchartConstrouctor',\n 'useSyncRender',\n 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'spec',\n 'container',\n 'options',\n 'morphConfig'\n];\nconst defaultMorphConfig = {\n morph: false,\n enableExitAnimation: false\n};\n\nconst getComponentId = (child: React.ReactNode, index: number) => {\n const componentName = child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n return `${componentName}-${index}`;\n};\n\nconst parseSpecFromChildren = (props: Props) => {\n const specFromChildren: Omit<ISpec, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map((child, index) => {\n const parseSpec = child && (child as any).type && (child as any).type.parseSpec;\n\n if (parseSpec && (child as any).props) {\n const childProps = isNil((child as any).props.componentId)\n ? {\n ...(child as any).props,\n componentId: getComponentId(child, index)\n }\n : (child as any).props;\n\n const specResult = parseSpec(childProps);\n\n if (specResult.isSingle) {\n (specFromChildren as any)[specResult.specName] = specResult.spec;\n } else {\n if (!(specFromChildren as any)[specResult.specName]) {\n (specFromChildren as any)[specResult.specName] = [];\n }\n\n (specFromChildren as any)[specResult.specName].push(specResult.spec);\n }\n }\n });\n\n return specFromChildren;\n};\n\nconst BaseChart: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const chartContext = useRef<ChartContextType>({});\n useImperativeHandle(ref, () => chartContext.current?.chart);\n const hasSpec = !!props.spec;\n const [view, setView] = useState<IView>(null);\n const isUnmount = useRef<boolean>(false);\n const prevSpec = useRef(pickWithout(props, notSpecKeys));\n const specFromChildren = useRef<Omit<ISpec, 'type' | 'data' | 'width' | 'height'>>(null);\n const eventsBinded = React.useRef<BaseChartProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n const [tooltipNode, setTooltipNode] = useState<ReactNode>(null);\n\n const parseSpec = (props: Props) => {\n let spec: ISpec;\n\n if (hasSpec && props.spec) {\n spec = props.spec;\n\n if (isValid(props.data)) {\n spec = {\n ...props.spec,\n data: props.data\n } as ISpec;\n }\n } else {\n spec = {\n ...prevSpec.current,\n ...specFromChildren.current\n } as ISpec;\n }\n\n const tooltipSpec = initCustomTooltip(setTooltipNode, props, spec.tooltip);\n if (tooltipSpec) {\n spec.tooltip = tooltipSpec;\n }\n return spec;\n };\n\n const createChart = (props: Props) => {\n const cs = new props.vchartConstrouctor(parseSpec(props), {\n ...props.options,\n onError: props.onError,\n autoFit: true,\n dom: props.container\n });\n chartContext.current = { ...chartContext.current, chart: cs };\n isUnmount.current = false;\n };\n\n const handleChartRender = () => {\n // rebind events after render\n if (!isUnmount.current) {\n if (!chartContext.current || !chartContext.current.chart) {\n return;\n }\n\n bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);\n\n const newView = chartContext.current.chart.getCompiler().getVGrammarView();\n\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(chartContext.current.chart, updateId === 0);\n }\n setView(newView);\n }\n };\n\n const renderChart = () => {\n if (chartContext.current.chart) {\n chartContext.current.chart.renderSync({\n reuse: false\n });\n handleChartRender();\n }\n };\n\n useEffect(() => {\n const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);\n\n if (!chartContext.current?.chart) {\n if (!hasSpec) {\n specFromChildren.current = newSpecFromChildren;\n }\n\n createChart(props);\n renderChart();\n eventsBinded.current = props;\n return;\n }\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec, { skipFunction: skipFunctionDiff })) {\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, props.morphConfig ?? defaultMorphConfig);\n handleChartRender();\n eventsBinded.current = props;\n } else if (eventsBinded.current.data !== props.data) {\n chartContext.current.chart.updateFullDataSync(props.data as any);\n handleChartRender();\n eventsBinded.current = props;\n }\n return;\n }\n\n const newSpec = pickWithout(props, notSpecKeys);\n\n if (\n !isEqual(newSpec, prevSpec.current, { skipFunction: skipFunctionDiff }) ||\n !isEqual(newSpecFromChildren, specFromChildren.current)\n ) {\n prevSpec.current = newSpec;\n specFromChildren.current = newSpecFromChildren;\n\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, props.morphConfig ?? defaultMorphConfig);\n handleChartRender();\n eventsBinded.current = props;\n }\n }, [props]);\n\n useEffect(() => {\n return () => {\n if (chartContext) {\n if (chartContext.current && chartContext.current.chart) {\n chartContext.current.chart.release();\n chartContext.current.chart = null;\n }\n }\n eventsBinded.current = null;\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootChartContext.Provider value={chartContext.current}>\n <ViewContext.Provider value={view}>\n {toArray(props.children).map((child, index) => {\n if (typeof child === 'string') {\n return null;\n }\n\n const childId = getComponentId(child, index);\n\n return (\n <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\n })}\n </React.Fragment>\n );\n })}\n {tooltipNode}\n </ViewContext.Provider>\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n registers?: (() => void)[]\n) => {\n if (registers && registers.length && defaultProps.vchartConstrouctor) {\n defaultProps.vchartConstrouctor.useRegisters(registers);\n }\n\n const Com = withContainer<ContainerProps, T>(BaseChart as any, componentName, (props: T) => {\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/charts/BaseChart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,+CAAgF;AAEhF,gFAAwD;AAExD,6DAAgD;AAChD,6CAAwE;AACxE,kCAAkC;AAClC,4CAAmD;AAYnD,gDAAoF;AAEpF,qDAA+D;AAqD/D,MAAM,WAAW,GAAG;IAClB,GAAG,+BAAmB;IACtB,GAAG,+BAAiB;IACpB,oBAAoB;IACpB,eAAe;IACf,kBAAkB;IAClB,SAAS;IACT,SAA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AE;YAChB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAjBW,QAAA,WAAW,eAiBtB","file":"BaseChart.js","sourcesContent":["import type {\n IVChart,\n IData,\n IInitOption,\n ISpec,\n IVChartConstructor,\n IHierarchyData,\n IVChartRenderOption\n} from '@visactor/vchart';\nimport type { ReactNode } from 'react';\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react';\nimport type { ContainerProps } from '../containers/withContainer';\nimport withContainer from '../containers/withContainer';\nimport type { ChartContextType } from '../context/chart';\nimport RootChartContext from '../context/chart';\nimport { isEqual, isNil, isValid, pickWithout } from '@visactor/vutils';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport type {\n EventsProps,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps\n} from '../eventsUtils';\nimport { bindEventsToChart, CHART_EVENTS_KEYS, CHART_EVENTS } from '../eventsUtils';\nimport type { IReactTooltipProps } from '../components/tooltip/interface';\nimport { initCustomTooltip } from '../components/tooltip/util';\n\nexport type ChartOptions = Omit<IInitOption, 'dom'>;\n\nexport interface BaseChartProps\n extends EventsProps,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps,\n IReactTooltipProps {\n vchartConstrouctor?: IVChartConstructor;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: ISpec;\n /** 数据 */\n data?: IData | IHierarchyData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n /** skip function diff when component update */\n skipFunctionDiff?: boolean;\n /**\n * add `morphConfig` for chart\n * @since 1.12.7\n */\n morphConfig?: IVChartRenderOption['morphConfig'];\n /** 图表渲染完成事件 */\n onReady?: (instance: IVChart, isInitial: boolean) => void;\n /** throw error when chart run into an error */\n onError?: (err: Error) => void;\n /**\n * use sync render\n *\n * @since 1.8.3\n * @deprecated 1.9.0\n **/\n useSyncRender?: boolean;\n}\n\ntype Props = React.PropsWithChildren<BaseChartProps>;\n\nconst notSpecKeys = [\n ...REACT_PRIVATE_PROPS,\n ...CHART_EVENTS_KEYS,\n 'vchartConstrouctor',\n 'useSyncRender',\n 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'spec',\n 'container',\n 'options',\n 'morphConfig'\n];\nconst defaultMorphConfig = {\n morph: false,\n enableExitAnimation: false\n};\n\nconst getComponentId = (child: React.ReactNode, index: number) => {\n const componentName = child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n return `${componentName}-${index}`;\n};\n\nconst parseSpecFromChildren = (props: Props) => {\n const specFromChildren: Omit<ISpec, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map((child, index) => {\n const parseSpec = child && (child as any).type && (child as any).type.parseSpec;\n\n if (parseSpec && (child as any).props) {\n const childProps = isNil((child as any).props.componentId)\n ? {\n ...(child as any).props,\n componentId: getComponentId(child, index)\n }\n : (child as any).props;\n\n const specResult = parseSpec(childProps);\n\n if (specResult.isSingle) {\n (specFromChildren as any)[specResult.specName] = specResult.spec;\n } else {\n if (!(specFromChildren as any)[specResult.specName]) {\n (specFromChildren as any)[specResult.specName] = [];\n }\n\n (specFromChildren as any)[specResult.specName].push(specResult.spec);\n }\n }\n });\n\n return specFromChildren;\n};\n\nconst BaseChart: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const chartContext = useRef<ChartContextType>({});\n useImperativeHandle(ref, () => chartContext.current?.chart);\n const hasSpec = !!props.spec;\n const isUnmount = useRef<boolean>(false);\n const prevSpec = useRef(pickWithout(props, notSpecKeys));\n const specFromChildren = useRef<Omit<ISpec, 'type' | 'data' | 'width' | 'height'>>(null);\n const eventsBinded = React.useRef<BaseChartProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n const [tooltipNode, setTooltipNode] = useState<ReactNode>(null);\n\n const parseSpec = (props: Props) => {\n let spec: ISpec;\n\n if (hasSpec && props.spec) {\n spec = props.spec;\n\n if (isValid(props.data)) {\n spec = {\n ...props.spec,\n data: props.data\n } as ISpec;\n }\n } else {\n spec = {\n ...prevSpec.current,\n ...specFromChildren.current\n } as ISpec;\n }\n\n const tooltipSpec = initCustomTooltip(setTooltipNode, props, spec.tooltip);\n if (tooltipSpec) {\n spec.tooltip = tooltipSpec;\n }\n return spec;\n };\n\n const createChart = (props: Props) => {\n const cs = new props.vchartConstrouctor(parseSpec(props), {\n ...props.options,\n onError: props.onError,\n autoFit: true,\n dom: props.container\n });\n chartContext.current = { ...chartContext.current, chart: cs };\n isUnmount.current = false;\n };\n\n const handleChartRender = (rebindEvent?: boolean) => {\n // rebind events after render\n if (!isUnmount.current) {\n if (!chartContext.current || !chartContext.current.chart) {\n return;\n }\n\n if (rebindEvent) {\n bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);\n }\n\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(chartContext.current.chart, updateId === 0);\n }\n }\n };\n\n const renderChart = () => {\n if (chartContext.current.chart) {\n // event should bind before render when the chart has not been rendered\n bindEventsToChart(chartContext.current.chart, props, eventsBinded.current, CHART_EVENTS);\n\n chartContext.current.chart.renderSync({\n reuse: false\n });\n handleChartRender();\n }\n };\n\n useEffect(() => {\n const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);\n\n if (!chartContext.current?.chart) {\n if (!hasSpec) {\n specFromChildren.current = newSpecFromChildren;\n }\n\n createChart(props);\n renderChart();\n eventsBinded.current = props;\n return;\n }\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec, { skipFunction: skipFunctionDiff })) {\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, props.morphConfig ?? defaultMorphConfig);\n handleChartRender(true);\n eventsBinded.current = props;\n } else if (eventsBinded.current.data !== props.data) {\n chartContext.current.chart.updateFullDataSync(props.data as any);\n handleChartRender(true);\n eventsBinded.current = props;\n }\n return;\n }\n\n const newSpec = pickWithout(props, notSpecKeys);\n\n if (\n !isEqual(newSpec, prevSpec.current, { skipFunction: skipFunctionDiff }) ||\n !isEqual(newSpecFromChildren, specFromChildren.current, { skipFunction: skipFunctionDiff })\n ) {\n prevSpec.current = newSpec;\n specFromChildren.current = newSpecFromChildren;\n\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, props.morphConfig ?? defaultMorphConfig);\n handleChartRender(true);\n eventsBinded.current = props;\n }\n }, [props]);\n\n useEffect(() => {\n return () => {\n if (chartContext) {\n if (chartContext.current && chartContext.current.chart) {\n chartContext.current.chart.release();\n chartContext.current.chart = null;\n }\n }\n eventsBinded.current = null;\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootChartContext.Provider value={chartContext.current}>\n {toArray(props.children).map((child, index) => {\n if (typeof child === 'string') {\n return null;\n }\n\n const childId = getComponentId(child, index);\n\n return (\n <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\n })}\n </React.Fragment>\n );\n })}\n {tooltipNode}\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n registers?: (() => void)[]\n) => {\n if (registers && registers.length && defaultProps.vchartConstrouctor) {\n defaultProps.vchartConstrouctor.useRegisters(registers);\n }\n\n const Com = withContainer<T>(BaseChart as any, componentName, (props: T) => {\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { IFunnel3dChartSpec } from '@visactor/vchart';
|
|
3
2
|
import type { BaseChartProps } from './BaseChart';
|
|
3
|
+
import type { IFunnel3dChartSpec } from '@visactor/vchart-extension';
|
|
4
4
|
export interface Funnel3dChartProps extends Omit<BaseChartProps, 'container' | 'type' | 'data'>, Omit<Partial<IFunnel3dChartSpec>, 'type'> {
|
|
5
5
|
}
|
|
6
6
|
export declare const Funnel3dChart: React.ForwardRefExoticComponent<Funnel3dChartProps & {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
} & {
|
|
9
9
|
type?: 'funnel3d';
|
|
10
|
-
} &
|
|
10
|
+
} & React.RefAttributes<any>>;
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Funnel3dChart = void 0;
|
|
6
6
|
|
|
7
|
-
const vchart_1 = require("@visactor/vchart"), BaseChart_1 = require("./BaseChart"), simple_1 = require("./registers/simple");
|
|
7
|
+
const vchart_1 = require("@visactor/vchart"), BaseChart_1 = require("./BaseChart"), simple_1 = require("./registers/simple"), vchart_extension_1 = require("@visactor/vchart-extension");
|
|
8
8
|
|
|
9
9
|
exports.Funnel3dChart = (0, BaseChart_1.createChart)("Funnel3dChart", {
|
|
10
10
|
type: "funnel3d",
|
|
11
11
|
vchartConstrouctor: vchart_1.VChart
|
|
12
|
-
}, [
|
|
12
|
+
}, [ vchart_extension_1.registerFunnel3dChart, vchart_1.registerLabel, ...simple_1.registers ]);
|
|
13
13
|
//# sourceMappingURL=Funnel3dChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/Funnel3dChart.tsx"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"sources":["../src/charts/Funnel3dChart.tsx"],"names":[],"mappings":";;;AAEA,6CAAyD;AAEzD,2CAA0C;AAC1C,+CAA+C;AAE/C,iEAAmE;AAMtD,QAAA,aAAa,GAAG,IAAA,uBAAW,EACtC,eAAe,EACf;IACE,IAAI,EAAE,UAAU;IAChB,kBAAkB,EAAE,eAA4B;CACjD,EACD,CAAC,wCAAqB,EAAE,sBAAa,EAAE,GAAG,kBAAS,CAAC,CACrD,CAAC","file":"Funnel3dChart.js","sourcesContent":["import type React from 'react';\nimport type { IVChartConstructor } from '@visactor/vchart';\nimport { VChart, registerLabel } from '@visactor/vchart';\nimport type { BaseChartProps } from './BaseChart';\nimport { createChart } from './BaseChart';\nimport { registers } from './registers/simple';\nimport type { IFunnel3dChartSpec } from '@visactor/vchart-extension';\nimport { registerFunnel3dChart } from '@visactor/vchart-extension';\n\nexport interface Funnel3dChartProps\n extends Omit<BaseChartProps, 'container' | 'type' | 'data'>,\n Omit<Partial<IFunnel3dChartSpec>, 'type'> {}\n\nexport const Funnel3dChart = createChart<React.PropsWithChildren<Funnel3dChartProps> & { type?: 'funnel3d' }>(\n 'Funnel3dChart',\n {\n type: 'funnel3d',\n vchartConstrouctor: VChart as IVChartConstructor\n },\n [registerFunnel3dChart, registerLabel, ...registers]\n);\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { IHistogram3dChartSpec } from '@visactor/vchart';
|
|
3
2
|
import type { BaseChartProps } from './BaseChart';
|
|
3
|
+
import type { IHistogram3dChartSpec } from '@visactor/vchart-extension';
|
|
4
4
|
export interface Histogram3dChartProps extends Omit<BaseChartProps, 'container' | 'type' | 'data'>, Omit<Partial<IHistogram3dChartSpec>, 'type'> {
|
|
5
5
|
}
|
|
6
6
|
export declare const Histogram3dChart: React.ForwardRefExoticComponent<Histogram3dChartProps & {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
} & {
|
|
9
9
|
type?: 'histogram3d';
|
|
10
|
-
} &
|
|
10
|
+
} & React.RefAttributes<any>>;
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Histogram3dChart = void 0;
|
|
6
6
|
|
|
7
|
-
const vchart_1 = require("@visactor/vchart"), BaseChart_1 = require("./BaseChart"), cartesian_1 = require("./registers/cartesian");
|
|
7
|
+
const vchart_1 = require("@visactor/vchart"), BaseChart_1 = require("./BaseChart"), cartesian_1 = require("./registers/cartesian"), vchart_extension_1 = require("@visactor/vchart-extension");
|
|
8
8
|
|
|
9
9
|
exports.Histogram3dChart = (0, BaseChart_1.createChart)("Histogram3dChart", {
|
|
10
10
|
type: "histogram3d",
|
|
11
11
|
vchartConstrouctor: vchart_1.VChart
|
|
12
|
-
}, [
|
|
12
|
+
}, [ vchart_extension_1.registerHistogram3dChart, vchart_1.registerLabel, ...cartesian_1.registers ]);
|
|
13
13
|
//# sourceMappingURL=Histogram3dChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/Histogram3dChart.tsx"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"sources":["../src/charts/Histogram3dChart.tsx"],"names":[],"mappings":";;;AAEA,6CAAyD;AAEzD,2CAA0C;AAC1C,qDAAkD;AAElD,iEAAsE;AAMzD,QAAA,gBAAgB,GAAG,IAAA,uBAAW,EACzC,kBAAkB,EAClB;IACE,IAAI,EAAE,aAAa;IACnB,kBAAkB,EAAE,eAA4B;CACjD,EACD,CAAC,2CAAwB,EAAE,sBAAa,EAAE,GAAG,qBAAS,CAAC,CACxD,CAAC","file":"Histogram3dChart.js","sourcesContent":["import type React from 'react';\nimport type { IVChartConstructor } from '@visactor/vchart';\nimport { VChart, registerLabel } from '@visactor/vchart';\nimport type { BaseChartProps } from './BaseChart';\nimport { createChart } from './BaseChart';\nimport { registers } from './registers/cartesian';\nimport type { IHistogram3dChartSpec } from '@visactor/vchart-extension';\nimport { registerHistogram3dChart } from '@visactor/vchart-extension';\n\nexport interface Histogram3dChartProps\n extends Omit<BaseChartProps, 'container' | 'type' | 'data'>,\n Omit<Partial<IHistogram3dChartSpec>, 'type'> {}\n\nexport const Histogram3dChart = createChart<React.PropsWithChildren<Histogram3dChartProps> & { type?: 'histogram3d' }>(\n 'Histogram3dChart',\n {\n type: 'histogram3d',\n vchartConstrouctor: VChart as IVChartConstructor\n },\n [registerHistogram3dChart, registerLabel, ...registers]\n);\n"]}
|
package/cjs/charts/MapChart.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export declare const PictogramChart: React.ForwardRefExoticComponent<Omit<Pictog
|
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
} & {
|
|
9
9
|
type?: 'pictogram';
|
|
10
|
-
}
|
|
10
|
+
}, "ref"> & React.RefAttributes<any>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { IPie3dChartSpec } from '@visactor/vchart';
|
|
3
2
|
import type { BaseChartProps } from './BaseChart';
|
|
3
|
+
import type { IPie3dChartSpec } from '@visactor/vchart-extension';
|
|
4
4
|
export interface Pie3dChartProps extends Omit<BaseChartProps, 'container' | 'type' | 'data'>, Omit<Partial<IPie3dChartSpec>, 'type'> {
|
|
5
5
|
}
|
|
6
6
|
export declare const Pie3dChart: React.ForwardRefExoticComponent<Pie3dChartProps & {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
} & {
|
|
9
9
|
type?: 'pie3d';
|
|
10
|
-
} &
|
|
10
|
+
} & React.RefAttributes<any>>;
|
package/cjs/charts/Pie3dChart.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.Pie3dChart = void 0;
|
|
6
6
|
|
|
7
|
-
const vchart_1 = require("@visactor/vchart"), BaseChart_1 = require("./BaseChart"), simple_1 = require("./registers/simple");
|
|
7
|
+
const vchart_1 = require("@visactor/vchart"), BaseChart_1 = require("./BaseChart"), simple_1 = require("./registers/simple"), vchart_extension_1 = require("@visactor/vchart-extension");
|
|
8
8
|
|
|
9
9
|
exports.Pie3dChart = (0, BaseChart_1.createChart)("Pie3dChart", {
|
|
10
10
|
type: "pie3d",
|
|
11
11
|
vchartConstrouctor: vchart_1.VChart
|
|
12
|
-
}, [
|
|
12
|
+
}, [ vchart_extension_1.registerPie3dChart, vchart_1.registerLabel, vchart_1.registerIndicator, ...simple_1.registers ]);
|
|
13
13
|
//# sourceMappingURL=Pie3dChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/Pie3dChart.tsx"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"sources":["../src/charts/Pie3dChart.tsx"],"names":[],"mappings":";;;AAEA,6CAA4E;AAE5E,2CAA0C;AAC1C,+CAA+C;AAC/C,iEAAgE;AAOnD,QAAA,UAAU,GAAG,IAAA,uBAAW,EACnC,YAAY,EACZ;IACE,IAAI,EAAE,OAAO;IACb,kBAAkB,EAAE,eAA4B;CACjD,EACD,CAAC,qCAAkB,EAAE,sBAAa,EAAE,0BAAiB,EAAE,GAAG,kBAAS,CAAC,CACrE,CAAC","file":"Pie3dChart.js","sourcesContent":["import type React from 'react';\nimport type { IVChartConstructor } from '@visactor/vchart';\nimport { VChart, registerIndicator, registerLabel } from '@visactor/vchart';\nimport type { BaseChartProps } from './BaseChart';\nimport { createChart } from './BaseChart';\nimport { registers } from './registers/simple';\nimport { registerPie3dChart } from '@visactor/vchart-extension';\nimport type { IPie3dChartSpec } from '@visactor/vchart-extension';\n\nexport interface Pie3dChartProps\n extends Omit<BaseChartProps, 'container' | 'type' | 'data'>,\n Omit<Partial<IPie3dChartSpec>, 'type'> {}\n\nexport const Pie3dChart = createChart<React.PropsWithChildren<Pie3dChartProps> & { type?: 'pie3d' }>(\n 'Pie3dChart',\n {\n type: 'pie3d',\n vchartConstrouctor: VChart as IVChartConstructor\n },\n [registerPie3dChart, registerLabel, registerIndicator, ...registers]\n);\n"]}
|
package/cjs/charts/PieChart.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { IRangeColumn3dChartSpec } from '@visactor/vchart';
|
|
3
2
|
import type { BaseChartProps } from './BaseChart';
|
|
3
|
+
import type { IRangeColumn3dChartSpec } from '@visactor/vchart-extension';
|
|
4
4
|
export interface RangeColumn3dChartProps extends Omit<BaseChartProps, 'container' | 'type' | 'data'>, Omit<Partial<IRangeColumn3dChartSpec>, 'type'> {
|
|
5
5
|
}
|
|
6
6
|
export declare const RangeColumn3dChart: React.ForwardRefExoticComponent<RangeColumn3dChartProps & {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
} & {
|
|
9
9
|
type?: 'rangeColumn3d';
|
|
10
|
-
} &
|
|
10
|
+
} & React.RefAttributes<any>>;
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.RangeColumn3dChart = void 0;
|
|
6
6
|
|
|
7
|
-
const vchart_1 = require("@visactor/vchart"), cartesian_1 = require("./registers/cartesian"), BaseChart_1 = require("./BaseChart");
|
|
7
|
+
const vchart_1 = require("@visactor/vchart"), cartesian_1 = require("./registers/cartesian"), BaseChart_1 = require("./BaseChart"), vchart_extension_1 = require("@visactor/vchart-extension");
|
|
8
8
|
|
|
9
9
|
exports.RangeColumn3dChart = (0, BaseChart_1.createChart)("RangeColumn3dChart", {
|
|
10
10
|
type: "rangeColumn3d",
|
|
11
11
|
vchartConstrouctor: vchart_1.VChart
|
|
12
|
-
}, [
|
|
12
|
+
}, [ vchart_extension_1.registerRangeColumn3dChart, vchart_1.registerLabel, ...cartesian_1.registers ]);
|
|
13
13
|
//# sourceMappingURL=RangeColumn3dChart.js.map
|