@antv/gpt-vis 0.5.6 → 0.5.7

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 (52) hide show
  1. package/dist/cjs/Bar/index.d.ts +4 -1
  2. package/dist/cjs/Bar/index.js +7 -2
  3. package/dist/cjs/Boxplot/index.d.ts +13 -0
  4. package/dist/cjs/Boxplot/index.js +88 -0
  5. package/dist/cjs/Column/index.d.ts +4 -1
  6. package/dist/cjs/Column/index.js +8 -2
  7. package/dist/cjs/Funnel/index.d.ts +12 -0
  8. package/dist/cjs/Funnel/index.js +173 -0
  9. package/dist/cjs/Liquid/index.d.ts +11 -0
  10. package/dist/cjs/Liquid/index.js +85 -0
  11. package/dist/cjs/Sankey/index.d.ts +12 -0
  12. package/dist/cjs/Sankey/index.js +106 -0
  13. package/dist/cjs/Scatter/index.js +7 -4
  14. package/dist/cjs/Treemap/index.js +1 -0
  15. package/dist/cjs/Venn/index.d.ts +32 -0
  16. package/dist/cjs/Venn/index.js +87 -0
  17. package/dist/cjs/Violin/index.d.ts +10 -0
  18. package/dist/cjs/Violin/index.js +185 -0
  19. package/dist/cjs/export.d.ts +7 -1
  20. package/dist/cjs/export.js +38 -8
  21. package/dist/cjs/types/chart.d.ts +6 -0
  22. package/dist/cjs/types/chart.js +6 -0
  23. package/dist/cjs/version.d.ts +1 -1
  24. package/dist/cjs/version.js +1 -1
  25. package/dist/esm/Bar/index.d.ts +4 -1
  26. package/dist/esm/Bar/index.js +12 -2
  27. package/dist/esm/Boxplot/index.d.ts +13 -0
  28. package/dist/esm/Boxplot/index.js +83 -0
  29. package/dist/esm/Column/index.d.ts +4 -1
  30. package/dist/esm/Column/index.js +13 -2
  31. package/dist/esm/Funnel/index.d.ts +12 -0
  32. package/dist/esm/Funnel/index.js +171 -0
  33. package/dist/esm/Liquid/index.d.ts +11 -0
  34. package/dist/esm/Liquid/index.js +100 -0
  35. package/dist/esm/Sankey/index.d.ts +12 -0
  36. package/dist/esm/Sankey/index.js +88 -0
  37. package/dist/esm/Scatter/index.js +12 -7
  38. package/dist/esm/Treemap/index.js +1 -0
  39. package/dist/esm/Venn/index.d.ts +32 -0
  40. package/dist/esm/Venn/index.js +69 -0
  41. package/dist/esm/Violin/index.d.ts +10 -0
  42. package/dist/esm/Violin/index.js +192 -0
  43. package/dist/esm/export.d.ts +7 -1
  44. package/dist/esm/export.js +8 -2
  45. package/dist/esm/types/chart.d.ts +6 -0
  46. package/dist/esm/types/chart.js +6 -0
  47. package/dist/esm/version.d.ts +1 -1
  48. package/dist/esm/version.js +1 -1
  49. package/dist/umd/373.async.js +1 -0
  50. package/dist/umd/index.min.js +1 -1
  51. package/package.json +1 -1
  52. package/dist/umd/962.async.js +0 -1
@@ -6,6 +6,9 @@ type BarDataItem = {
6
6
  value: number;
7
7
  [key: string]: string | number;
8
8
  };
9
- export type BarProps = BasePlotProps<BarDataItem> & Partial<BarConfig> & Theme & Style;
9
+ export type BarProps = BasePlotProps<BarDataItem> & Partial<BarConfig> & Theme & Style & {
10
+ group?: boolean;
11
+ stack?: boolean;
12
+ };
10
13
  declare const Bar: (props: BarProps) => React.JSX.Element;
