@visactor/react-vchart 1.10.0-alpha.0 → 1.10.0-alpha.10

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.
Files changed (130) hide show
  1. package/cjs/VChart.js.map +1 -1
  2. package/cjs/charts/BaseChart.d.ts +2 -1
  3. package/cjs/charts/BaseChart.js +37 -23
  4. package/cjs/charts/BaseChart.js.map +1 -1
  5. package/cjs/charts/RoseChart.js +2 -1
  6. package/cjs/charts/ScatterChart.js +1 -2
  7. package/cjs/components/BaseComponent.d.ts +1 -0
  8. package/cjs/components/BaseComponent.js +9 -35
  9. package/cjs/components/BaseComponent.js.map +1 -1
  10. package/cjs/components/Mark.d.ts +4 -14
  11. package/cjs/components/Mark.js +2 -61
  12. package/cjs/components/Mark.js.map +1 -1
  13. package/cjs/components/Region.js +2 -1
  14. package/cjs/components/Title.js +1 -2
  15. package/cjs/components/index.d.ts +1 -1
  16. package/cjs/components/index.js +1 -1
  17. package/cjs/components/index.js.map +1 -1
  18. package/cjs/components/tooltip/Tooltip.d.ts +2 -0
  19. package/cjs/components/{Tooltip.js → tooltip/Tooltip.js} +2 -2
  20. package/cjs/components/tooltip/Tooltip.js.map +1 -0
  21. package/cjs/components/tooltip/constant.d.ts +1 -0
  22. package/cjs/components/tooltip/constant.js +10 -0
  23. package/cjs/components/tooltip/constant.js.map +1 -0
  24. package/cjs/components/tooltip/index.d.ts +3 -0
  25. package/cjs/components/tooltip/index.js +22 -0
  26. package/cjs/components/tooltip/index.js.map +1 -0
  27. package/cjs/components/tooltip/interface.d.ts +14 -0
  28. package/cjs/components/tooltip/interface.js +6 -0
  29. package/cjs/components/tooltip/interface.js.map +1 -0
  30. package/cjs/components/tooltip/util.d.ts +5 -0
  31. package/cjs/components/tooltip/util.js +47 -0
  32. package/cjs/components/tooltip/util.js.map +1 -0
  33. package/cjs/containers/withContainer.d.ts +1 -1
  34. package/cjs/containers/withContainer.js.map +1 -1
  35. package/cjs/context/chart.d.ts +0 -1
  36. package/cjs/context/chart.js.map +1 -1
  37. package/cjs/index.d.ts +1 -1
  38. package/cjs/index.js +1 -1
  39. package/cjs/index.js.map +1 -1
  40. package/cjs/series/Area.d.ts +1 -0
  41. package/cjs/series/Bar.d.ts +1 -0
  42. package/cjs/series/BaseSeries.d.ts +1 -0
  43. package/cjs/series/BaseSeries.js +29 -55
  44. package/cjs/series/BaseSeries.js.map +1 -1
  45. package/cjs/series/BoxPlot.d.ts +1 -0
  46. package/cjs/series/CircularProgress.d.ts +1 -0
  47. package/cjs/series/Dot.d.ts +1 -0
  48. package/cjs/series/Funnel.d.ts +1 -0
  49. package/cjs/series/Line.d.ts +1 -0
  50. package/cjs/series/LinearProgress.d.ts +1 -0
  51. package/cjs/series/LinearProgress.js +2 -1
  52. package/cjs/series/Link.d.ts +1 -0
  53. package/cjs/series/Link.js +1 -2
  54. package/cjs/series/Map.d.ts +1 -0
  55. package/cjs/series/Pie.d.ts +1 -0
  56. package/cjs/series/Radar.d.ts +1 -0
  57. package/cjs/series/RangeColumn.d.ts +1 -0
  58. package/cjs/series/Rose.d.ts +1 -0
  59. package/cjs/series/Scatter.d.ts +1 -0
  60. package/cjs/series/Series.d.ts +1 -0
  61. package/cjs/series/Series.js +1 -1
  62. package/cjs/series/WordCloud.d.ts +1 -0
  63. package/esm/VChart.js.map +1 -1
  64. package/esm/charts/BaseChart.d.ts +2 -1
  65. package/esm/charts/BaseChart.js +37 -24
  66. package/esm/charts/BaseChart.js.map +1 -1
  67. package/esm/charts/RoseChart.js +2 -1
  68. package/esm/charts/ScatterChart.js +1 -2
  69. package/esm/components/BaseComponent.d.ts +1 -0
  70. package/esm/components/BaseComponent.js +9 -36
  71. package/esm/components/BaseComponent.js.map +1 -1
  72. package/esm/components/Mark.d.ts +4 -14
  73. package/esm/components/Mark.js +2 -39
  74. package/esm/components/Mark.js.map +1 -1
  75. package/esm/components/Region.js +2 -1
  76. package/esm/components/Title.js +1 -2
  77. package/esm/components/index.d.ts +1 -1
  78. package/esm/components/index.js +1 -1
  79. package/esm/components/index.js.map +1 -1
  80. package/esm/components/tooltip/Tooltip.d.ts +2 -0
  81. package/esm/components/tooltip/Tooltip.js +4 -0
  82. package/esm/components/tooltip/Tooltip.js.map +1 -0
  83. package/esm/components/tooltip/constant.d.ts +1 -0
  84. package/esm/components/tooltip/constant.js +4 -0
  85. package/esm/components/tooltip/constant.js.map +1 -0
  86. package/esm/components/tooltip/index.d.ts +3 -0
  87. package/esm/components/tooltip/index.js +6 -0
  88. package/esm/components/tooltip/index.js.map +1 -0
  89. package/esm/components/tooltip/interface.d.ts +14 -0
  90. package/esm/components/tooltip/interface.js +2 -0
  91. package/esm/components/tooltip/interface.js.map +1 -0
  92. package/esm/components/tooltip/util.d.ts +5 -0
  93. package/esm/components/tooltip/util.js +40 -0
  94. package/esm/components/tooltip/util.js.map +1 -0
  95. package/esm/containers/withContainer.d.ts +1 -1
  96. package/esm/containers/withContainer.js.map +1 -1
  97. package/esm/context/chart.d.ts +0 -1
  98. package/esm/context/chart.js.map +1 -1
  99. package/esm/index.d.ts +1 -1
  100. package/esm/index.js +1 -1
  101. package/esm/index.js.map +1 -1
  102. package/esm/series/Area.d.ts +1 -0
  103. package/esm/series/Bar.d.ts +1 -0
  104. package/esm/series/BaseSeries.d.ts +1 -0
  105. package/esm/series/BaseSeries.js +29 -56
  106. package/esm/series/BaseSeries.js.map +1 -1
  107. package/esm/series/BoxPlot.d.ts +1 -0
  108. package/esm/series/CircularProgress.d.ts +1 -0
  109. package/esm/series/Dot.d.ts +1 -0
  110. package/esm/series/Funnel.d.ts +1 -0
  111. package/esm/series/Line.d.ts +1 -0
  112. package/esm/series/LinearProgress.d.ts +1 -0
  113. package/esm/series/LinearProgress.js +2 -1
  114. package/esm/series/Link.d.ts +1 -0
  115. package/esm/series/Link.js +1 -2
  116. package/esm/series/Map.d.ts +1 -0
  117. package/esm/series/Pie.d.ts +1 -0
  118. package/esm/series/Radar.d.ts +1 -0
  119. package/esm/series/RangeColumn.d.ts +1 -0
  120. package/esm/series/Rose.d.ts +1 -0
  121. package/esm/series/Scatter.d.ts +1 -0
  122. package/esm/series/Series.d.ts +1 -0
  123. package/esm/series/Series.js +1 -1
  124. package/esm/series/WordCloud.d.ts +1 -0
  125. package/package.json +8 -8
  126. package/cjs/components/Tooltip.d.ts +0 -4
  127. package/cjs/components/Tooltip.js.map +0 -1
  128. package/esm/components/Tooltip.d.ts +0 -4
  129. package/esm/components/Tooltip.js +0 -4
  130. package/esm/components/Tooltip.js.map +0 -1
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var __importDefault = this && this.__importDefault || function(mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ default: mod
6
+ };
7
+ };
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: !0
11
+ }), exports.initCustomTooltip = void 0;
12
+
13
+ const react_1 = __importDefault(require("react")), vutils_1 = require("@visactor/vutils"), constant_1 = require("./constant"), react_dom_1 = require("react-dom"), initCustomTooltip = (setTooltipNode, props, spec) => {
14
+ let render;
15
+ if ((null == spec ? void 0 : spec.tooltipRender) ? (render = spec.tooltipRender,
16
+ delete spec.tooltipRender) : (null == spec ? void 0 : spec.children) ? render = (tooltipElement, actualTooltip, params) => react_1.default.Children.map(spec.children, (child => (0,
17
+ vutils_1.isObject)(child) ? react_1.default.cloneElement(child, {
18
+ tooltipElement: tooltipElement,
19
+ actualTooltip: actualTooltip,
20
+ params: params
21
+ }) : child)) : props.tooltipRender && (render = props.tooltipRender), render) {
22
+ let reserve;
23
+ return (null == spec ? void 0 : spec.reserveDefaultTooltip) ? (reserve = spec.reserveDefaultTooltip,
24
+ delete spec.reserveDefaultTooltip) : reserve = props.reserveDefaultTooltip, Object.assign(Object.assign({}, spec), {
25
+ updateElement: (el, actualTooltip, params) => {
26
+ const {changePositionOnly: changePositionOnly} = params;
27
+ if (!changePositionOnly) {
28
+ if (!reserve) {
29
+ el.style.width = "auto", el.style.height = "auto", el.style.minHeight = "auto",
30
+ el.style.padding = "0px";
31
+ for (let i = 0; i < el.children.length; i++) {
32
+ const childNode = el.children[i];
33
+ childNode.className !== constant_1.REACT_TOOLTIP_ClASS_NAME && "none" !== childNode.style.display && (childNode.style.display = "none");
34
+ }
35
+ }
36
+ setTooltipNode((0, react_dom_1.createPortal)(react_1.default.createElement("div", {
37
+ className: constant_1.REACT_TOOLTIP_ClASS_NAME
38
+ }, render(el, actualTooltip, params)), el));
39
+ }
40
+ }
41
+ });
42
+ }
43
+ return spec;
44
+ };
45
+
46
+ exports.initCustomTooltip = initCustomTooltip;
47
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/tooltip/util.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,6CAA4C;AAE5C,yCAAsD;AACtD,yCAAyC;AAGlC,MAAM,iBAAiB,GAAG,CAC/B,cAAqE,EACrE,KAAqB,EACrB,IAAmB,EACnB,EAAE;IACF,IAAI,MAAM,GAAkB,SAAS,CAAC;IACtC,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,EAAE;QACvB,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC;QAC5B,OAAO,IAAI,CAAC,aAAa,CAAC;KAC3B;SAAM,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,EAAE;QACzB,MAAM,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,CACjD,eAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CACxC,IAAA,iBAAQ,EAAC,KAAK,CAAC;YACb,CAAC,CAAC,eAAK,CAAC,YAAY,CAAC,KAAkE,EAAE;gBACrF,cAAc;gBACd,aAAa;gBACb,MAAM;aACP,CAAC;YACJ,CAAC,CAAC,KAAK,CACV,CAAC;KACL;SAAM,IAAI,KAAK,CAAC,aAAa,EAAE;QAC9B,MAA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EAAE,EAAE,CAAC,CACtG,CAAC;YACJ,CAAC,GACc,CAAC;KACnB;IAED,OAAO,IAAoB,CAAC;AAC9B,CAAC,CAAC;AA3DW,QAAA,iBAAiB,qBA2D5B","file":"util.js","sourcesContent":["import React from 'react';\nimport type { BaseChartProps } from '../../charts/BaseChart';\nimport { TooltipProps, TooltipRender } from './interface';\nimport { isObject } from '@visactor/vutils';\nimport { ITooltipSpec } from '@visactor/vchart';\nimport { REACT_TOOLTIP_ClASS_NAME } from './constant';\nimport { createPortal } from 'react-dom';\n\n/** tooltip 自定义插槽 */\nexport const initCustomTooltip = (\n setTooltipNode: React.Dispatch<React.SetStateAction<React.ReactNode>>,\n props: BaseChartProps,\n spec?: TooltipProps\n) => {\n let render: TooltipRender = undefined;\n if (spec?.tooltipRender) {\n render = spec.tooltipRender;\n delete spec.tooltipRender;\n } else if (spec?.children) {\n render = (tooltipElement, actualTooltip, params) =>\n React.Children.map(spec.children, child =>\n isObject(child)\n ? React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n tooltipElement,\n actualTooltip,\n params\n })\n : child\n );\n } else if (props.tooltipRender) {\n render = props.tooltipRender;\n }\n\n if (render) {\n let reserve: boolean = undefined;\n if (spec?.reserveDefaultTooltip) {\n reserve = spec.reserveDefaultTooltip;\n delete spec.reserveDefaultTooltip;\n } else {\n reserve = props.reserveDefaultTooltip;\n }\n return {\n ...spec,\n updateElement: (el, actualTooltip, params) => {\n const { changePositionOnly } = params;\n if (changePositionOnly) {\n return;\n }\n if (!reserve) {\n el.style.width = 'auto';\n el.style.height = 'auto';\n el.style.minHeight = 'auto';\n el.style.padding = '0px';\n for (let i = 0; i < el.children.length; i++) {\n const childNode = el.children[i] as HTMLElement;\n if (childNode.className !== REACT_TOOLTIP_ClASS_NAME && childNode.style.display !== 'none') {\n childNode.style.display = 'none';\n }\n }\n }\n setTooltipNode(\n createPortal(<div className={REACT_TOOLTIP_ClASS_NAME}>{render(el, actualTooltip, params)}</div>, el)\n );\n }\n } as ITooltipSpec;\n }\n\n return spec as ITooltipSpec;\n};\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: typeof React.Component<any, CompProps>, name?: string, getProps?: (props: any) => CompProps): React.ForwardRefExoticComponent<React.PropsWithoutRef<CompProps & Props> & React.RefAttributes<any>>;
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,IAA4C,EAC5C,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: typeof React.Component<any, CompProps>,\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"]}
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"]}
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import type { IVChart } from '@visactor/vchart';
3
3
  export interface ChartContextType {
4
4
  chart?: IVChart;
5
- specFromChildren: any;
6
5
  isChildrenUpdated?: boolean;
7
6
  }
