@antv/gpt-vis 0.5.9 → 0.5.11

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 (60) hide show
  1. package/dist/cjs/Area/index.d.ts +2 -1
  2. package/dist/cjs/Boxplot/index.d.ts +2 -4
  3. package/dist/cjs/Boxplot/index.js +2 -2
  4. package/dist/cjs/Column/index.d.ts +2 -1
  5. package/dist/cjs/DualAxes/index.d.ts +5 -0
  6. package/dist/cjs/DualAxes/index.js +3 -2
  7. package/dist/cjs/DualAxes/util.d.ts +1 -1
  8. package/dist/cjs/DualAxes/util.js +2 -1
  9. package/dist/cjs/Funnel/index.js +2 -2
  10. package/dist/cjs/Histogram/index.d.ts +1 -0
  11. package/dist/cjs/Line/index.d.ts +2 -1
  12. package/dist/cjs/Line/index.js +3 -2
  13. package/dist/cjs/Scatter/index.d.ts +4 -1
  14. package/dist/cjs/Violin/index.js +11 -6
  15. package/dist/cjs/Waterfall/index.d.ts +22 -0
  16. package/dist/cjs/Waterfall/index.js +194 -0
  17. package/dist/cjs/export.d.ts +41 -1
  18. package/dist/cjs/export.js +4 -0
  19. package/dist/cjs/index.d.ts +2 -0
  20. package/dist/cjs/index.js +3 -1
  21. package/dist/cjs/render.d.ts +2 -0
  22. package/dist/cjs/render.js +67 -0
  23. package/dist/cjs/types/chart.d.ts +2 -0
  24. package/dist/cjs/types/chart.js +1 -0
  25. package/dist/cjs/version.d.ts +1 -1
  26. package/dist/cjs/version.js +1 -1
  27. package/dist/esm/Area/index.d.ts +2 -1
  28. package/dist/esm/Boxplot/index.d.ts +2 -4
  29. package/dist/esm/Boxplot/index.js +5 -2
  30. package/dist/esm/Column/index.d.ts +2 -1
  31. package/dist/esm/DualAxes/index.d.ts +5 -0
  32. package/dist/esm/DualAxes/index.js +6 -2
  33. package/dist/esm/DualAxes/util.d.ts +1 -1
  34. package/dist/esm/DualAxes/util.js +7 -0
  35. package/dist/esm/Funnel/index.js +2 -2
  36. package/dist/esm/Histogram/index.d.ts +1 -0
  37. package/dist/esm/Line/index.d.ts +2 -1
  38. package/dist/esm/Line/index.js +5 -2
  39. package/dist/esm/Scatter/index.d.ts +4 -1
  40. package/dist/esm/Violin/index.js +13 -6
  41. package/dist/esm/Waterfall/index.d.ts +22 -0
  42. package/dist/esm/Waterfall/index.js +186 -0
  43. package/dist/esm/export.d.ts +41 -1
  44. package/dist/esm/export.js +8 -2
  45. package/dist/esm/index.d.ts +2 -0
  46. package/dist/esm/index.js +3 -0
  47. package/dist/esm/render.d.ts +2 -0
  48. package/dist/esm/render.js +32 -0
  49. package/dist/esm/types/chart.d.ts +2 -0
  50. package/dist/esm/types/chart.js +1 -0
  51. package/dist/esm/version.d.ts +1 -1
  52. package/dist/esm/version.js +1 -1
  53. package/dist/umd/134.async.js +1 -0
  54. package/dist/umd/index.min.js +1 -1
  55. package/package.json +5 -2
  56. package/dist/cjs/Pie/index.text.d.ts +0 -0
  57. package/dist/cjs/Pie/index.text.js +0 -0
  58. package/dist/esm/Pie/index.text.d.ts +0 -0
  59. package/dist/esm/Pie/index.text.js +0 -0
  60. package/dist/umd/330.async.js +0 -1
@@ -1,3 +1,4 @@
1
+ import type { AreaConfig } from '@ant-design/plots';
1
2
  import React from 'react';