11
14
  export default Bar;
@@ -82,14 +82,19 @@ var defaultConfig = (props) => {
82
82
  },
83
83
  ...paletteConfig
84
84
  },
85
- ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : { viewStyle: void 0 }
85
+ ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : { viewStyle: void 0 },
86
+ legend: hasGroupField ? {} : false
86
87
  };
87
88
  };
88
89
  var Bar = (props) => {
89
90
  const themeConfig = import_theme.THEME_MAP[props.theme ?? "default"];
91
+ const { data, group = false, stack = false } = props;
92
+ const hasGroupField = (0, import_lodash.get)(data, "[0].group") !== void 0;
90
93
  const config = (0, import_hooks.usePlotConfig)("Bar", defaultConfig, {
91
94
  ...props,
92
- theme: themeConfig
95
+ theme: themeConfig,
96
+ group: hasGroupField && group,
97
+ stack: hasGroupField && stack
93
98
  });
94
99
  return /* @__PURE__ */ import_react.default.createElement(import_plots.Bar, { ...config });
95
100
  };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { BasePlotProps, Style, Theme } from '../types';
3
+ type BoxplotDatum = {
4
+ category: string;
5
+ value: number;
6
+ group?: string;
7
+ };
8
+ export type BoxplotProps = BasePlotProps<BoxplotDatum> & Theme & Style & {
9
+ xField?: string;
10
+ yField?: string;
11
+ };
12
+ declare const Boxplot: (props: BoxplotProps) => React.JSX.Element;
13
+ export default Boxplot;
@@ -0,0 +1,88 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/Boxplot/index.tsx
30
+ var Boxplot_exports = {};
31
+ __export(Boxplot_exports, {
32
+ default: () => Boxplot_default
33
+ });
34
+ module.exports = __toCommonJS(Boxplot_exports);
35
+ var import_plots = require("@ant-design/plots");
36
+ var import_react = __toESM(require("react"));
37
+ var import_hooks = require("../ConfigProvider/hooks");
38
+ var import_theme = require("../theme");
39
+ var defaultConfig = (props) => {
40
+ var _a;
41
+ const { data, style = {}, axisYTitle, axisXTitle, xField = "category", yField = "value" } = props;
42
+ const { backgroundColor, palette } = style;
43
+ const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
44
+ let paletteConfig = { color: void 0 };
45
+ const hasPalette = !!(palette == null ? void 0 : palette[0]);
46
+ const colorField = hasGroupField ? "group" : "category";
47
+ const seriesField = hasGroupField ? "group" : "category";
48
+ if (hasPalette) {
49
+ paletteConfig = {
50
+ color: {
51
+ range: palette
52
+ }
53
+ };
54
+ }
55
+ return {
56
+ data,
57
+ boxType: "boxplot",
58
+ xField,
59
+ yField,
60
+ colorField,
61
+ seriesField,
62
+ axis: {
63
+ y: {
64
+ title: axisYTitle || false
65
+ },
66
+ x: {
67
+ title: axisXTitle || false
68
+ }
69
+ },
70
+ scale: {
71
+ x: { paddingInner: 0.6, paddingOuter: 0.3 },
72
+ series: { paddingInner: 0.3, paddingOuter: 0.1 },
73
+ y: { nice: true },
74
+ ...paletteConfig
75
+ },
76
+ style: { stroke: "black" },
77
+ ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {}
78
+ };
79
+ };
80
+ var Boxplot = (props) => {
81
+ const themeConfig = import_theme.THEME_MAP[props.theme ?? "default"];
82
+ const config = (0, import_hooks.usePlotConfig)("Boxplot", defaultConfig, {
83
+ ...props,
84
+ theme: themeConfig
85
+ });
86
+ return /* @__PURE__ */ import_react.default.createElement(import_plots.Box, { ...config });
87
+ };
88
+ var Boxplot_default = Boxplot;
@@ -5,6 +5,9 @@ export type ColumnDataItem = {
5
5
  value: number;
6
6
  [key: string]: string | number;
7
7
  };