8
7
  declare const ChartContext: React.Context<ChartContextType>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context/chart.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAS1B,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 specFromChildren: any;\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"]}
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.0";
6
+ export declare const version = "1.10.0-alpha.10";
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.0";
22
+ __exportStar(require("./VChartSimple"), exports), exports.version = "1.10.0-alpha.10";
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.0\";\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"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,iDAA+B;AAGlB,QAAA,OAAO,GAAG,iBAAiB,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.10\";\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"]}
@@ -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
  }>;
@@ -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
  }>;
@@ -5,4 +5,5 @@ export interface BaseSeriesProps extends EventsProps {
5
5
  }
6
6
  export declare const createSeries: <T extends BaseSeriesProps>(componentName: string, markNames: string[], type?: string) => React.FC<T & {
7
7
  updateId?: number;
8
+ componentId?: string;
8
9
  }>;
@@ -10,67 +10,41 @@ 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"), util_1 = require("../util"), createSeries = (componentName, markNames, type) => {
14
- const notSpecKeys = eventsUtils_1.COMMON_EVENTK_KEYS.concat([ "id", "updateId" ]), Comp = props => {
15
- const context = react_1.default.useContext(chart_1.default), id = react_1.default.useRef((0,
16
- vutils_1.isNil)(props.id) ? (0, util_1.uid)(null != type ? type : "series") : props.id), seriesSpec = react_1.default.useRef(), bindedEvents = react_1.default.useRef({}), updateId = react_1.default.useRef(props.updateId), handleEvent = e => {
17
- const markIds = markNames.map((markName => `${id.current}-${markName}`));
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
- events && context.chart && (bindedEvents && Object.keys(bindedEvents).forEach((eventKey => {
21
- events[eventKey] || context.chart.off(eventsUtils_1.REACT_TO_VCHART_EVENTS[eventKey], handleEvent),
22
- bindedEvents.current[eventKey] = !1;
23
- })), Object.keys(events).forEach((eventKey => {
24
- (null == bindedEvents ? void 0 : bindedEvents[eventKey]) || (context.chart.on(eventsUtils_1.REACT_TO_VCHART_EVENTS[eventKey], handleEvent),
25
- bindedEvents || (bindedEvents.current = {}), bindedEvents.current[eventKey] = !0);
20
+ events && context.chart && (bindedEvents.current && Object.keys(bindedEvents.current).forEach((eventKey => {
21
+ context.chart.off(eventsUtils_1.REACT_TO_VCHART_EVENTS[eventKey], bindedEvents.current[eventKey]),
22
+ bindedEvents.current[eventKey] = null;
23
+ })), events && Object.keys(events).forEach((eventKey => {
24
+ var _a;
25
+ (null === (_a = bindedEvents.current) || void 0 === _a ? void 0 : _a[eventKey]) || (context.chart.on(eventsUtils_1.REACT_TO_VCHART_EVENTS[eventKey], handleEvent),
26
+ bindedEvents.current || (bindedEvents.current = {}), bindedEvents.current[eventKey] = handleEvent);
26
27
  })));
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
28
  };
46
- if (addMarkEvent((0, eventsUtils_1.findEventProps)(props)), props.updateId !== updateId.current) updateId.current = props.updateId; else {
47
- const newSeriesSpec = (0, vutils_1.pickWithout)(props, notSpecKeys);
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({});
29
+ return addMarkEvent((0, eventsUtils_1.findEventProps)(props)), react_1.default.useEffect((() => () => {
30
+ addMarkEvent({}), bindedEvents.current = {};
71
31
  }), []), null;
72
32
  };
73
- return Comp.displayName = componentName, Comp;
33
+ return Comp.displayName = componentName, Comp.parseSpec = compProps => {
34
+ var _a;
35
+ const newSeriesSpec = (0, vutils_1.pickWithout)(compProps, notSpecKeys);
36
+ var spec, seriesId;
37
+ return spec = newSeriesSpec, seriesId = null !== (_a = compProps.id) && void 0 !== _a ? _a : compProps.componentId,
38
+ markNames.forEach((markName => {
39
+ const defaultMarkId = `${seriesId}-${markName}`;
40
+ (0, vutils_1.isNil)(spec[markName]) ? spec[markName] = {
41
+ id: defaultMarkId
42
+ } : (0, vutils_1.isNil)(spec[markName].id) && (spec[markName].id = defaultMarkId);
43
+ })), (0, vutils_1.isNil)(type) || (newSeriesSpec.type = type), {
44
+ spec: newSeriesSpec,
45
+ specName: "series"
46
+ };
47
+ }, Comp;
74
48
  };
75
49
 
76
50
  exports.createSeries = createSeries;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/series/BaseSeries.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6CAA+D;AAC/D,6DAAgD;AAChD,gDAMwB;AACxB,kCAA8B;AAMvB,MAAM,YAAY,GAAG,CAA4B,aAAqB,EAAE,SAAmB,EAAE,IAAa,EAAE,EAAE;IACnH,MAAM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ACL,MAAM,aAAa,GAAG,IAAA,oBAAW,EAAI,KAAK,EAAE,WAAW,CAAC,CAAC;YAEzD,SAAS,CAAC,aAAa,CAAC,CAAC;YACzB,IAAI,CAAC,IAAA,gBAAO,EAAC,aAAa,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;gBAC/C,UAAU,CAAC,OAAO,GAAG,aAAa,CAAC;gBACnC,eAAe,CAAC,aAAa,CAAC,CAAC;aAChC;SACF;QAED,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;YACnB,OAAO,GAAG,EAAE;gBACV,eAAe,EAAE,CAAC;gBAClB,eAAe,EAAE,CAAC;YACpB,CAAC,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;IACjC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AA1IW,QAAA,YAAY,gBA0IvB","file":"BaseSeries.js","sourcesContent":["import React from 'react';\nimport { isNil, isEqual, 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';\nimport { uid } from '../util';\n\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'];\n const notSpecKeys = COMMON_EVENTK_KEYS.concat(ignoreKeys);\n\n const Comp: React.FC<T & { updateId?: number }> = props => {\n const context = React.useContext(RootChartContext);\n\n const id = React.useRef<string | number>(isNil(props.id) ? uid(type ?? 'series') : props.id);\n\n const seriesSpec = React.useRef<Partial<T>>();\n const bindedEvents = React.useRef<Record<string, boolean>>({});\n const updateId = React.useRef<number>(props.updateId);\n\n const handleEvent = (e: any) => {\n const markIds = markNames.map(markName => `${id.current}-${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 const addMarkId = (spec: any) => {\n markNames.forEach(markName => {\n const defaultMarkId = `${id.current}-${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 insertToContext = (props: Partial<T>) => {\n if (context.specFromChildren) {\n if (!context.specFromChildren.series) {\n context.specFromChildren.series = [];\n }\n\n const spec = isNil(type) ? { ...props, id: id.current } : { ...props, id: id.current, type };\n\n addMarkId(spec);\n context.specFromChildren.series.push(spec);\n context.isChildrenUpdated = true;\n }\n };\n\n const updateToContext = (props: Partial<T>) => {\n if (!context.specFromChildren) {\n return;\n }\n\n if (!context.specFromChildren.series) {\n insertToContext(props);\n return;\n }\n\n const series = context.specFromChildren.series;\n const index = series.findIndex((entry: any) => entry.id === id.current);\n\n if (index >= 0) {\n series[index] = isNil(type) ? { ...props, id: id.current } : { ...props, id: id.current, type };\n addMarkId(series[index]);\n } else {\n insertToContext(props);\n }\n context.isChildrenUpdated = true;\n };\n\n const deleteToContext = () => {\n if (!context.specFromChildren) {\n return;\n }\n const series = context.specFromChildren.series ?? [];\n const index = series.findIndex((entry: any) => entry.id === id.current);\n\n if (index >= 0) {\n const newSeries = series.slice(0, index - 1).concat(series.slice(index + 1));\n context.specFromChildren.series = newSeries;\n context.isChildrenUpdated = true;\n }\n };\n\n addMarkEvent(findEventProps(props));\n if (props.updateId !== updateId.current) {\n // chart render\n updateId.current = props.updateId;\n } else {\n const newSeriesSpec = pickWithout<T>(props, notSpecKeys);\n\n addMarkId(newSeriesSpec);\n if (!isEqual(newSeriesSpec, seriesSpec.current)) {\n seriesSpec.current = newSeriesSpec;\n updateToContext(newSeriesSpec);\n }\n }\n\n React.useEffect(() => {\n return () => {\n deleteToContext();\n removeMarkEvent();\n };\n }, []);\n\n return null;\n };\n\n Comp.displayName = componentName;\n return Comp;\n};\n"]}
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,CAAC,EAAE;gBACnC,IAAI,CAAC,QAAQ,CAAC,CAAC,EA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;QAED,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,QAAQ,EAAE,QAAQ;SACnB,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAtFW,QAAA,YAAY,gBAsFvB","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, (e: any) => void>>({});\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.current) {\n Object.keys(bindedEvents.current).forEach(eventKey => {\n context.chart.off(REACT_TO_VCHART_EVENTS[eventKey], bindedEvents.current[eventKey]);\n bindedEvents.current[eventKey] = null;\n });\n }\n\n events &&\n Object.keys(events).forEach(eventKey => {\n if (!bindedEvents.current?.[eventKey]) {\n context.chart.on(REACT_TO_VCHART_EVENTS[eventKey], handleEvent);\n\n if (!bindedEvents.current) {\n bindedEvents.current = {};\n }\n bindedEvents.current[eventKey] = handleEvent;\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"]}
@@ -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
  }>;
@@ -3,4 +3,5 @@ import type { ICircularProgressSeriesSpec } from '@visactor/vchart';
3
3
  export type CircularProgressProps = BaseSeriesProps & Omit<ICircularProgressSeriesSpec, 'type'>;
4
4
  export declare const CircularProgress: import("react").FC<BaseSeriesProps & Omit<ICircularProgressSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { IDotSeriesSpec } from '@visactor/vchart';
3
3
  export type DotProps = BaseSeriesProps & Omit<IDotSeriesSpec, 'type'>;
4
4
  export declare const Dot: import("react").FC<BaseSeriesProps & Omit<IDotSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { IFunnelSeriesSpec } from '@visactor/vchart';
3
3
  export type FunnelProps = BaseSeriesProps & Omit<IFunnelSeriesSpec, 'type'>;
4
4
  export declare const Funnel: import("react").FC<BaseSeriesProps & Omit<IFunnelSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { ILineSeriesSpec } from '@visactor/vchart';
3
3
  export type LineProps = BaseSeriesProps & Omit<ILineSeriesSpec, 'type'>;
4
4
  export declare const Line: import("react").FC<BaseSeriesProps & Omit<ILineSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { ILinearProgressSeriesSpec } from '@visactor/vchart';
3
3
  export type LinearProgressProps = BaseSeriesProps & Omit<ILinearProgressSeriesSpec, 'type'>;
4
4
  export declare const LinearProgress: import("react").FC<BaseSeriesProps & Omit<ILinearProgressSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -6,4 +6,5 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  const BaseSeries_1 = require("./BaseSeries");
8
8
 
9
- exports.LinearProgress = (0, BaseSeries_1.createSeries)("LinearProgress", [ "linearProgress" ], "linearProgress");
9
+ exports.LinearProgress = (0, BaseSeries_1.createSeries)("LinearProgress", [ "linearProgress" ], "linearProgress");
10
+ //# sourceMappingURL=LinearProgress.js.map
@@ -3,4 +3,5 @@ import type { ILinkSeriesSpec } from '@visactor/vchart';
3
3
  export type LinkProps = BaseSeriesProps & Omit<ILinkSeriesSpec, 'type'>;
4
4
  export declare const Link: import("react").FC<BaseSeriesProps & Omit<ILinkSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -6,5 +6,4 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  const BaseSeries_1 = require("./BaseSeries");
8
8
 
9
- exports.Link = (0, BaseSeries_1.createSeries)("Link", [ "link" ], "link");
10
- //# sourceMappingURL=Link.js.map
9
+ exports.Link = (0, BaseSeries_1.createSeries)("Link", [ "link" ], "link");
@@ -3,4 +3,5 @@ import type { IMapSeriesSpec } from '@visactor/vchart';
3
3
  export type MapProps = BaseSeriesProps & Omit<IMapSeriesSpec, 'type'>;
4
4
  export declare const Map: import("react").FC<BaseSeriesProps & Omit<IMapSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { IPieSeriesSpec } from '@visactor/vchart';
3
3
  export type PieProps = BaseSeriesProps & Omit<IPieSeriesSpec, 'type'>;
4
4
  export declare const Pie: import("react").FC<BaseSeriesProps & Omit<IPieSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { IRadarSeriesSpec } from '@visactor/vchart';
3
3
  export type RadarProps = BaseSeriesProps & Omit<IRadarSeriesSpec, 'type'>;
4
4
  export declare const Radar: import("react").FC<BaseSeriesProps & Omit<IRadarSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { IRangeColumnSeriesSpec } from '@visactor/vchart';
3
3
  export type RangeColumnProps = BaseSeriesProps & Omit<IRangeColumnSeriesSpec, 'type'>;
4
4
  export declare const RangeColumn: import("react").FC<BaseSeriesProps & Omit<IRangeColumnSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { IRoseSeriesSpec } from '@visactor/vchart';
3
3
  export type RoseProps = BaseSeriesProps & Omit<IRoseSeriesSpec, 'type'>;
4
4
  export declare const Rose: import("react").FC<BaseSeriesProps & Omit<IRoseSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { IScatterSeriesSpec } from '@visactor/vchart';
3
3
  export type ScatterProps = BaseSeriesProps & Omit<IScatterSeriesSpec, 'type'>;
4
4
  export declare const Scatter: import("react").FC<BaseSeriesProps & Omit<IScatterSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -3,4 +3,5 @@ import type { IBarSeriesSpec, IAreaSeriesSpec, IBoxPlotSeriesSpec, ICircularProg
3
3
  export type SeriesProps = (IBarSeriesSpec | IAreaSeriesSpec | IBoxPlotSeriesSpec | ICircularProgressSeriesSpec | IDotSeriesSpec | IFunnelSeriesSpec | ILineSeriesSpec | ILinearProgressSeriesSpec | ILinkSeriesSpec | IMapSeriesSpec | IPieSeriesSpec | IRadarSeriesSpec | IRangeColumnSeriesSpec | IRoseSeriesSpec | IScatterSeriesSpec | IWordCloudSeriesSpec) & BaseSeriesProps;
4
4
  export declare const Series: import("react").FC<SeriesProps & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
@@ -7,4 +7,4 @@ Object.defineProperty(exports, "__esModule", {
7
7
  const BaseSeries_1 = require("./BaseSeries");
8
8
 
9
9
  exports.Series = (0, BaseSeries_1.createSeries)("Series", [ "bar", "line", "area" ]);
10
- //# sourceMappingURL=Series.js.map
10
+ //# sourceMappingURL=Series.js.map
@@ -3,4 +3,5 @@ import type { IWordCloudSeriesSpec } from '@visactor/vchart';
3
3
  export type WordCloudProps = BaseSeriesProps & Omit<IWordCloudSeriesSpec, 'type'>;
4
4
  export declare const WordCloud: import("react").FC<BaseSeriesProps & Omit<IWordCloudSeriesSpec, "type"> & {
5
5
  updateId?: number;
6
+ componentId?: string;
6
7
  }>;
package/esm/VChart.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/VChart.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAItB,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAc,QAAQ,EAAE;IACvD,kBAAkB,EAAE,UAAU;CAC/B,CAAC,CAAC","file":"VChart.js","sourcesContent":["import { BaseChartProps, createChart } from './charts/BaseChart';\nimport type { IVChartConstructor } from '@visactor/vchart';\nimport VChartCore from '@visactor/vchart';\nexport { VChartCore };\n\nexport type VChartProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'type'>;\n\nexport const VChart = createChart<VChartProps>('VChart', {\n vchartConstrouctor: VChartCore\n});\n"]}
1
+ {"version":3,"sources":["../src/VChart.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAItB,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAc,QAAQ,EAAE;IACvD,kBAAkB,EAAE,UAAU;CAC/B,CAAC,CAAC","file":"VChart.js","sourcesContent":["import { BaseChartProps, createChart } from './charts/BaseChart';\nimport VChartCore from '@visactor/vchart';\nexport { VChartCore };\n\nexport type VChartProps = Omit<BaseChartProps, 'container' | 'data' | 'width' | 'height' | 'type'>;\n\nexport const VChart = createChart<VChartProps>('VChart', {\n vchartConstrouctor: VChartCore\n});\n"]}
@@ -2,8 +2,9 @@ import type { IVChart, IData, IInitOption, ISpec, IVChartConstructor } from '@vi
2
2
  import React from 'react';
3
3
  import { ContainerProps } from '../containers/withContainer';
4
4
  import { EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps } from '../eventsUtils';
5
+ import { IReactTooltipProps } from '../components/tooltip/interface';
5
6
  export type ChartOptions = Omit<IInitOption, 'dom'>;
6
- export interface BaseChartProps extends EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps {
7
+ export interface BaseChartProps extends EventsProps, LegendEventProps, ScrollBarEventProps, BrushEventProps, DataZoomEventProps, PlayerEventProps, DimensionEventProps, HierarchyEventProps, ChartLifeCycleEventProps, IReactTooltipProps {
7
8
  vchartConstrouctor?: IVChartConstructor;
8
9
  type?: string;
9
10
  container?: HTMLDivElement;
@@ -4,7 +4,7 @@ import withContainer from "../containers/withContainer";
4
4
 
5
5
  import RootChartContext from "../context/chart";
6
6
 
7
- import { isEqual, pickWithout } from "@visactor/vutils";
7
+ import { isEqual, isNil, pickWithout } from "@visactor/vutils";
8
8
 
9
9
  import ViewContext from "../context/view";
10
10
 
@@ -14,17 +14,30 @@ import { REACT_PRIVATE_PROPS } from "../constants";
14
14
 
15
15
  import { bindEventsToChart, CHART_EVENTS_KEYS, CHART_EVENTS } from "../eventsUtils";
16
16
 
17
- const notSpecKeys = [ ...REACT_PRIVATE_PROPS, ...CHART_EVENTS_KEYS, "skipFunctionDiff", "onError", "onReady", "spec", "container", "options" ], BaseChart = React.forwardRef(((props, ref) => {
18
- const [updateId, setUpdateId] = useState(0), chartContext = useRef({
19
- specFromChildren: {}
20
- });
17
+ import { initCustomTooltip } from "../components/tooltip/util";
18
+
19
+ const notSpecKeys = [ ...REACT_PRIVATE_PROPS, ...CHART_EVENTS_KEYS, "vchartConstrouctor", "useSyncRender", "skipFunctionDiff", "onError", "onReady", "spec", "container", "options" ], getComponentId = (child, index) => `${child && child.type && (child.type.displayName || child.type.name)}-${index}`, parseSpecFromChildren = props => {
20
+ const specFromChildren = {};
21
+ return toArray(props.children).map(((child, index) => {
22
+ const parseSpec = child && child.type && child.type.parseSpec;
23
+ if (parseSpec && child.props) {
24
+ const specResult = parseSpec(isNil(child.props.componentId) ? Object.assign(Object.assign({}, child.props), {
25
+ componentId: getComponentId(child, index)
26
+ }) : child.props);
27
+ specResult.isSingle ? specFromChildren[specResult.specName] = specResult.spec : (specFromChildren[specResult.specName] || (specFromChildren[specResult.specName] = []),
28
+ specFromChildren[specResult.specName].push(specResult.spec));
29
+ }
30
+ })), specFromChildren;
31
+ }, BaseChart = React.forwardRef(((props, ref) => {
32
+ const [updateId, setUpdateId] = useState(0), chartContext = useRef({});
21
33
  useImperativeHandle(ref, (() => {
22
34
  var _a;
23
35
  return null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart;
24
36
  }));
25
- const hasSpec = !!props.spec, [view, setView] = useState(null), isUnmount = useRef(!1), prevSpec = useRef(pickWithout(props, notSpecKeys)), eventsBinded = React.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, parseSpec = props => {
26
- var _a;
27
- return hasSpec && props.spec ? props.spec : Object.assign(Object.assign({}, prevSpec.current), null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.specFromChildren);
37
+ const hasSpec = !!props.spec, [view, setView] = useState(null), isUnmount = useRef(!1), prevSpec = useRef(pickWithout(props, notSpecKeys)), specFromChildren = useRef(null), eventsBinded = React.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, [tooltipNode, setTooltipNode] = useState(null), parseSpec = props => {
38
+ let spec;
39
+ return spec = hasSpec && props.spec ? props.spec : Object.assign(Object.assign({}, prevSpec.current), specFromChildren.current),
40
+ spec.tooltip = initCustomTooltip(setTooltipNode, props, spec.tooltip), spec;
28
41
  }, handleChartRender = () => {
29
42
  if (!isUnmount.current) {
30
43
  if (!chartContext.current || !chartContext.current.chart) return;
@@ -36,7 +49,9 @@ const notSpecKeys = [ ...REACT_PRIVATE_PROPS, ...CHART_EVENTS_KEYS, "skipFunctio
36
49
  };
37
50
  return useEffect((() => {
38
51
  var _a;
39
- if (!(null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart)) return (props => {
52
+ const newSpecFromChildren = hasSpec ? null : parseSpecFromChildren(props);
53
+ if (!(null === (_a = chartContext.current) || void 0 === _a ? void 0 : _a.chart)) return hasSpec || (specFromChildren.current = newSpecFromChildren),
54
+ (props => {
40
55
  const cs = new props.vchartConstrouctor(parseSpec(props), Object.assign(Object.assign({}, props.options), {
41
56
  onError: props.onError,
42
57
  autoFit: !0,
@@ -44,13 +59,10 @@ const notSpecKeys = [ ...REACT_PRIVATE_PROPS, ...CHART_EVENTS_KEYS, "skipFunctio
44
59
  }));
45
60
  chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
46
61
  chart: cs
47
- });
62
+ }), isUnmount.current = !1;
48
63
  })(props), chartContext.current.chart && (chartContext.current.chart.renderSync({
49
64
  reuse: !1
50
- }), handleChartRender()), bindEventsToChart(chartContext.current.chart, props, null, CHART_EVENTS),
51
- chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
52
- isChildrenUpdated: !1
53
- }), void (eventsBinded.current = props);
65
+ }), handleChartRender()), void (eventsBinded.current = props);
54
66
  if (hasSpec) return void (isEqual(eventsBinded.current.spec, props.spec, {
55
67
  skipFunction: skipFunctionDiff
56
68
  }) || (eventsBinded.current = props, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
@@ -60,27 +72,28 @@ const notSpecKeys = [ ...REACT_PRIVATE_PROPS, ...CHART_EVENTS_KEYS, "skipFunctio
60
72
  const newSpec = pickWithout(props, notSpecKeys);
61
73
  isEqual(newSpec, prevSpec.current, {
62
74
  skipFunction: skipFunctionDiff
63
- }) && !chartContext.current.isChildrenUpdated || (prevSpec.current = newSpec, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
75
+ }) && isEqual(newSpecFromChildren, specFromChildren.current) || (prevSpec.current = newSpec,
76
+ specFromChildren.current = newSpecFromChildren, chartContext.current.chart.updateSpecSync(parseSpec(props), void 0, {
64
77
  morph: !1,
65
78
  enableExitAnimation: !1
66
- }), handleChartRender()), chartContext.current = Object.assign(Object.assign({}, chartContext.current), {
67
- isChildrenUpdated: !1
68
- });
79
+ }), handleChartRender());
69
80
  }), [ props ]), useEffect((() => () => {
70
- chartContext && (chartContext.current.chart && chartContext.current.chart.release(),
71
- chartContext.current = null), isUnmount.current = !0;
81
+ chartContext && chartContext.current && chartContext.current.chart && (chartContext.current.chart.release(),
82
+ chartContext.current.chart = null), eventsBinded.current = null, isUnmount.current = !0;
72
83
  }), []), React.createElement(RootChartContext.Provider, {
73
84
  value: chartContext.current
74
85
  }, React.createElement(ViewContext.Provider, {
75
86
  value: view
76
87
  }, toArray(props.children).map(((child, index) => {
77
- var _a, _b, _c;
88
+ if ("string" == typeof child) return;
89
+ const childId = getComponentId(child, index);
78
90
  return React.createElement(React.Fragment, {
79
- key: null !== (_c = null !== (_b = null === (_a = null == child ? void 0 : child.props) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : null == child ? void 0 : child.id) && void 0 !== _c ? _c : `child-${index}`
91
+ key: childId
80
92
  }, React.cloneElement(child, {
81
- updateId: updateId
93
+ updateId: updateId,
94
+ componentId: childId
82
95
  }));
83
- }))));
96
+ })), tooltipNode));
84
97
  }));
85
98
 
86
99
  export const createChart = (componentName, defaultProps, callback) => {