2
3
  import type { BasePlotProps, Style, Theme } from '../types';
3
4
  type AreaDataItem = {
@@ -5,6 +6,6 @@ type AreaDataItem = {
5
6
  value: number;
6
7
  [key: string]: string | number;
7
8
  };
8
- export type AreaProps = BasePlotProps<AreaDataItem> & Theme & Style;
9
+ export type AreaProps = BasePlotProps<AreaDataItem> & Partial<AreaConfig> & Theme & Style;
9
10
  declare const Area: (props: AreaProps) => React.JSX.Element;
10
11
  export default Area;
@@ -1,3 +1,4 @@
1
+ import type { BoxConfig } from '@ant-design/plots';
1
2
  import React from 'react';
2
3
  import type { BasePlotProps, Style, Theme } from '../types';
3
4
  type BoxplotDatum = {
@@ -5,9 +6,6 @@ type BoxplotDatum = {
5
6
  value: number;
6
7
  group?: string;
7
8
  };
8
- export type BoxplotProps = BasePlotProps<BoxplotDatum> & Theme & Style & {
9
- xField?: string;
10
- yField?: string;
11
- };
9
+ export type BoxplotProps = BasePlotProps<BoxplotDatum> & Partial<BoxConfig> & Theme & Style;
12
10
  declare const Boxplot: (props: BoxplotProps) => React.JSX.Element;
13
11
  export default Boxplot;
@@ -39,7 +39,7 @@ var import_theme = require("../theme");
39
39
  var defaultConfig = (props) => {
40
40
  var _a;
41
41
  const { data, style = {}, axisYTitle, axisXTitle, xField = "category", yField = "value" } = props;
42
- const { backgroundColor, palette } = style;
42
+ const { backgroundColor, palette, startAtZero = false } = style;
43
43
  const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
44
44
  let paletteConfig = { color: void 0 };
45
45
  const hasPalette = !!(palette == null ? void 0 : palette[0]);
@@ -70,7 +70,7 @@ var defaultConfig = (props) => {
70
70
  scale: {
71
71
  x: { paddingInner: 0.6, paddingOuter: 0.3 },
72
72
  series: { paddingInner: 0.3, paddingOuter: 0.1 },
73
- y: { nice: true },
73
+ y: { nice: true, zero: startAtZero },
74
74
  ...paletteConfig
75
75
  },
76
76
  style: { stroke: "black" },
@@ -1,3 +1,4 @@
1
+ import type { ColumnConfig } from '@ant-design/plots';
1
2
  import React from 'react';
2
3
  import type { BasePlotProps, Style, Theme } from '../types';
3
4
  export type ColumnDataItem = {
@@ -5,7 +6,7 @@ export type ColumnDataItem = {
5
6
  value: number;
6
7
  [key: string]: string | number;
7
8
  };
8
- export type ColumnProps = BasePlotProps<ColumnDataItem> & Theme & Style & {
9
+ export type ColumnProps = BasePlotProps<ColumnDataItem> & Partial<ColumnConfig> & Theme & Style & {
9
10
  group?: boolean;
10
11
  stack?: boolean;
11
12
  };
@@ -5,6 +5,11 @@ export type DualAxesProps = Partial<DualAxesConfig> & {
5
5
  axisXTitle?: string;
6
6
  series: DualAxesSeriesItem[];
7
7
  legendTypeList?: string[];
8
+ style?: {
9
+ palette?: string[];
10
+ backgroundColor?: string;
11
+ startAtZero?: boolean;
12
+ };
8
13
  };
9
14
  export type DualAxesSeriesItem = {
10
15
  type: string;
@@ -70,9 +70,10 @@ var defaultConfig = (props) => {
70
70
  };
71
71
  };
72
72
  var DualAxes = (props) => {
73
- const { categories, series, theme = "default", ...others } = props;
73
+ const { categories, series, theme = "default", style = {}, ...others } = props;
74
+ const { startAtZero = false } = style;
74
75
  const themeConfig = import_theme.THEME_MAP[theme];
75
- const transformData = (0, import_react.useMemo)(() => (0, import_util.transform)(series, categories), [props]);
76
+ const transformData = (0, import_react.useMemo)(() => (0, import_util.transform)(series, categories, startAtZero), [props]);
76
77
  const config = (0, import_hooks.usePlotConfig)("DualAxes", defaultConfig, {
77
78
  ...others,
78
79
  ...transformData,
@@ -1,5 +1,5 @@
1
1
  import type { DualAxesSeriesItem } from '.';
2
- export declare function transform(series: DualAxesSeriesItem[], categories: string[]): {
2
+ export declare function transform(series: DualAxesSeriesItem[], categories: string[], startAtZero?: boolean): {
3
3
  children: any[];
4
4
  data: {
5
5
  [key: string]: any;
@@ -23,7 +23,7 @@ __export(util_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(util_exports);
25
25
  var import_types = require("../types");
26
- function transform(series, categories) {
26
+ function transform(series, categories, startAtZero = false) {
27
27
  const newChildren = series.sort((a, b) => {
28
28
  const ORDER = ["column", "line"];
29
29
  return ORDER.indexOf(a.type) - ORDER.indexOf(b.type);
@@ -34,6 +34,7 @@ function transform(series, categories) {
34
34
  ...others,
35
35
  yField: defaultYField,
36
36
  axis: { y: { title: axisYTitle } },
37
+ scale: { y: { nice: true, zero: startAtZero } },
37
38
  // data放在最外层
38
39
  data: void 0
39
40
  };
@@ -44,8 +44,8 @@ var defaultConfig = (props) => {
44
44
  data,
45
45
  theme: import_theme.THEME_MAP[theme],
46
46
  title,
47
- padding: 40,
48
- insetRight: 28,
47
+ paddingLeft: 40,
48
+ paddingRight: 68,
49
49
  children: [
50
50
  {
51
51
  type: "interval",
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import type { BasePlotProps, Style, Theme } from '../types';
3
3
  export type HistogramProps = BasePlotProps<number> & Theme & Style & {
4
4
  binNumber: number;
5
+ binField?: (d: number) => number;
5
6
  };
6
7
  declare const Histogram: (props: HistogramProps) => React.JSX.Element;
7
8
  export default Histogram;
@@ -1,3 +1,4 @@
1
+ import type { LineConfig } from '@ant-design/plots';
1
2
  import React from 'react';
2
3
  import type { BasePlotProps, Style, Theme } from '../types';
3
4
  export type LineDataItem = {
@@ -5,6 +6,6 @@ export type LineDataItem = {
5
6
  value: number;
6
7
  [key: string]: string | number;
7
8
  };
8
- export type LineProps = BasePlotProps<LineDataItem> & Theme & Style;
9
+ export type LineProps = BasePlotProps<LineDataItem> & Partial<LineConfig> & Theme & Style;
9
10
  declare const Line: (props: LineProps) => React.JSX.Element;
10
11
  export default Line;
@@ -39,7 +39,7 @@ var import_hooks = require("../ConfigProvider/hooks");
39
39
  var import_theme = require("../theme");
40
40
  var defaultConfig = (props) => {
41
41
  const { data, xField = "time", yField = "value", style = {} } = props;
42
- const { palette, lineWidth, backgroundColor } = style;
42
+ const { palette, lineWidth, backgroundColor, startAtZero = false } = style;
43
43
  const hasGroupField = (0, import_lodash.get)(data, "[0].group") !== void 0;
44
44
  const axisYTitle = (0, import_lodash.get)(props, "axis.y.title");
45
45
  const hasPalette = !!(palette == null ? void 0 : palette[0]);
@@ -72,7 +72,8 @@ var defaultConfig = (props) => {
72
72
  },
73
73
  scale: {
74
74
  y: {
75
- nice: true
75
+ nice: true,
76
+ zero: startAtZero
76
77
  },
77
78
  ...paletteConfig
78
79
  },
@@ -5,6 +5,9 @@ type ScatterDataItem = {
5
5
  y: number;
6
6
  [key: string]: string | number;
7
7
  };
8
- export type ScatterProps = BasePlotProps<ScatterDataItem> & Theme & Style;
8
+ export type ScatterProps = BasePlotProps<ScatterDataItem> & Theme & Style & {
9
+ xField?: string;
10
+ yField?: string;
11
+ };
9
12
  declare const Scatter: (props: ScatterProps) => React.JSX.Element;
10
13
  export default Scatter;
@@ -38,7 +38,7 @@ var import_theme = require("../theme");
38
38
  var defaultConfig = (props) => {
39
39
  var _a;
40
40
  const { data, title, axisYTitle, axisXTitle, theme = "default", style = {} } = props;
41
- const { backgroundColor, palette } = style;
41
+ const { backgroundColor, palette, startAtZero = false } = style;
42
42
  const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
43
43
  let encode = {};
44
44
  let children = [];
@@ -59,7 +59,8 @@ var defaultConfig = (props) => {
59
59
  encode,
60
60
  scale: {
61
61
  y: {
62
- nice: true
62
+ nice: true,
63
+ zero: startAtZero
63
64
  },
64
65
  ...(palette == null ? void 0 : palette[0]) ? {
65
66
  color: {
@@ -82,7 +83,8 @@ var defaultConfig = (props) => {
82
83
  ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {},
83
84
  scale: {
84
85
  y: {
85
- nice: true
86
+ nice: true,
87
+ zero: startAtZero
86
88
  },
87
89
  ...(palette == null ? void 0 : palette[0]) ? {
88
90
  color: {
@@ -108,7 +110,8 @@ var defaultConfig = (props) => {
108
110
  encode,
109
111
  scale: {
110
112
  y: {
111
- nice: true
113
+ nice: true,
114
+ zero: startAtZero
112
115
  }
113
116
  },
114
117
  ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {},
@@ -126,7 +129,8 @@ var defaultConfig = (props) => {
126
129
  ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {},
127
130
  scale: {
128
131
  y: {
129
- nice: true
132
+ nice: true,
133
+ zero: startAtZero
130
134
  },
131
135
  ...(palette == null ? void 0 : palette[0]) ? {
132
136
  color: {
@@ -154,7 +158,8 @@ var defaultConfig = (props) => {
154
158
  children,
155
159
  scale: {
156
160
  y: {
157
- nice: true
161
+ nice: true,
162
+ zero: startAtZero
158
163
  }
159
164
  },
160
165
  ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {}
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import type { BasePlotProps, Style, Theme } from '../types';
3
+ type WaterfallDataItem = {
4
+ category: string;
5
+ value?: number;
6
+ isTotal?: boolean;
7
+ isIntermediateTotal?: boolean;
8
+ [key: string]: string | number | boolean | undefined;
9
+ };
10
+ type WaterfallStyle = {
11
+ backgroundColor?: string;
12
+ } & Style;
13
+ export type WaterfallProps = BasePlotProps<WaterfallDataItem> & Theme & {
14
+ style?: WaterfallStyle;
15
+ positiveColor?: string;
16
+ negativeColor?: string;
17
+ totalColor?: string;
18
+ axisXTitle?: string;
19
+ axisYTitle?: string;
20
+ };
21
+ declare const Waterfall: (props: WaterfallProps) => React.JSX.Element;
22
+ export default Waterfall;
@@ -0,0 +1,194 @@
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/Waterfall/index.tsx
30
+ var Waterfall_exports = {};
31
+ __export(Waterfall_exports, {
32
+ default: () => Waterfall_default
33
+ });
34
+ module.exports = __toCommonJS(Waterfall_exports);
35
+ var import_g2 = require("@antv/g2");
36
+ var import_react = __toESM(require("react"));
37
+ var import_theme = require("../theme");
38
+ var DEFAULT_POSITIVE_COLOR = "#FF4D4F";
39
+ var DEFAULT_NEGATIVE_COLOR = "#2EBB59";
40
+ var DEFAULT_TOTAL_COLOR = "#1783FF";
41
+ function transformWaterfallData(data) {
42
+ let cumulative = 0;
43
+ let lastIntermediateTotalEnd = 0;
44
+ let totalSum = 0;
45
+ return data.map((item) => {
46
+ const value = item.value || 0;
47
+ let start;
48
+ let end;
49
+ if (item.isTotal) {
50
+ start = 0;
51
+ end = totalSum;
52
+ } else if (item.isIntermediateTotal) {
53
+ start = lastIntermediateTotalEnd;
54
+ end = cumulative;
55
+ lastIntermediateTotalEnd = end;
56
+ } else {
57
+ start = cumulative;
58
+ end = cumulative + value;
59
+ cumulative = end;
60
+ totalSum += value;
61
+ }
62
+ return {
63
+ ...item,
64
+ __start__: start,
65
+ __end__: end,
66
+ __value__: item.isTotal ? totalSum : item.isIntermediateTotal ? end - start : value
67
+ };
68
+ });
69
+ }
70
+ function generateLinkData(data) {
71
+ return data.reduce((result, current, index) => {
72
+ if (index > 0) {
73
+ const previous = data[index - 1];
74
+ result.push({
75
+ x: [previous.category, current.category],
76
+ y: current.isTotal || current.isIntermediateTotal ? current.__end__ : current.__start__
77
+ });
78
+ }
79
+ return result;
80
+ }, []);
81
+ }
82
+ var defaultConfig = (props) => {
83
+ const {
84
+ data = [],
85
+ title,
86
+ style = {},
87
+ positiveColor: customPositiveColor,
88
+ negativeColor: customNegativeColor,
89
+ totalColor: customTotalColor,
90
+ axisXTitle,
91
+ axisYTitle,
92
+ theme = "default"
93
+ } = props;
94
+ const { backgroundColor } = style;
95
+ const positiveColor = customPositiveColor || DEFAULT_POSITIVE_COLOR;
96
+ const negativeColor = customNegativeColor || DEFAULT_NEGATIVE_COLOR;
97
+ const totalColor = customTotalColor || DEFAULT_TOTAL_COLOR;
98
+ const transformedData = transformWaterfallData(data);
99
+ const linkData = generateLinkData(transformedData);
100
+ return {
101
+ type: "view",
102
+ theme: import_theme.THEME_MAP[theme],
103
+ title,
104
+ data: transformedData,
105
+ axis: {
106
+ y: {
107
+ labelFormatter: "~s",
108
+ title: axisYTitle || false
109
+ },
110
+ x: {
111
+ title: axisXTitle || false
112
+ }
113
+ },
114
+ children: [
115
+ {
116
+ type: "interval",
117
+ data: transformedData,
118
+ encode: { x: "category", y: ["__start__", "__end__"], color: "category" },
119
+ style: {
120
+ maxWidth: 60,
121
+ stroke: "#666",
122
+ radius: 4,
123
+ fill: (d) => {
124
+ return d.isTotal || d.isIntermediateTotal ? totalColor : d.__value__ > 0 ? positiveColor : negativeColor;
125
+ }
126
+ },
127
+ labels: [
128
+ {
129
+ text: "__value__",
130
+ position: "inside",
131
+ fontSize: 10,
132
+ transform: [{ type: "overflowHide" }],
133
+ formatter: "~s",
134
+ fill: "#000",
135
+ fontWeight: 600,
136
+ stroke: "#fff"
137
+ }
138
+ ],
139
+ tooltip: (d) => {
140
+ const tooltipName = axisYTitle || d["category"];
141
+ return {
142
+ name: tooltipName,
143
+ value: d["__value__"]
144
+ };
145
+ }
146
+ },
147
+ {
148
+ type: "link",
149
+ data: linkData,
150
+ encode: {
151
+ x: "x",
152
+ y: "y"
153
+ },
154
+ zIndex: -1,
155
+ style: {
156
+ stroke: "#ccc",
157
+ lineDash: [4, 2],
158
+ lineWidth: 1
159
+ },
160
+ tooltip: false
161
+ }
162
+ ],
163
+ scale: {
164
+ y: {
165
+ nice: true
166
+ }
167
+ },
168
+ legend: false,
169
+ ...backgroundColor ? { viewStyle: { viewFill: backgroundColor } } : {}
170
+ };
171
+ };
172
+ var Waterfall = (props) => {
173
+ const containerRef = (0, import_react.useRef)(null);
174
+ const chartRef = (0, import_react.useRef)(null);
175
+ (0, import_react.useEffect)(() => {
176
+ if (!containerRef.current)
177
+ return;
178
+ const chart = new import_g2.Chart({
179
+ container: containerRef.current,
180
+ autoFit: true,
181
+ padding: "auto"
182
+ });
183
+ const config = defaultConfig(props);
184
+ chart.options(config);
185
+ chart.render();
186
+ chartRef.current = chart;
187
+ return () => {
188
+ chart.destroy();
189
+ chartRef.current = null;
190
+ };
191
+ }, [props]);
192
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: containerRef });
193
+ };
194
+ var Waterfall_default = Waterfall;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { ChartType } from './types';
2
3
  /********** plot chart **********/
3
4
  import { default as Area, type AreaProps } from './Area';
4
5
  import { default as Bar, type BarProps } from './Bar';
@@ -16,6 +17,7 @@ import { default as Scatter, type ScatterProps } from './Scatter';
16
17
  import { default as Treemap, type TreemapProps } from './Treemap';
17
18
  import { default as Venn, type VennProps } from './Venn';
18
19
  import { default as Violin, type ViolinProps } from './Violin';
20
+ import { default as Waterfall, type WaterfallProps } from './Waterfall';
19
21
  import { default as WordCloud, type WordCloudProps } from './WordCloud';
20
22
  /********** graph chart **********/
21
23
  import { default as FishboneDiagram, type FishboneDiagramProps } from './FishboneDiagram';
@@ -30,5 +32,43 @@ import { PinMap, type PinMapProps, HeatMap, type HeatMapProps, PathMap, type Pat
30
32
  /********** NTV **********/
31
33
  import { default as Table, type TableProps } from './Table';
32
34
  export { VisText, type VisTextProps } from './Text';
33
- export { Area, Bar, Boxplot, Column, DualAxes, FishboneDiagram, FlowDiagram, Funnel, HeatMap, Histogram, IndentedTree, Line, Liquid, MindMap, NetworkGraph, OrganizationChart, PathMap, Pie, PinMap, Radar, Sankey, Scatter, Treemap, Venn, Violin, Table, WordCloud, type AreaProps, type BarProps, type BoxplotProps, type ColumnProps, type DualAxesProps, type FishboneDiagramProps, type FlowDiagramProps, type FunnelProps, type HeatMapProps, type HistogramProps, type IndentedTreeProps, type LineProps, type LiquidProps, type MindMapProps, type NetworkGraphProps, type OrganizationChartProps, type PathMapProps, type PieProps, type PinMapProps, type RadarProps, type SankeyProps, type ScatterProps, type TreemapProps, type VennProps, type ViolinProps, type TableProps, type WordCloudProps, };
35
+ export { Area, Bar, Boxplot, Column, DualAxes, FishboneDiagram, FlowDiagram, Funnel, HeatMap, Histogram, IndentedTree, Line, Liquid, MindMap, NetworkGraph, OrganizationChart, PathMap, Pie, PinMap, Radar, Sankey, Scatter, Treemap, Venn, Violin, Waterfall, Table, WordCloud, type AreaProps, type BarProps, type BoxplotProps, type ColumnProps, type DualAxesProps, type FishboneDiagramProps, type FlowDiagramProps, type FunnelProps, type HeatMapProps, type HistogramProps, type IndentedTreeProps, type LineProps, type LiquidProps, type MindMapProps, type NetworkGraphProps, type OrganizationChartProps, type PathMapProps, type PieProps, type PinMapProps, type RadarProps, type SankeyProps, type ScatterProps, type TreemapProps, type VennProps, type ViolinProps, type WaterfallProps, type TableProps, type WordCloudProps, };
36
+ export type VisOptionMap = {
37
+ [ChartType.Area]: AreaProps;
38
+ [ChartType.Bar]: BarProps;
39
+ [ChartType.Boxplot]: BoxplotProps;
40
+ [ChartType.Column]: ColumnProps;
41
+ [ChartType.DualAxes]: DualAxesProps;
42
+ [ChartType.FishboneDiagram]: FishboneDiagramProps;
43
+ [ChartType.FlowDiagram]: FlowDiagramProps;
44
+ [ChartType.Funnel]: FunnelProps;
45
+ [ChartType.HeatMap]: HeatMapProps;
46
+ [ChartType.Histogram]: HistogramProps;
47
+ [ChartType.IndentedTree]: IndentedTreeProps;
48
+ [ChartType.Line]: LineProps;
49
+ [ChartType.Liquid]: LiquidProps;
50
+ [ChartType.MindMap]: MindMapProps;
51
+ [ChartType.NetworkGraph]: NetworkGraphProps;
52
+ [ChartType.OrganizationChart]: OrganizationChartProps;
53
+ [ChartType.PathMap]: PathMapProps;
54
+ [ChartType.Pie]: PieProps;
55
+ [ChartType.PinMap]: PinMapProps;
56
+ [ChartType.Radar]: RadarProps;
57
+ [ChartType.Sankey]: SankeyProps;
58
+ [ChartType.Scatter]: ScatterProps;
59
+ [ChartType.Table]: TableProps;
60
+ [ChartType.Treemap]: TreemapProps;
61
+ [ChartType.Venn]: VennProps;
62
+ [ChartType.Violin]: ViolinProps;
63
+ [ChartType.Waterfall]: WaterfallProps;
64
+ [ChartType.WordCloud]: WordCloudProps;
65
+ };
66
+ /**
67
+ * 所有的 Vis 类型的类型定义
68
+ */
69
+ export type Spec = {
70
+ [K in keyof VisOptionMap]: {
71
+ type: K;
72
+ } & VisOptionMap[K];
73
+ }[keyof VisOptionMap];
34
74
  export declare const DEFAULT_CHART_COMPONENTS: Record<string, React.FC<any>>;
@@ -58,6 +58,7 @@ __export(export_exports, {
58
58
  Venn: () => import_Venn.default,
59
59
  Violin: () => import_Violin.default,
60
60
  VisText: () => import_Text.VisText,
61
+ Waterfall: () => import_Waterfall.default,
61
62
  WordCloud: () => import_WordCloud.default
62
63
  });
63
64
  module.exports = __toCommonJS(export_exports);
@@ -78,6 +79,7 @@ var import_Scatter = __toESM(require("./Scatter"));
78
79
  var import_Treemap = __toESM(require("./Treemap"));
79
80
  var import_Venn = __toESM(require("./Venn"));
80
81
  var import_Violin = __toESM(require("./Violin"));
82
+ var import_Waterfall = __toESM(require("./Waterfall"));
81
83
  var import_WordCloud = __toESM(require("./WordCloud"));
82
84
  var import_FishboneDiagram = __toESM(require("./FishboneDiagram"));
83
85
  var import_FlowDiagram = __toESM(require("./FlowDiagram"));
@@ -113,6 +115,7 @@ var DEFAULT_CHART_COMPONENTS = {
113
115
  [import_types.ChartType.Treemap]: import_Treemap.default,
114
116
  [import_types.ChartType.Venn]: import_Venn.default,
115
117
  [import_types.ChartType.Violin]: import_Violin.default,
118
+ [import_types.ChartType.Waterfall]: import_Waterfall.default,
116
119
  [import_types.ChartType.Table]: import_Table.default,
117
120
  [import_types.ChartType.WordCloud]: import_WordCloud.default,
118
121
  [import_types.ChartType.OrganizationChart]: import_OrganizationChart.default
@@ -148,5 +151,6 @@ var DEFAULT_CHART_COMPONENTS = {
148
151
  Venn,
149
152
  Violin,
150
153
  VisText,
154
+ Waterfall,
151
155
  WordCloud
152
156
  });
@@ -2,6 +2,8 @@
2
2
  export * from './export';
3
3
  /********** export types **********/
4
4
  export * from './types';
5
+ /********** export render **********/
6
+ export * from './render';
5
7
  /********** export GPTVis **********/
6
8
  export { withChartCode, withDefaultChartCode } from './ChartCodeRender';
7
9
  export type { CodeBlockComponent, ErrorRender, WithChartCodeOptions } from './ChartCodeRender/type';
package/dist/cjs/index.js CHANGED
@@ -41,6 +41,7 @@ __export(src_exports, {
41
41
  module.exports = __toCommonJS(src_exports);
42
42
  __reExport(src_exports, require("./export"), module.exports);
43
43
  __reExport(src_exports, require("./types"), module.exports);
44
+ __reExport(src_exports, require("./render"), module.exports);
44
45
  var import_ChartCodeRender = require("./ChartCodeRender");
45
46
  var import_ConfigProvider = __toESM(require("./ConfigProvider"));
46
47
  var import_GPTVis = __toESM(require("./GPTVis"));
@@ -56,5 +57,6 @@ var import_version = __toESM(require("./version"));
56
57
  withChartCode,
57
58
  withDefaultChartCode,
58
59
  ...require("./export"),
59
- ...require("./types")
60
+ ...require("./types"),
61
+ ...require("./render")
60
62
  });
@@ -0,0 +1,2 @@
1
+ import { type Spec } from './export';
2
+ export declare function render(container: string, spec: Spec): void;
@@ -0,0 +1,67 @@
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/render.tsx
30
+ var render_exports = {};
31
+ __export(render_exports, {
32
+ render: () => render
33
+ });
34
+ module.exports = __toCommonJS(render_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_react_dom = __toESM(require("react-dom"));
37
+ var import_export = require("./export");
38
+ var roots = /* @__PURE__ */ new Map();
39
+ function getRoot(container) {
40
+ if (roots.has(container)) {
41
+ return roots.get(container);
42
+ }
43
+ const root = import_react_dom.default.createRoot(container);
44
+ roots.set(container, root);
45
+ return root;
46
+ }
47
+ function render(container, spec) {
48
+ const mount = typeof container === "string" ? document.querySelector(container) : container;
49
+ if (!mount)
50
+ throw new Error("Target container not found: " + container);
51
+ const { type, ...chartProps } = spec;
52
+ const ChartComp = import_export.DEFAULT_CHART_COMPONENTS[type];
53
+ if (!ChartComp) {
54
+ throw new Error(`Unknown chart type: ${type}`);
55
+ }
56
+ const chartElement = import_react.default.createElement(ChartComp, chartProps);
57
+ if (import_react_dom.default.createRoot) {
58
+ const root = getRoot(mount);
59
+ root.render(chartElement);
60
+ } else {
61
+ import_react_dom.default.render(chartElement, mount);
62
+ }
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ render
67
+ });
@@ -28,6 +28,7 @@ export declare enum ChartType {
28
28
  Treemap = "treemap",
29
29
  Venn = "venn",
30
30
  Violin = "violin",
31
+ Waterfall = "waterfall",
31
32
  Table = "table",
32
33
  VisText = "vis-text",
33
34
  WordCloud = "word-cloud"
@@ -81,5 +82,6 @@ export interface Style {
81
82
  lineWidth?: number;
82
83
  backgroundColor?: string;
83
84
  palette?: string[];
85
+ startAtZero?: boolean;
84
86
  };
85
87
  }
@@ -48,6 +48,7 @@ var ChartType = /* @__PURE__ */ ((ChartType2) => {
48
48
  ChartType2["Treemap"] = "treemap";
49
49
  ChartType2["Venn"] = "venn";
50
50
  ChartType2["Violin"] = "violin";
51
+ ChartType2["Waterfall"] = "waterfall";
51
52
  ChartType2["Table"] = "table";
52
53
  ChartType2["VisText"] = "vis-text";
53
54
  ChartType2["WordCloud"] = "word-cloud";