8
- export type ColumnProps = BasePlotProps<ColumnDataItem> & Theme & Style;
8
+ export type ColumnProps = BasePlotProps<ColumnDataItem> & Theme & Style & {
9
+ group?: boolean;
10
+ stack?: boolean;
11
+ };
9
12
  declare const Column: (props: ColumnProps) => React.JSX.Element;
10
13
  export default Column;
@@ -82,14 +82,20 @@ var defaultConfig = (props) => {
82
82
  },
83
83
  ...paletteConfig
84
84
  },
85
- ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : { viewStyle: void 0 }
85
+ ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : { viewStyle: void 0 },
86
+ legend: hasGroupField ? {} : false,
87
+ group: hasGroupField
86
88
  };
87
89
  };
88
90
  var Column = (props) => {
89
91
  const themeConfig = import_theme.THEME_MAP[props.theme ?? "default"];
92
+ const { data, group = false, stack = false } = props;
93
+ const hasGroupField = (0, import_lodash.get)(data, "[0].group") !== void 0;
90
94
  const config = (0, import_hooks.usePlotConfig)("Column", defaultConfig, {
91
95
  ...props,
92
- theme: themeConfig
96
+ theme: themeConfig,
97
+ group: hasGroupField && group,
98
+ stack: hasGroupField && stack
93
99
  });
94
100
  return /* @__PURE__ */ import_react.default.createElement(import_plots.Column, { ...config });
95
101
  };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { BasePlotProps, Style, Theme } from '../types';
