@visactor/react-vchart 1.10.0-alpha.0 → 1.10.0-alpha.4
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/cjs/charts/BaseChart.js +28 -21
- package/cjs/charts/BaseChart.js.map +1 -1
- package/cjs/components/BaseComponent.d.ts +1 -0
- package/cjs/components/BaseComponent.js +9 -35
- package/cjs/components/BaseComponent.js.map +1 -1
- package/cjs/components/Mark.d.ts +4 -14
- package/cjs/components/Mark.js +2 -61
- package/cjs/components/Mark.js.map +1 -1
- package/cjs/containers/withContainer.d.ts +1 -1
- package/cjs/containers/withContainer.js.map +1 -1
- package/cjs/context/chart.d.ts +0 -1
- package/cjs/context/chart.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/series/Area.d.ts +1 -0
- package/cjs/series/Bar.d.ts +1 -0
- package/cjs/series/BaseSeries.d.ts +1 -0
- package/cjs/series/BaseSeries.js +22 -49
- package/cjs/series/BaseSeries.js.map +1 -1
- package/cjs/series/BoxPlot.d.ts +1 -0
- package/cjs/series/CircularProgress.d.ts +1 -0
- package/cjs/series/Dot.d.ts +1 -0
- package/cjs/series/Funnel.d.ts +1 -0
- package/cjs/series/Line.d.ts +1 -0
- package/cjs/series/LinearProgress.d.ts +1 -0
- package/cjs/series/Link.d.ts +1 -0
- package/cjs/series/Map.d.ts +1 -0
- package/cjs/series/Pie.d.ts +1 -0
- package/cjs/series/Radar.d.ts +1 -0
- package/cjs/series/RangeColumn.d.ts +1 -0
- package/cjs/series/Rose.d.ts +1 -0
- package/cjs/series/Scatter.d.ts +1 -0
- package/cjs/series/Series.d.ts +1 -0
- package/cjs/series/WordCloud.d.ts +1 -0
- package/esm/charts/BaseChart.js +27 -21
- package/esm/charts/BaseChart.js.map +1 -1
- package/esm/components/BaseComponent.d.ts +1 -0
- package/esm/components/BaseComponent.js +9 -36
- package/esm/components/BaseComponent.js.map +1 -1
- package/esm/components/Mark.d.ts +4 -14
- package/esm/components/Mark.js +2 -39
- package/esm/components/Mark.js.map +1 -1
- package/esm/containers/withContainer.d.ts +1 -1
- package/esm/containers/withContainer.js.map +1 -1
- package/esm/context/chart.d.ts +0 -1
- package/esm/context/chart.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/series/Area.d.ts +1 -0
- package/esm/series/Bar.d.ts +1 -0
- package/esm/series/BaseSeries.d.ts +1 -0
- package/esm/series/BaseSeries.js +22 -50
- package/esm/series/BaseSeries.js.map +1 -1
- package/esm/series/BoxPlot.d.ts +1 -0
- package/esm/series/CircularProgress.d.ts +1 -0
- package/esm/series/Dot.d.ts +1 -0
- package/esm/series/Funnel.d.ts +1 -0
- package/esm/series/Line.d.ts +1 -0
- package/esm/series/LinearProgress.d.ts +1 -0
- package/esm/series/Link.d.ts +1 -0
- package/esm/series/Map.d.ts +1 -0
- package/esm/series/Pie.d.ts +1 -0
- package/esm/series/Radar.d.ts +1 -0
- package/esm/series/RangeColumn.d.ts +1 -0
- package/esm/series/Rose.d.ts +1 -0
- package/esm/series/Scatter.d.ts +1 -0
- package/esm/series/Series.d.ts +1 -0
- package/esm/series/WordCloud.d.ts +1 -0
- package/package.json +6 -6
package/cjs/charts/BaseChart.js
CHANGED
|
@@ -33,19 +33,25 @@ 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"), view_1 = __importDefault(require("../context/view")), util_1 = require("../util"), constants_1 = require("../constants"), eventsUtils_1 = require("../eventsUtils"), notSpecKeys = [ ...constants_1.REACT_PRIVATE_PROPS, ...eventsUtils_1.CHART_EVENTS_KEYS, "skipFunctionDiff", "onError", "onReady", "spec", "container", "options" ],
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const react_1 = __importStar(require("react")), withContainer_1 = __importDefault(require("../containers/withContainer")), chart_1 = __importDefault(require("../context/chart")), vutils_1 = require("@visactor/vutils"), view_1 = __importDefault(require("../context/view")), util_1 = require("../util"), constants_1 = require("../constants"), eventsUtils_1 = require("../eventsUtils"), notSpecKeys = [ ...constants_1.REACT_PRIVATE_PROPS, ...eventsUtils_1.CHART_EVENTS_KEYS, "vchartConstrouctor", "useSyncRender", "skipFunctionDiff", "onError", "onReady", "spec", "container", "options" ], parseSpecFromChildren = props => {
|
|
37
|
+
const specFromChildren = {};
|
|
38
|
+
return (0, util_1.toArray)(props.children).map((child => {
|
|
39
|
+
const parseSpec = child && child.type && child.type.parseSpec;
|
|
40
|
+
if (parseSpec && child.props) {
|
|
41
|
+
const specResult = parseSpec(child.props);
|
|
42
|
+
specResult.isSingle ? specFromChildren[specResult.specName] = specResult.spec : (specFromChildren[specResult.specName] || (specFromChildren[specResult.specName] = []),
|
|
43
|
+
specFromChildren[specResult.specName].push(specResult.spec));
|
|
44
|
+
}
|
|
45
|
+
})), specFromChildren;
|
|
46
|
+
}, BaseChart = react_1.default.forwardRef(((props, ref) => {
|
|
47
|
+
const [updateId, setUpdateId] = (0, react_1.useState)(0), chartContext = (0, react_1.useRef)({});
|
|
40
48
|
(0, react_1.useImperativeHandle)(ref, (() => {
|
|
41
49
|
var _a;
|
|
42
50
|
return null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart;
|
|
43
51
|
}));
|
|
44
52
|
const hasSpec = !!props.spec, [view, setView] = (0, react_1.useState)(null), isUnmount = (0,
|
|
45
|
-
react_1.useRef)(!1), prevSpec = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notSpecKeys)),
|
|
46
|
-
|
|
47
|
-
return hasSpec && props.spec ? props.spec : Object.assign(Object.assign({}, prevSpec.current), null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.specFromChildren);
|
|
48
|
-
}, handleChartRender = () => {
|
|
53
|
+
react_1.useRef)(!1), prevSpec = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notSpecKeys)), specFromChildren = (0,
|
|
54
|
+
react_1.useRef)(null), eventsBinded = react_1.default.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, parseSpec = props => hasSpec && props.spec ? props.spec : Object.assign(Object.assign({}, prevSpec.current), specFromChildren.current), handleChartRender = () => {
|
|
49
55
|
if (!isUnmount.current) {
|
|
50
56
|
if (!chartContext.current || !chartContext.current.chart) return;
|
|
51
57
|
(0, eventsUtils_1.bindEventsToChart)(chartContext.current.chart, props, eventsBinded.current, eventsUtils_1.CHART_EVENTS);
|
|
@@ -56,7 +62,9 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
|
|
|
56
62
|
};
|
|
57
63
|
return (0, react_1.useEffect)((() => {
|
|
58
64
|
var _a;
|
|
59
|
-
|
|
65
|
+
const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);
|
|
66
|
+
if (!(null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart)) return hasSpec || (specFromChildren.current = newSpecFromChildren),
|
|
67
|
+
(props => {
|
|
60
68
|
const cs = new props.vchartConstrouctor(parseSpec(props), Object.assign(Object.assign({}, props.options), {
|
|
61
69
|
onError: props.onError,
|
|
62
70
|
autoFit: !0,
|
|
@@ -68,9 +76,7 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
|
|
|
68
76
|
})(props), chartContext.current.chart && (chartContext.current.chart.renderSync({
|
|
69
77
|
reuse: !1
|
|
70
78
|
}), handleChartRender()), (0, eventsUtils_1.bindEventsToChart)(chartContext.current.chart, props, null, eventsUtils_1.CHART_EVENTS),
|
|
71
|
-
|
|
72
|
-
isChildrenUpdated: !1
|
|
73
|
-
}), void (eventsBinded.current = props);
|
|
79
|
+
void (eventsBinded.current = props);
|
|
74
80
|
if (hasSpec) return void ((0, vutils_1.isEqual)(eventsBinded.current.spec, props.spec, {
|
|
75
81
|
skipFunction: skipFunctionDiff
|
|
76
82
|
}) || (eventsBinded.current = props, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
|
|
@@ -80,25 +86,26 @@ const react_1 = __importStar(require("react")), withContainer_1 = __importDefaul
|
|
|
80
86
|
const newSpec = (0, vutils_1.pickWithout)(props, notSpecKeys);
|
|
81
87
|
(0, vutils_1.isEqual)(newSpec, prevSpec.current, {
|
|
82
88
|
skipFunction: skipFunctionDiff
|
|
83
|
-
}) &&
|
|
89
|
+
}) && (0, vutils_1.isEqual)(newSpecFromChildren, specFromChildren.current) || (prevSpec.current = newSpec,
|
|
90
|
+
specFromChildren.current = newSpecFromChildren, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
|
|
84
91
|
morph: !1,
|
|
85
92
|
enableExitAnimation: !1
|
|
86
|
-
}), handleChartRender())
|
|
87
|
-
isChildrenUpdated: !1
|
|
88
|
-
});
|
|
93
|
+
}), handleChartRender());
|
|
89
94
|
}), [ props ]), (0, react_1.useEffect)((() => () => {
|
|
90
|
-
chartContext &&
|
|
91
|
-
chartContext.current = null), isUnmount.current = !0;
|
|
95
|
+
chartContext && chartContext.current && chartContext.current.chart && (chartContext.current.chart.release(),
|
|
96
|
+
chartContext.current.chart = null), isUnmount.current = !0;
|
|
92
97
|
}), []), react_1.default.createElement(chart_1.default.Provider, {
|
|
93
98
|
value: chartContext.current
|
|
94
99
|
}, react_1.default.createElement(view_1.default.Provider, {
|
|
95
100
|
value: view
|
|
96
101
|
}, (0, util_1.toArray)(props.children).map(((child, index) => {
|
|
97
|
-
|
|
102
|
+
if ("string" == typeof child) return;
|
|
103
|
+
const childId = `${child && child.type && (child.type.displayName || child.type.name)}-${index}`;
|
|
98
104
|
return react_1.default.createElement(react_1.default.Fragment, {
|
|
99
|
-
key:
|
|
105
|
+
key: childId
|
|
100
106
|
}, react_1.default.cloneElement(child, {
|
|
101
|
-
updateId: updateId
|
|
107
|
+
updateId: updateId,
|
|
108
|
+
componentId: childId
|
|
102
109
|
}));
|
|
103
110
|
}))));
|
|
104
111
|
})), createChart = (componentName, defaultProps, callback) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/BaseChart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAgF;AAChF,gFAA4E;AAC5E,6DAAsE;AAEtE,6CAAwD;AACxD,2DAA0C;AAC1C,kCAAkC;AAClC,4CAAmD;AAEnD,gDAawB;AA+CxB,MAAM,WAAW,GAAG;IAClB,GAAG,+BAAmB;IACtB,GAAG,+BAAiB;IACpB,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,MAAM;IACN,WAAW;IACX,SAAS;CACV,CAAC;AAEF,MAAM,SAAS,GAAoB,eAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAS,CAAC,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,IAAA,cAAM,EAAmB;QAC5C,gBAAgB,EAAE,EAAE;KACrB,CAAC,CAAC;IACH,IAAA,2BAAmB,EAAC,GAAG,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,YAAY,CAAC,OAAO,0CAAE,KAAK,CAAA,EAAA,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IAC7B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAQ,IAAI,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAA,cAAM,EAAU,KAAK,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAC,IAAA,oBAAW,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,eAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,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AK,uBAAL,KAAK,CAAU,KAAK,0CAAE,EAAE,mCAAK,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,EAAE,mCAAI,SAAS,KAAK,EAAE,IACrF,eAAK,CAAC,YAAY,CAAC,KAAqB,EAAE;gBACzC,QAAQ,EAAE,QAAQ;aACnB,CAAC,CACa,CAClB,CAAC;QACJ,CAAC,CAAC,CACmB,CACG,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,MAAM,WAAW,GAAG,CACzB,aAAqB,EACrB,YAAyB,EACzB,QAAqD,EACrD,EAAE;IACF,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAQ,EAAE,EAAE;QACzF,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtC;QAED,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 { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@visactor/vchart';\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react';\nimport withContainer, { ContainerProps } from '../containers/withContainer';\nimport RootChartContext, { ChartContextType } from '../context/chart';\nimport type { IView } from '@visactor/vgrammar-core';\nimport { isEqual, pickWithout } from '@visactor/vutils';\nimport ViewContext from '../context/view';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport { IMarkElement } from '../components';\nimport {\n bindEventsToChart,\n EventsProps,\n CHART_EVENTS_KEYS,\n CHART_EVENTS,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps\n} from '../eventsUtils';\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 vchartConstrouctor?: IVChartConstructor;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: ISpec;\n /** 数据 */\n data?: IData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n /** skip function diff when component update */\n skipFunctionDiff?: boolean;\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 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'spec',\n 'container',\n 'options'\n];\n\nconst BaseChart: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const chartContext = useRef<ChartContextType>({\n specFromChildren: {}\n });\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 eventsBinded = React.useRef<BaseChartProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n\n const parseSpec = (props: Props) => {\n if (hasSpec && props.spec) {\n return props.spec;\n }\n\n return {\n ...prevSpec.current,\n ...chartContext.current?.specFromChildren\n };\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 };\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 if (!chartContext.current?.chart) {\n createChart(props);\n renderChart();\n bindEventsToChart(chartContext.current.chart, props, null, CHART_EVENTS);\n chartContext.current = {\n ...chartContext.current,\n isChildrenUpdated: false\n };\n eventsBinded.current = props;\n return;\n }\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec, { skipFunction: skipFunctionDiff })) {\n eventsBinded.current = props;\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n return;\n }\n\n const newSpec = pickWithout(props, notSpecKeys);\n\n if (\n !isEqual(newSpec, prevSpec.current, { skipFunction: skipFunctionDiff }) ||\n chartContext.current.isChildrenUpdated\n ) {\n prevSpec.current = newSpec;\n\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\n }\n chartContext.current = {\n ...chartContext.current,\n isChildrenUpdated: false\n };\n }, [props]);\n\n useEffect(() => {\n return () => {\n if (chartContext) {\n if (chartContext.current.chart) {\n chartContext.current.chart.release();\n }\n chartContext.current = null;\n }\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 return (\n <React.Fragment key={(child as any)?.props?.id ?? (child as any)?.id ?? `child-${index}`}>\n {React.cloneElement(child as IMarkElement, {\n updateId: updateId\n })}\n </React.Fragment>\n );\n })}\n </ViewContext.Provider>\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n callback?: (props: T, defaultProps?: Partial<T>) => T\n) => {\n const Com = withContainer<ContainerProps, T>(BaseChart as any, componentName, (props: T) => {\n if (callback) {\n return callback(props, defaultProps);\n }\n\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAgF;AAChF,gFAA4E;AAC5E,6DAAsE;AAEtE,6CAAwD;AACxD,2DAA0C;AAC1C,kCAAkC;AAClC,4CAAmD;AACnD,gDAawB;AA+CxB,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;CACV,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAE,EAAE;IAC7C,MAAM,gBAAgB,GAAsD,EAAE,CAAC;IAE/E,IAAA,cAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAClC,MAAM,SAAS,GAAG,KAAK,IAAK,KAAa,CAAC,IAAI,IAAK,KAAa,CAAC,IAAI,CAAC,SAAS,CAAC;QAEhF,IAAI,SAAS,IAAK,KAAa,CAAC,KAAK,EAAE;YACrC,MAAM,UAAU,GAAG,SAAS,CAAE,KAAa,CAAC,KAAK,CAAC,CAAC;YA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KAAK,EAAE,KAAK,EAAE,EAAE;YAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBAC7B,OAAO;aACR;YAED,MAAM,aAAa,GACjB,KAAK,IAAK,KAAa,CAAC,IAAI,IAAI,CAAE,KAAa,CAAC,IAAI,CAAC,WAAW,IAAK,KAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChG,MAAM,OAAO,GAAG,GAAG,aAAa,IAAI,KAAK,EAAE,CAAC;YAE5C,OAAO,CACL,8BAAC,eAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,OAAO,IACzB,eAAK,CAAC,YAAY,CAAC,KAAkE,EAAE;gBACtF,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,OAAO;aACrB,CAAC,CACa,CAClB,CAAC;QACJ,CAAC,CAAC,CACmB,CACG,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,MAAM,WAAW,GAAG,CACzB,aAAqB,EACrB,YAAyB,EACzB,QAAqD,EACrD,EAAE;IACF,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAQ,EAAE,EAAE;QACzF,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtC;QAED,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 { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@visactor/vchart';\nimport React, { useState, useEffect, useRef, useImperativeHandle } from 'react';\nimport withContainer, { ContainerProps } from '../containers/withContainer';\nimport RootChartContext, { ChartContextType } from '../context/chart';\nimport type { IView } from '@visactor/vgrammar-core';\nimport { isEqual, pickWithout } from '@visactor/vutils';\nimport ViewContext from '../context/view';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport {\n bindEventsToChart,\n EventsProps,\n CHART_EVENTS_KEYS,\n CHART_EVENTS,\n LegendEventProps,\n ScrollBarEventProps,\n BrushEventProps,\n DataZoomEventProps,\n PlayerEventProps,\n DimensionEventProps,\n HierarchyEventProps,\n ChartLifeCycleEventProps\n} from '../eventsUtils';\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 vchartConstrouctor?: IVChartConstructor;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /**\n * used only by <VChart />\n */\n spec?: ISpec;\n /** 数据 */\n data?: IData;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n /** 图表配置 */\n options?: ChartOptions;\n /** skip function diff when component update */\n skipFunctionDiff?: boolean;\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];\n\nconst parseSpecFromChildren = (props: Props) => {\n const specFromChildren: Omit<ISpec, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map(child => {\n const parseSpec = child && (child as any).type && (child as any).type.parseSpec;\n\n if (parseSpec && (child as any).props) {\n const specResult = parseSpec((child as any).props);\n\n if (specResult.isSingle) {\n specFromChildren[specResult.specName] = specResult.spec;\n } else {\n if (!specFromChildren[specResult.specName]) {\n specFromChildren[specResult.specName] = [];\n }\n\n specFromChildren[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\n const parseSpec = (props: Props) => {\n if (hasSpec && props.spec) {\n return props.spec;\n }\n\n return {\n ...prevSpec.current,\n ...specFromChildren.current\n } as ISpec;\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 };\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 bindEventsToChart(chartContext.current.chart, props, null, CHART_EVENTS);\n eventsBinded.current = props;\n return;\n }\n\n if (hasSpec) {\n if (!isEqual(eventsBinded.current.spec, props.spec, { skipFunction: skipFunctionDiff })) {\n eventsBinded.current = props;\n chartContext.current.chart.updateSpecSync(parseSpec(props), undefined, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\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, {\n morph: false,\n enableExitAnimation: false\n });\n handleChartRender();\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 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;\n }\n\n const componentName =\n child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n const childId = `${componentName}-${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 </ViewContext.Provider>\n </RootChartContext.Provider>\n );\n});\n\nexport const createChart = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n callback?: (props: T, defaultProps?: Partial<T>) => T\n) => {\n const Com = withContainer<ContainerProps, T>(BaseChart as any, componentName, (props: T) => {\n if (callback) {\n return callback(props, defaultProps);\n }\n\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
|
|
@@ -4,6 +4,7 @@ export interface BaseComponentProps {
|
|
|
4
4
|
}
|
|
5
5
|
type ComponentProps = BaseComponentProps & {
|
|
6
6
|
updateId?: number;
|
|
7
|
+
componentId?: number;
|
|
7
8
|
};
|
|
8
9
|
export declare const createComponent: <T extends ComponentProps>(componentName: string, specName: string, supportedEvents?: Record<string, string> | null, isSingle?: boolean) => React.FC<T>;
|
|
9
10
|
export {};
|
|
@@ -33,49 +33,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
33
33
|
value: !0
|
|
34
34
|
}), exports.createComponent = void 0;
|
|
35
35
|
|
|
36
|
-
const react_1 = __importStar(require("react")), vutils_1 = require("@visactor/vutils"), chart_1 = __importDefault(require("../context/chart")), eventsUtils_1 = require("../eventsUtils"),
|
|
37
|
-
const ignoreKeys = [ "id", "updateId" ], notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys, Comp = props => {
|
|
38
|
-
const context = (0, react_1.useContext)(chart_1.default),
|
|
39
|
-
vutils_1.isNil)(props.id) ? (0, util_1.uid)(specName) : props.id), eventsBinded = react_1.default.useRef(null), updateId = react_1.default.useRef(props.updateId), componentSpec = react_1.default.useRef();
|
|
36
|
+
const react_1 = __importStar(require("react")), vutils_1 = require("@visactor/vutils"), chart_1 = __importDefault(require("../context/chart")), eventsUtils_1 = require("../eventsUtils"), createComponent = (componentName, specName, supportedEvents, isSingle) => {
|
|
37
|
+
const ignoreKeys = [ "id", "updateId", "componentId" ], notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys, Comp = props => {
|
|
38
|
+
const context = (0, react_1.useContext)(chart_1.default), eventsBinded = react_1.default.useRef(null), updateId = react_1.default.useRef(props.updateId);
|
|
40
39
|
if (props.updateId !== updateId.current) {
|
|
41
40
|
updateId.current = props.updateId;
|
|
42
41
|
!!supportedEvents && (0, eventsUtils_1.bindEventsToChart)(context.chart, props, eventsBinded.current, supportedEvents) && (eventsBinded.current = props);
|
|
43
|
-
} else {
|
|
44
|
-
const newComponentSpec = (0, vutils_1.pickWithout)(props, notSpecKeys);
|
|
45
|
-
(0, vutils_1.isEqual)(newComponentSpec, componentSpec.current) || (componentSpec.current = newComponentSpec,
|
|
46
|
-
updateToContext(context, id.current, specName, isSingle, newComponentSpec));
|
|
47
42
|
}
|
|
48
43
|
return (0, react_1.useEffect)((() => () => {
|
|
49
|
-
supportedEvents && (0, eventsUtils_1.bindEventsToChart)(context.chart, null, eventsBinded.current, supportedEvents)
|
|
50
|
-
deleteToContext(context, id.current, specName, isSingle);
|
|
44
|
+
supportedEvents && (0, eventsUtils_1.bindEventsToChart)(context.chart, null, eventsBinded.current, supportedEvents);
|
|
51
45
|
}), []), null;
|
|
52
46
|
};
|
|
53
|
-
return Comp.displayName = componentName, Comp
|
|
47
|
+
return Comp.displayName = componentName, Comp.parseSpec = props => ({
|
|
48
|
+
spec: (0, vutils_1.pickWithout)(props, notSpecKeys),
|
|
49
|
+
specName: specName,
|
|
50
|
+
isSingle: isSingle
|
|
51
|
+
}), Comp;
|
|
54
52
|
};
|
|
55
53
|
|
|
56
54
|
exports.createComponent = createComponent;
|
|
57
|
-
|
|
58
|
-
const updateToContext = (context, id, specName, isSingle, props) => {
|
|
59
|
-
if (context.specFromChildren) {
|
|
60
|
-
if (isSingle) context.specFromChildren[specName] = Object.assign({}, props); else {
|
|
61
|
-
context.specFromChildren[specName] || (context.specFromChildren[specName] = []);
|
|
62
|
-
const comps = context.specFromChildren[specName], index = comps.findIndex((entry => entry.id === id));
|
|
63
|
-
index >= 0 ? comps[index] = Object.assign({
|
|
64
|
-
id: id
|
|
65
|
-
}, props) : context.specFromChildren[specName].push(Object.assign({
|
|
66
|
-
id: id
|
|
67
|
-
}, props));
|
|
68
|
-
}
|
|
69
|
-
context.isChildrenUpdated = !0;
|
|
70
|
-
}
|
|
71
|
-
}, deleteToContext = (context, id, specName, isSingle) => {
|
|
72
|
-
var _a;
|
|
73
|
-
if (context.specFromChildren) if (isSingle) context.specFromChildren[specName] = null; else {
|
|
74
|
-
const comps = null !== (_a = context.specFromChildren[specName]) && void 0 !== _a ? _a : [], index = comps.findIndex((entry => entry.id === id));
|
|
75
|
-
if (index >= 0) {
|
|
76
|
-
const newComps = comps.slice(0, index - 1).concat(comps.slice(index + 1));
|
|
77
|
-
context.specFromChildren[specName] = newComps, context.isChildrenUpdated = !0;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
55
|
//# sourceMappingURL=BaseComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/BaseComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,6CAA+
|
|
1
|
+
{"version":3,"sources":["../src/components/BaseComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,6CAA+C;AAE/C,6DAAgD;AAChD,gDAAmD;AAQ5C,MAAM,eAAe,GAAG,CAC7B,aAAqB,EACrB,QAAgB,EAChB,eAA+C,EAC/C,QAAkB,EAClB,EAAE;IACF,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAEnG,MAAM,IAAI,GAAgB,CAAC,KAAQ,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,eAAgB,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAG,eAAK,CAAC,MAAM,CAAI,IAAI,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAS,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtD,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,OAAO,EAAE;YAEvC,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC;YAGlC,MAAM,mBAAmB,GAAG,eAAe;gBACzC,CAAC,CAAC,IAAA,+BAAiB,EAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC;gBAChF,CAAC,CAAC,KAAK,CAAC;YACV,IAAI,mBAAmB,EAAE;gBACvB,YAAY,CAAC,OAAO,GAAG,KAAK,CAAC;aAC9B;SACF;QAED,IAAA,iBAAS,EAAC,GAAG,EAAE;YACb,OAAO,GAAG,EAAE;gBACV,IAAI,eAAe,EAAE;oBACnB,IAAA,+BAAiB,EAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;iBAC/E;YACH,CAAC,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,IAAY,CAAC,SAAS,GAAG,CAAC,KAAsD,EAAE,EAAE;QACnF,MAAM,gBAAgB,GAAe,IAAA,oBAAW,EAAI,KAAK,EAAE,WAAW,CAAC,CAAC;QAExE,OAAO;YACL,IAAI,EAAE,gBAAgB;YACtB,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAjDW,QAAA,eAAe,mBAiD1B","file":"BaseComponent.js","sourcesContent":["import React, { useContext, useEffect } from 'react';\nimport { pickWithout } from '@visactor/vutils';\n\nimport RootChartContext from '../context/chart';\nimport { bindEventsToChart } from '../eventsUtils';\n\nexport interface BaseComponentProps {\n id?: string | number;\n}\n\ntype ComponentProps = BaseComponentProps & { updateId?: number; componentId?: number };\n\nexport const createComponent = <T extends ComponentProps>(\n componentName: string,\n specName: string,\n supportedEvents?: Record<string, string> | null,\n isSingle?: boolean\n) => {\n const ignoreKeys = ['id', 'updateId', 'componentId'];\n const notSpecKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys;\n\n const Comp: React.FC<T> = (props: T) => {\n const context = useContext(RootChartContext);\n const eventsBinded = React.useRef<T>(null);\n const updateId = React.useRef<number>(props.updateId);\n if (props.updateId !== updateId.current) {\n // update triggered by chart when chart is rendered\n updateId.current = props.updateId;\n\n // rebind events after chart render\n const hasPrevEventsBinded = supportedEvents\n ? bindEventsToChart(context.chart, props, eventsBinded.current, supportedEvents)\n : false;\n if (hasPrevEventsBinded) {\n eventsBinded.current = props;\n }\n }\n\n useEffect(() => {\n return () => {\n if (supportedEvents) {\n bindEventsToChart(context.chart, null, eventsBinded.current, supportedEvents);\n }\n };\n }, []);\n\n return null;\n };\n\n Comp.displayName = componentName;\n (Comp as any).parseSpec = (props: T & { updateId?: number; componentId?: string }) => {\n const newComponentSpec: Partial<T> = pickWithout<T>(props, notSpecKeys);\n\n return {\n spec: newComponentSpec,\n specName,\n isSingle\n };\n };\n\n return Comp;\n};\n"]}
|
package/cjs/components/Mark.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
glyphType?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface IMarkElement extends React.ReactElement<Props, React.JSXElementConstructor<Props>> {
|
|
8
|
-
id: string | number;
|
|
9
|
-
}
|
|
10
|
-
type Props = MarkProps & {
|
|
11
|
-
updateId?: number;
|
|
12
|
-
};
|
|
13
|
-
export declare const Mark: React.FC<Props>;
|
|
14
|
-
export {};
|
|
1
|
+
import type { ICustomMarkSpec, EnableMarkType } from '@visactor/vchart';
|
|
2
|
+
import { BaseComponentProps } from './BaseComponent';
|
|
3
|
+
export type MarkProps = ICustomMarkSpec<EnableMarkType> & BaseComponentProps;
|
|
4
|
+
export declare const Mark: import("react").FC<MarkProps>;
|
package/cjs/components/Mark.js
CHANGED
|
@@ -1,69 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
-
void 0 === k2 && (k2 = k);
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
-
enumerable: !0,
|
|
8
|
-
get: function() {
|
|
9
|
-
return m[k];
|
|
10
|
-
}
|
|
11
|
-
}), Object.defineProperty(o, k2, desc);
|
|
12
|
-
} : function(o, m, k, k2) {
|
|
13
|
-
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
-
}), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", {
|
|
16
|
-
enumerable: !0,
|
|
17
|
-
value: v
|
|
18
|
-
});
|
|
19
|
-
} : function(o, v) {
|
|
20
|
-
o.default = v;
|
|
21
|
-
}), __importStar = this && this.__importStar || function(mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
|
|
25
|
-
return __setModuleDefault(result, mod), result;
|
|
26
|
-
}, __rest = this && this.__rest || function(s, e) {
|
|
27
|
-
var t = {};
|
|
28
|
-
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
29
|
-
if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
|
|
30
|
-
var i = 0;
|
|
31
|
-
for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
32
|
-
}
|
|
33
|
-
return t;
|
|
34
|
-
}, __importDefault = this && this.__importDefault || function(mod) {
|
|
35
|
-
return mod && mod.__esModule ? mod : {
|
|
36
|
-
default: mod
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
3
|
Object.defineProperty(exports, "__esModule", {
|
|
41
4
|
value: !0
|
|
42
5
|
}), exports.Mark = void 0;
|
|
43
6
|
|
|
44
|
-
const
|
|
45
|
-
const context = (0, react_1.useContext)(view_1.default), id = react_1.default.useRef((0,
|
|
46
|
-
vutils_1.isNil)(props.id) ? (0, util_1.uid)("mark") : props.id), updateId = react_1.default.useRef(props.updateId);
|
|
47
|
-
return props.updateId !== updateId.current && (updateId.current = props.updateId,
|
|
48
|
-
context && addOrUpdateMark(context, id.current, props)), (0, react_1.useEffect)((() => () => {
|
|
49
|
-
context && removeMark(context, id.current);
|
|
50
|
-
}), []), null;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
exports.Mark = Mark;
|
|
7
|
+
const BaseComponent_1 = require("./BaseComponent");
|
|
54
8
|
|
|
55
|
-
|
|
56
|
-
var _a;
|
|
57
|
-
if (!view.renderer) return;
|
|
58
|
-
let mark = view.getMarkById(id);
|
|
59
|
-
const {group: group, glyphType: glyphType, updateId: updateId} = props, others = __rest(props, [ "group", "glyphType", "updateId" ]);
|
|
60
|
-
mark || (mark = view.mark(props.type, null !== (_a = props.group) && void 0 !== _a ? _a : view.rootMark, props.glyphType ? {
|
|
61
|
-
glyphType: props.glyphType
|
|
62
|
-
} : null).name(id)), mark.parse(others), view.run();
|
|
63
|
-
}, removeMark = (view, id) => {
|
|
64
|
-
if (view.renderer) {
|
|
65
|
-
view.getMarkById(id);
|
|
66
|
-
view.removeGrammar(id);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
9
|
+
exports.Mark = (0, BaseComponent_1.createComponent)("Mark", "customMark");
|
|
69
10
|
//# sourceMappingURL=Mark.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Mark.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/Mark.tsx"],"names":[],"mappings":";;;AACA,mDAAsE;AAIzD,QAAA,IAAI,GAAG,IAAA,+BAAe,EAAY,MAAM,EAAE,YAAY,CAAC,CAAC","file":"Mark.js","sourcesContent":["import type { ICustomMarkSpec, EnableMarkType } from '@visactor/vchart';\nimport { BaseComponentProps, createComponent } from './BaseComponent';\n\nexport type MarkProps = ICustomMarkSpec<EnableMarkType> & BaseComponentProps;\n\nexport const Mark = createComponent<MarkProps>('Mark', 'customMark');\n"]}
|
|
@@ -5,4 +5,4 @@ export interface ContainerProps {
|
|
|
5
5
|
width?: number | string;
|
|
6
6
|
height?: number | string;
|
|
7
7
|
}
|
|
8
|
-
export default function withContainer<Props extends ContainerProps, CompProps>(Comp:
|
|
8
|
+
export default function withContainer<Props extends ContainerProps, CompProps>(Comp: any, name?: string, getProps?: (props: any) => CompProps): React.ForwardRefExoticComponent<React.PropsWithoutRef<CompProps & Props> & React.RefAttributes<any>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/containers/withContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiE;AASjE,SAAwB,aAAa,CACnC,
|
|
1
|
+
{"version":3,"sources":["../src/containers/withContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiE;AASjE,SAAwB,aAAa,CACnC,IAAS,EACT,IAAI,GAAG,gBAAgB,EACvB,QAAoC;IAEpC,MAAM,GAAG,GAAG,eAAK,CAAC,UAAU,CAAyB,CAAC,KAAwB,EAAE,GAAG,EAAE,EAAE;QACrF,MAAM,SAAS,GAAG,IAAA,cAAM,GAAE,CAAC;QAC3B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,KAAiB,KAAK,EAAjB,OAAO,UAAK,KAAK,EAA/C,+BAAuC,CAAQ,CAAC;QAEtD,IAAA,uBAAe,EAAC,GAAG,EAAE;YACnB,SAAS,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,CACL,uCACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,SAAS,EACpB,KAAK,kBACH,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,MAAM,EAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,MAAM,IACzB,KAAK,KAGT,MAAM,CAAC,CAAC,CAAC,CACR,8BAAC,IAAI,kBAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,OAAO,IAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,OAAqB,CAAC,EAAI,CAC9G,CAAC,CAAC,CAAC,CACF,6DAAK,CACN,CACG,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAnCD,gCAmCC","file":"withContainer.js","sourcesContent":["import React, { useRef, useState, useLayoutEffect } from 'react';\n\nexport interface ContainerProps {\n style?: React.CSSProperties;\n className?: string;\n width?: number | string;\n height?: number | string;\n}\n\nexport default function withContainer<Props extends ContainerProps, CompProps>(\n Comp: any,\n name = 'ChartContainer',\n getProps?: (props: any) => CompProps\n) {\n const Cls = React.forwardRef<any, CompProps & Props>((props: CompProps & Props, ref) => {\n const container = useRef();\n const [inited, setInited] = useState(false);\n const { className, style, width, ...options } = props;\n\n useLayoutEffect(() => {\n setInited(true);\n }, []);\n\n return (\n <div\n ref={container}\n className={className}\n style={{\n position: 'relative',\n height: props.height || '100%',\n width: props.width || '100%',\n ...style\n }}\n >\n {inited ? (\n <Comp ref={ref} container={container.current} {...(getProps ? getProps(options) : (options as CompProps))} />\n ) : (\n <></>\n )}\n </div>\n );\n });\n Cls.displayName = name || Comp.name;\n return Cls;\n}\n"]}
|
package/cjs/context/chart.d.ts
CHANGED
package/cjs/context/chart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context/chart.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;
|
|
1
|
+
{"version":3,"sources":["../src/context/chart.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAQ1B,MAAM,YAAY,GAAG,eAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AACjE,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,SAAgB,iBAAiB,CAAI,SAAiC;IACpE,MAAM,GAAG,GAAG,eAAK,CAAC,UAAU,CAAS,CAAC,KAAQ,EAAE,GAAG,EAAE,EAAE;QACrD,OAAO,CACL,8BAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,GAAqB,EAAE,EAAE,CAAC,8BAAC,SAAS,kBAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,IAAM,KAAK,EAAI,CAC1D,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC;AAVD,8CAUC;AAED,kBAAe,YAAY,CAAC","file":"chart.js","sourcesContent":["import React from 'react';\nimport type { IVChart } from '@visactor/vchart';\n\nexport interface ChartContextType {\n chart?: IVChart;\n isChildrenUpdated?: boolean;\n}\n\nconst ChartContext = React.createContext<ChartContextType>(null);\nChartContext.displayName = 'ChartContext';\n\nexport function withChartInstance<T>(Component: typeof React.Component) {\n const Com = React.forwardRef<any, T>((props: T, ref) => {\n return (\n <ChartContext.Consumer>\n {(ctx: ChartContextType) => <Component ref={ref} chart={ctx.chart} {...props} />}\n </ChartContext.Consumer>\n );\n });\n Com.displayName = Component.name;\n return Com;\n}\n\nexport default ChartContext;\n"]}
|
package/cjs/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export * from './series';
|
|
|
3
3
|
export * from './components';
|
|
4
4
|
export * from './VChart';
|
|
5
5
|
export * from './VChartSimple';
|
|
6
|
-
export declare const version = "1.10.0-alpha.
|
|
6
|
+
export declare const version = "1.10.0-alpha.4";
|
|
7
7
|
export type { IAreaChartSpec, IBarChartSpec, IBar3dChartSpec, IBoxPlotChartSpec, ICirclePackingChartSpec, ICommonChartSpec, IFunnelChartSpec, IFunnel3dChartSpec, IGaugeChartSpec, IHeatmapChartSpec, IHistogramChartSpec, IHistogram3dChartSpec, ILineChartSpec, IMapChartSpec, IPieChartSpec, IPie3dChartSpec, ICircularProgressChartSpec, ILinearProgressChartSpec, IRadarChartSpec, IRangeColumnChartSpec, IRangeColumn3dChartSpec, IRangeAreaChartSpec, IRoseChartSpec, IScatterChartSpec, ISankeyChartSpec, ISequenceChartSpec, ISunburstChartSpec, ITreemapChartSpec, IWaterfallChartSpec, ICorrelationChartSpec, ILiquidChartSpec, IWordCloud3dChartSpec, IWordCloudChartSpec, IPolarChartSpec, ICartesianChartSpec, ITheme, IInitOption, ISpec, IVChart } from '@visactor/vchart';
|
package/cjs/index.js
CHANGED
|
@@ -19,5 +19,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
19
19
|
value: !0
|
|
20
20
|
}), exports.version = void 0, __exportStar(require("./charts"), exports), __exportStar(require("./series"), exports),
|
|
21
21
|
__exportStar(require("./components"), exports), __exportStar(require("./VChart"), exports),
|
|
22
|
-
__exportStar(require("./VChartSimple"), exports), exports.version = "1.10.0-alpha.
|
|
22
|
+
__exportStar(require("./VChartSimple"), exports), exports.version = "1.10.0-alpha.4";
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,iDAA+B;AAGlB,QAAA,OAAO,GAAG,gBAAgB,CAAC","file":"index.js","sourcesContent":["export * from './charts';\nexport * from './series';\nexport * from './components';\nexport * from './VChart';\nexport * from './VChartSimple';\n\n// export the version, since @1.8.3\nexport const version = \"1.10.0-alpha.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,iDAA+B;AAGlB,QAAA,OAAO,GAAG,gBAAgB,CAAC","file":"index.js","sourcesContent":["export * from './charts';\nexport * from './series';\nexport * from './components';\nexport * from './VChart';\nexport * from './VChartSimple';\n\n// export the version, since @1.8.3\nexport const version = \"1.10.0-alpha.4\";\n\nexport type {\n IAreaChartSpec,\n IBarChartSpec,\n IBar3dChartSpec,\n IBoxPlotChartSpec,\n ICirclePackingChartSpec,\n ICommonChartSpec,\n IFunnelChartSpec,\n IFunnel3dChartSpec,\n IGaugeChartSpec,\n IHeatmapChartSpec,\n IHistogramChartSpec,\n IHistogram3dChartSpec,\n ILineChartSpec,\n IMapChartSpec,\n IPieChartSpec,\n IPie3dChartSpec,\n ICircularProgressChartSpec,\n ILinearProgressChartSpec,\n IRadarChartSpec,\n IRangeColumnChartSpec,\n IRangeColumn3dChartSpec,\n IRangeAreaChartSpec,\n IRoseChartSpec,\n IScatterChartSpec,\n ISankeyChartSpec,\n ISequenceChartSpec,\n ISunburstChartSpec,\n ITreemapChartSpec,\n IWaterfallChartSpec,\n ICorrelationChartSpec,\n ILiquidChartSpec,\n IWordCloud3dChartSpec,\n IWordCloudChartSpec,\n IPolarChartSpec,\n ICartesianChartSpec,\n ITheme,\n IInitOption,\n ISpec,\n IVChart\n} from '@visactor/vchart';\n"]}
|
package/cjs/series/Area.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import type { IAreaSeriesSpec } from '@visactor/vchart';
|
|
|
3
3
|
export type AreaProps = BaseSeriesProps & Omit<IAreaSeriesSpec, 'type'>;
|
|
4
4
|
export declare const Area: import("react").FC<BaseSeriesProps & Omit<IAreaSeriesSpec, "type"> & {
|
|
5
5
|
updateId?: number;
|
|
6
|
+
componentId?: string;
|
|
6
7
|
}>;
|
package/cjs/series/Bar.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import type { IBarSeriesSpec } from '@visactor/vchart';
|
|
|
3
3
|
export type BarProps = BaseSeriesProps & Omit<IBarSeriesSpec, 'type'>;
|
|
4
4
|
export declare const Bar: import("react").FC<BaseSeriesProps & Omit<IBarSeriesSpec, "type"> & {
|
|
5
5
|
updateId?: number;
|
|
6
|
+
componentId?: string;
|
|
6
7
|
}>;
|
package/cjs/series/BaseSeries.js
CHANGED
|
@@ -10,11 +10,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
10
10
|
value: !0
|
|
11
11
|
}), exports.createSeries = void 0;
|
|
12
12
|
|
|
13
|
-
const react_1 = __importDefault(require("react")), vutils_1 = require("@visactor/vutils"), chart_1 = __importDefault(require("../context/chart")), eventsUtils_1 = require("../eventsUtils"),
|
|
14
|
-
const notSpecKeys = eventsUtils_1.COMMON_EVENTK_KEYS.concat([ "id", "updateId" ]), Comp = props => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const markIds = markNames.map((markName => `${id
|
|
13
|
+
const react_1 = __importDefault(require("react")), vutils_1 = require("@visactor/vutils"), chart_1 = __importDefault(require("../context/chart")), eventsUtils_1 = require("../eventsUtils"), createSeries = (componentName, markNames, type) => {
|
|
14
|
+
const notSpecKeys = eventsUtils_1.COMMON_EVENTK_KEYS.concat([ "id", "updateId", "componentId" ]), Comp = props => {
|
|
15
|
+
var _a;
|
|
16
|
+
const context = react_1.default.useContext(chart_1.default), id = null !== (_a = props.id) && void 0 !== _a ? _a : props.componentId, bindedEvents = react_1.default.useRef({}), handleEvent = e => {
|
|
17
|
+
const markIds = markNames.map((markName => `${id}-${markName}`));
|
|
18
18
|
(null == e ? void 0 : e.mark) && markIds.includes(e.mark.getUserId()) && props[eventsUtils_1.VCHART_TO_REACT_EVENTS[e.event.type]](e);
|
|
19
19
|
}, addMarkEvent = events => {
|
|
20
20
|
events && context.chart && (bindedEvents && Object.keys(bindedEvents).forEach((eventKey => {
|
|
@@ -24,53 +24,26 @@ const react_1 = __importDefault(require("react")), vutils_1 = require("@visactor
|
|
|
24
24
|
(null == bindedEvents ? void 0 : bindedEvents[eventKey]) || (context.chart.on(eventsUtils_1.REACT_TO_VCHART_EVENTS[eventKey], handleEvent),
|
|
25
25
|
bindedEvents || (bindedEvents.current = {}), bindedEvents.current[eventKey] = !0);
|
|
26
26
|
})));
|
|
27
|
-
}, addMarkId = spec => {
|
|
28
|
-
markNames.forEach((markName => {
|
|
29
|
-
const defaultMarkId = `${id.current}-${markName}`;
|
|
30
|
-
(0, vutils_1.isNil)(spec[markName]) ? spec[markName] = {
|
|
31
|
-
id: defaultMarkId
|
|
32
|
-
} : (0, vutils_1.isNil)(spec[markName].id) && (spec[markName].id = defaultMarkId);
|
|
33
|
-
}));
|
|
34
|
-
}, insertToContext = props => {
|
|
35
|
-
if (context.specFromChildren) {
|
|
36
|
-
context.specFromChildren.series || (context.specFromChildren.series = []);
|
|
37
|
-
const spec = (0, vutils_1.isNil)(type) ? Object.assign(Object.assign({}, props), {
|
|
38
|
-
id: id.current
|
|
39
|
-
}) : Object.assign(Object.assign({}, props), {
|
|
40
|
-
id: id.current,
|
|
41
|
-
type: type
|
|
42
|
-
});
|
|
43
|
-
addMarkId(spec), context.specFromChildren.series.push(spec), context.isChildrenUpdated = !0;
|
|
44
|
-
}
|
|
45
27
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
addMarkId(newSeriesSpec), (0, vutils_1.isEqual)(newSeriesSpec, seriesSpec.current) || (seriesSpec.current = newSeriesSpec,
|
|
49
|
-
(props => {
|
|
50
|
-
if (!context.specFromChildren) return;
|
|
51
|
-
if (!context.specFromChildren.series) return void insertToContext(props);
|
|
52
|
-
const series = context.specFromChildren.series, index = series.findIndex((entry => entry.id === id.current));
|
|
53
|
-
index >= 0 ? (series[index] = (0, vutils_1.isNil)(type) ? Object.assign(Object.assign({}, props), {
|
|
54
|
-
id: id.current
|
|
55
|
-
}) : Object.assign(Object.assign({}, props), {
|
|
56
|
-
id: id.current,
|
|
57
|
-
type: type
|
|
58
|
-
}), addMarkId(series[index])) : insertToContext(props), context.isChildrenUpdated = !0;
|
|
59
|
-
})(newSeriesSpec));
|
|
60
|
-
}
|
|
61
|
-
return react_1.default.useEffect((() => () => {
|
|
62
|
-
(() => {
|
|
63
|
-
var _a;
|
|
64
|
-
if (!context.specFromChildren) return;
|
|
65
|
-
const series = null !== (_a = context.specFromChildren.series) && void 0 !== _a ? _a : [], index = series.findIndex((entry => entry.id === id.current));
|
|
66
|
-
if (index >= 0) {
|
|
67
|
-
const newSeries = series.slice(0, index - 1).concat(series.slice(index + 1));
|
|
68
|
-
context.specFromChildren.series = newSeries, context.isChildrenUpdated = !0;
|
|
69
|
-
}
|
|
70
|
-
})(), addMarkEvent({});
|
|
28
|
+
return addMarkEvent((0, eventsUtils_1.findEventProps)(props)), react_1.default.useEffect((() => () => {
|
|
29
|
+
addMarkEvent({}), bindedEvents.current = {};
|
|
71
30
|
}), []), null;
|
|
72
31
|
};
|
|
73
|
-
return Comp.displayName = componentName, Comp
|
|
32
|
+
return Comp.displayName = componentName, Comp.parseSpec = compProps => {
|
|
33
|
+
var _a;
|
|
34
|
+
const newSeriesSpec = (0, vutils_1.pickWithout)(compProps, notSpecKeys);
|
|
35
|
+
var spec, seriesId;
|
|
36
|
+
return spec = newSeriesSpec, seriesId = null !== (_a = compProps.id) && void 0 !== _a ? _a : compProps.componentId,
|
|
37
|
+
markNames.forEach((markName => {
|
|
38
|
+
const defaultMarkId = `${seriesId}-${markName}`;
|
|
39
|
+
(0, vutils_1.isNil)(spec[markName]) ? spec[markName] = {
|
|
40
|
+
id: defaultMarkId
|
|
41
|
+
} : (0, vutils_1.isNil)(spec[markName].id) && (spec[markName].id = defaultMarkId);
|
|
42
|
+
})), (0, vutils_1.isNil)(type) || (newSeriesSpec.type = type), {
|
|
43
|
+
spec: newSeriesSpec,
|
|
44
|
+
specName: "series"
|
|
45
|
+
};
|
|
46
|
+
}, Comp;
|
|
74
47
|
};
|
|
75
48
|
|
|
76
49
|
exports.createSeries = createSeries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/series/BaseSeries.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,
|
|
1
|
+
{"version":3,"sources":["../src/series/BaseSeries.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6CAAsD;AACtD,6DAAgD;AAChD,gDAMwB;AAKjB,MAAM,YAAY,GAAG,CAA4B,aAAqB,EAAE,SAAmB,EAAE,IAAa,EAAE,EAAE;IACnH,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,gCAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAE1D,MAAM,SAAS,GAAG,CAAC,IAAS,EAAE,QAAyB,EAAE,EAAE;QACzD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,MAAM,aAAa,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;YAEhD,IAAI,IAAA,cAAK,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC;aACxC;iBAAM,IAAI,IAAA,cAAK,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CA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CAAC,IAAI,GAAG,IAAI,CAAC;SACpC;QAED,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,QAAQ,EAAE,QAAQ;SACnB,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAvFW,QAAA,YAAY,gBAuFvB","file":"BaseSeries.js","sourcesContent":["import React from 'react';\nimport { isNil, pickWithout } from '@visactor/vutils';\nimport RootChartContext from '../context/chart';\nimport {\n REACT_TO_VCHART_EVENTS,\n EventsProps,\n findEventProps,\n COMMON_EVENTK_KEYS,\n VCHART_TO_REACT_EVENTS\n} from '../eventsUtils';\nexport interface BaseSeriesProps extends EventsProps {\n id?: string | number;\n}\n\nexport const createSeries = <T extends BaseSeriesProps>(componentName: string, markNames: string[], type?: string) => {\n const ignoreKeys = ['id', 'updateId', 'componentId'];\n const notSpecKeys = COMMON_EVENTK_KEYS.concat(ignoreKeys);\n\n const addMarkId = (spec: any, seriesId: string | number) => {\n markNames.forEach(markName => {\n const defaultMarkId = `${seriesId}-${markName}`;\n\n if (isNil(spec[markName])) {\n spec[markName] = { id: defaultMarkId };\n } else if (isNil(spec[markName].id)) {\n spec[markName].id = defaultMarkId;\n }\n });\n };\n\n const Comp: React.FC<T & { updateId?: number; componentId?: string }> = props => {\n const context = React.useContext(RootChartContext);\n\n const id = props.id ?? props.componentId;\n const bindedEvents = React.useRef<Record<string, boolean>>({});\n\n const handleEvent = (e: any) => {\n const markIds = markNames.map(markName => `${id}-${markName}`);\n if (e?.mark && markIds.includes(e.mark.getUserId())) {\n props[VCHART_TO_REACT_EVENTS[e.event.type]](e);\n }\n };\n\n const addMarkEvent = (events: EventsProps) => {\n if (!events || !context.chart) {\n return;\n }\n\n if (bindedEvents) {\n Object.keys(bindedEvents).forEach(eventKey => {\n if (!events[eventKey]) {\n context.chart.off(REACT_TO_VCHART_EVENTS[eventKey], handleEvent);\n }\n bindedEvents.current[eventKey] = false;\n });\n }\n\n Object.keys(events).forEach(eventKey => {\n if (!bindedEvents?.[eventKey]) {\n context.chart.on(REACT_TO_VCHART_EVENTS[eventKey], handleEvent);\n\n if (!bindedEvents) {\n bindedEvents.current = {};\n }\n bindedEvents.current[eventKey] = true;\n }\n });\n };\n\n const removeMarkEvent = () => {\n addMarkEvent({});\n };\n\n addMarkEvent(findEventProps(props));\n\n React.useEffect(() => {\n return () => {\n removeMarkEvent();\n bindedEvents.current = {};\n };\n }, []);\n\n return null;\n };\n\n Comp.displayName = componentName;\n (Comp as any).parseSpec = (compProps: T & { updateId?: number; componentId?: string }) => {\n const newSeriesSpec = pickWithout<T>(compProps, notSpecKeys);\n\n addMarkId(newSeriesSpec, compProps.id ?? compProps.componentId);\n\n if (!isNil(type)) {\n (newSeriesSpec as any).type = type;\n }\n\n return {\n spec: newSeriesSpec,\n specName: 'series'\n };\n };\n return Comp;\n};\n"]}
|
package/cjs/series/BoxPlot.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import type { IBoxPlotSeriesSpec } from '@visactor/vchart';
|
|
|
3
3
|
export type BoxPlotProps = BaseSeriesProps & Omit<IBoxPlotSeriesSpec, 'type'>;
|
|
4
4
|
export declare const BoxPlot: import("react").FC<BaseSeriesProps & Omit<IBoxPlotSeriesSpec, "type"> & {
|
|
5
5
|
updateId?: number;
|
|
6
|
+
componentId?: string;
|
|
6
7
|
}>;
|