3
+ type FunnelDatum = {
4
+ category: string;
5
+ value: number;
6
+ };
7
+ export type FunnelProps = BasePlotProps<FunnelDatum> & Theme & Style & {
8
+ width?: number;
9
+ height?: number;
10
+ };
11
+ declare const Funnel: (props: FunnelProps) => React.JSX.Element;
12
+ export default Funnel;
@@ -0,0 +1,173 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/Funnel/index.tsx
30
+ var Funnel_exports = {};
31
+ __export(Funnel_exports, {
32
+ default: () => Funnel_default
33
+ });
34
+ module.exports = __toCommonJS(Funnel_exports);
35
+ var import_g2 = require("@antv/g2");
36
+ var import_react = __toESM(require("react"));
37
+ var import_theme = require("../theme");
38
+ var defaultConfig = (props) => {
39
+ const { data, title, theme = "default", style = {} } = props;
40
+ const { backgroundColor, palette = [] } = style;
41
+ const r = (start, end) => `${(end / start * 100).toFixed(2)} %`;
42
+ return {
43
+ type: "view",
44
+ data,
45
+ theme: import_theme.THEME_MAP[theme],
46
+ title,
47
+ padding: 40,
48
+ insetRight: 28,
49
+ children: [
50
+ {
51
+ type: "interval",
52
+ data,
53
+ encode: { x: "category", y: "value", color: "category", shape: "funnel" },
54
+ transform: [{ type: "symmetryY" }],
55
+ scale: {
56
+ x: { padding: 0 },
57
+ ...(palette == null ? void 0 : palette[0]) ? {
58
+ color: {
59
+ range: palette
60
+ }
61
+ } : {}
62
+ },
63
+ coordinate: { transform: [{ type: "transpose" }] },
64
+ legend: {
65
+ color: {
66
+ position: "top",
67
+ layout: {
68
+ justifyContent: "center"
69
+ }
70
+ }
71
+ },
72
+ labels: [
73
+ {
74
+ text: (d) => `${d.category}
75
+ ${d.value}`,
76
+ position: "inside",
77
+ transform: [{ type: "contrastReverse" }]
78
+ },
79
+ {
80
+ text: (d, i) => i !== 0 ? "———" : "",
81
+ style: {
82
+ "font-size": "1px",
83
+ color: "#666",
84
+ "letter-spacing": "0px"
85
+ },
86
+ position: "top-right",
87
+ fill: "#666",
88
+ dx: 35,
89
+ dy: -8
90
+ },
91
+ {
92
+ text: (d, i) => i !== 0 ? "转化率" : "",
93
+ position: "top-right",
94
+ textAlign: "left",
95
+ textBaseline: "middle",
96
+ fill: "#666",
97
+ dx: 40
98
+ },
99
+ {
100
+ text: (d, i, data2) => i !== 0 ? r(data2[i - 1].value, data2[i].value) : "",
101
+ position: "top-right",
102
+ textAlign: "left",
103
+ textBaseline: "middle",
104
+ dx: 80
105
+ }
106
+ ],
107
+ ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {}
108
+ },
109
+ {
110
+ type: "connector",
111
+ data: [
112
+ {
113
+ startX: data[0].category,
114
+ startY: data[data.length - 1].category,
115
+ endX: 0,
116
+ endY: (data[0].value - data[data.length - 1].value) / 2
117
+ }
118
+ ],
119
+ encode: { x: "startX", x1: "startY", y: "endX", y1: "endY" },
120
+ style: {
121
+ stroke: "#666",
122
+ markerEnd: false,
123
+ connectLength1: -12,
124
+ offset2: -20,
125
+ connectorStroke: "#0649f2",
126
+ lineDash: [12, 2]
127
+ },
128
+ labels: [
129
+ {
130
+ text: "转化率",
131
+ position: "left",
132
+ textAlign: "start",
133
+ textBaseline: "middle",
134
+ fill: "#666",
135
+ dx: 10
136
+ },
137
+ {
138
+ text: r(data[0].value, data[data.length - 1].value),
139
+ position: "left",
140
+ textAlign: "start",
141
+ dx: 50,
142
+ fill: "#000"
143
+ }
144
+ ]
145
+ }
146
+ ],
147
+ axis: false,
148
+ animate: false
149
+ };
150
+ };
151
+ var Funnel = (props) => {
152
+ const containerRef = (0, import_react.useRef)(null);
153
+ const chartRef = (0, import_react.useRef)(null);
154
+ (0, import_react.useEffect)(() => {
155
+ if (!containerRef.current)
156
+ return;
157
+ const chart = new import_g2.Chart({
158
+ container: containerRef.current,
159
+ autoFit: true,
160
+ padding: "auto"
161
+ });
162
+ const config = defaultConfig(props);
163
+ chart.options(config);
164
+ chart.render();
165
+ chartRef.current = chart;
166
+ return () => {
167
+ chart.destroy();
168
+ chartRef.current = null;
169
+ };
170
+ }, [props]);
171
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: containerRef });
172
+ };
173
+ var Funnel_default = Funnel;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { Style, Theme } from '../types';
3
+ export type LiquidProps = Theme & Style & {
4
+ percent: number;
5
+ shape?: 'rect' | 'circle' | 'pin' | 'triangle';
6
+ title?: string;
7
+ width?: number;
8
+ height?: number;
9
+ };
10
+ declare const Liquid: (props: LiquidProps) => React.JSX.Element;
11
+ export default Liquid;
@@ -0,0 +1,85 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/Liquid/index.tsx
30
+ var Liquid_exports = {};
31
+ __export(Liquid_exports, {
32
+ default: () => Liquid_default
33
+ });
34
+ module.exports = __toCommonJS(Liquid_exports);
35
+ var import_plots = require("@ant-design/plots");
36
+ var import_react = __toESM(require("react"));
37
+ var import_hooks = require("../ConfigProvider/hooks");
38
+ var import_theme = require("../theme");
39
+ var defaultConfig = (props) => {
40
+ const { percent, shape = "circle", style = {}, width = 600, height = 400 } = props;
41
+ const { backgroundColor, palette } = style;
42
+ const inferFontSize = Math.min(width, height) / 10;
43
+ const fontSize = Math.min(Math.max(inferFontSize, 24), 64);
44
+ const hasPalette = !!(palette == null ? void 0 : palette[0]);
45
+ let paletteConfig = { fill: void 0, outlineStroke: void 0 };
46
+ if (hasPalette) {
47
+ paletteConfig = { fill: palette[0], outlineStroke: palette[0] };
48
+ }
49
+ return {
50
+ percent,
51
+ style: {
52
+ shape,
53
+ contentFontSize: fontSize,
54
+ contentFill: "#000",
55
+ contentStroke: "#fff",
56
+ contentLineWidth: 2,
57
+ outlineBorder: 4,
58
+ outlineDistance: 4,
59
+ waveLength: 128,
60
+ ...paletteConfig
61
+ },
62
+ ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {},
63
+ interaction: { tooltip: false },
64
+ animate: false
65
+ };
66
+ };
67
+ var Liquid = (props) => {
68
+ const themeConfig = import_theme.THEME_MAP[props.theme ?? "default"];
69
+ const containerRef = (0, import_react.useRef)(null);
70
+ const [size, setSize] = (0, import_react.useState)({ width: 0, height: 0 });
71
+ const config = (0, import_hooks.usePlotConfig)("Liquid", defaultConfig, {
72
+ ...props,
73
+ theme: themeConfig,
74
+ width: size.width,
75
+ height: size.height
76
+ });
77
+ (0, import_react.useEffect)(() => {
78
+ if (containerRef.current) {
79
+ const { offsetWidth, offsetHeight } = containerRef.current;
80
+ setSize({ width: offsetWidth, height: offsetHeight });
81
+ }
82
+ }, []);
83
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: containerRef, style: { width: "100%", height: "100%" } }, /* @__PURE__ */ import_react.default.createElement(import_plots.Liquid, { ...config }));
84
+ };
85
+ var Liquid_default = Liquid;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { BasePlotProps, Style, Theme } from '../types';
3
+ type SankeyDatum = {
4
+ source: string;
5
+ target: string;
6
+ value: number;
7
+ };
8
+ export type SankeyProps = BasePlotProps<SankeyDatum> & Theme & Style & {
9
+ nodeAlign?: 'left' | 'center' | 'right' | 'justify';
10
+ };
11
+ declare const Sankey: (props: SankeyProps) => React.JSX.Element;
12
+ export default Sankey;
@@ -0,0 +1,106 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/Sankey/index.tsx
30
+ var Sankey_exports = {};
31
+ __export(Sankey_exports, {
32
+ default: () => Sankey_default
33
+ });
34
+ module.exports = __toCommonJS(Sankey_exports);
35
+ var import_g2 = require("@antv/g2");
36
+ var import_react = __toESM(require("react"));
37
+ var import_theme = require("../theme");
38
+ var defaultConfig = (props) => {
39
+ const { title, data, theme = "default", nodeAlign = "center", style = {} } = props;
40
+ const { backgroundColor, palette } = style;
41
+ const hasPalette = !!(palette == null ? void 0 : palette[0]);
42
+ let paletteConfig = {};
43
+ if (hasPalette) {
44
+ paletteConfig = {
45
+ color: {
46
+ range: palette
47
+ }
48
+ };
49
+ }
50
+ return {
51
+ title,
52
+ type: "sankey",
53
+ theme: import_theme.THEME_MAP[theme],
54
+ layout: {
55
+ nodeAlign,
56
+ nodePadding: 0.01
57
+ },
58
+ data: {
59
+ type: "inline",
60
+ value: data,
61
+ transform: [
62
+ {
63
+ type: "custom",
64
+ callback: (data2) => ({
65
+ links: data2
66
+ })
67
+ }
68
+ ]
69
+ },
70
+ scale: {
71
+ ...paletteConfig
72
+ },
73
+ style: {
74
+ labelSpacing: 2,
75
+ nodeLineWidth: 1,
76
+ linkFillOpacity: 0.3
77
+ },
78
+ viewStyle: {
79
+ viewFill: "red"
80
+ },
81
+ ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {}
82
+ };
83
+ };
84
+ var Sankey = (props) => {
85
+ const containerRef = (0, import_react.useRef)(null);
86
+ const chartRef = (0, import_react.useRef)(null);
87
+ (0, import_react.useEffect)(() => {
88
+ if (!containerRef.current)
89
+ return;
90
+ const chart = new import_g2.Chart({
91
+ container: containerRef.current,
92
+ autoFit: true,
93
+ padding: "auto"
94
+ });
95
+ const config = defaultConfig(props);
96
+ chart.options(config);
97
+ chart.render();
98
+ chartRef.current = chart;
99
+ return () => {
100
+ chart.destroy();
101
+ chartRef.current = null;
102
+ };
103
+ }, [props]);
104
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: containerRef });
105
+ };
106
+ var Sankey_default = Sankey;
@@ -71,10 +71,13 @@ var defaultConfig = (props) => {
71
71
  data,
72
72
  xField,
73
73
  yField,
74
- tooltip: [
75
- { channel: "x", name: axisXTitle || "x" },
76
- { channel: "y", name: axisYTitle || "y" }
77
- ],
74
+ tooltip: {
75
+ title: (d) => (d == null ? void 0 : d.group) ? d.group : false,
76
+ items: [
77
+ { channel: "x", name: axisXTitle || "x" },
78
+ { channel: "y", name: axisYTitle || "y" }
79
+ ]
80
+ },
78
81
  legend: hasGroupField ? {} : false,
79
82
  encode,
80
83
  scale: {
@@ -87,6 +87,7 @@ var Treemap = (props) => {
87
87
  });
88
88
  const { data, ...others } = config;
89
89
  const transformData = (0, import_react.useMemo)(() => transform(data), [data]);
90
+ console.log("treemap config:", config, props);
90
91
  return /* @__PURE__ */ import_react.default.createElement(import_plots.Treemap, { ...others, data: transformData });
91
92
  };
92
93
  var Treemap_default = Treemap;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import type { BasePlotProps, Style, Theme } from '../types';
3
+ type VennDatum = {
4
+ /**
5
+ * Label for the venn chart segment.
6
+ * This should be a string that describes the segment.
7
+ * For example, "A", "B", or "A ∩ B" for intersections.
8
+ * It is used to identify the segment in the chart.
9
+ */
10
+ label?: string;
11
+ /**
12
+ * Value for the venn chart segment.
13
+ * This should be a number that represents the size or count of the segment.
14
+ * For example, if the segment represents a set of items, this could be the number of items in that set.
15
+ * It is used to determine the size of the segment in the chart.
16
+ * For intersections, this value should represent the count of items that belong to the intersection of sets.
17
+ * For example, if "A ∩ B" represents the intersection of sets A and B, this value should be the count of items that are in both sets.
18
+ */
19
+ value: number;
20
+ /**
21
+ * Sets that the segment belongs to.
22
+ * This should be an array of strings representing the sets that the segment is part of.
23
+ * For example, if the segment represents items that belong to both set A and set B, this could be ['A', 'B'].
24
+ * It is used to determine how the segment is displayed in the venn chart.
25
+ * For intersections, this array should include the sets that contribute to the intersection.
26
+ * For example, if "A ∩ B" represents the intersection of sets A and B, this array should be ['A', 'B'].
27
+ */
28
+ sets: string[] | number[];
29
+ };
30
+ export type VennProps = BasePlotProps<VennDatum> & Theme & Style;
31
+ declare const Venn: (props: VennProps) => React.JSX.Element;
32
+ export default Venn;