@antv/gpt-vis 0.4.7 → 0.5.0-beta.0

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 (76) hide show
  1. package/dist/cjs/ssr/area.d.ts +6 -0
  2. package/dist/cjs/ssr/area.js +64 -0
  3. package/dist/cjs/ssr/bar.d.ts +6 -0
  4. package/dist/cjs/ssr/bar.js +79 -0
  5. package/dist/cjs/ssr/column.d.ts +6 -0
  6. package/dist/cjs/ssr/column.js +77 -0
  7. package/dist/cjs/ssr/dual-axes.d.ts +6 -0
  8. package/dist/cjs/ssr/dual-axes.js +98 -0
  9. package/dist/cjs/ssr/fishbone-diagram.d.ts +6 -0
  10. package/dist/cjs/ssr/fishbone-diagram.js +189 -0
  11. package/dist/cjs/ssr/flow-diagram.d.ts +6 -0
  12. package/dist/cjs/ssr/flow-diagram.js +82 -0
  13. package/dist/cjs/ssr/histogram.d.ts +6 -0
  14. package/dist/cjs/ssr/histogram.js +50 -0
  15. package/dist/cjs/ssr/index.d.ts +2 -0
  16. package/dist/cjs/ssr/index.js +79 -0
  17. package/dist/cjs/ssr/line.d.ts +6 -0
  18. package/dist/cjs/ssr/line.js +62 -0
  19. package/dist/cjs/ssr/mind-map.d.ts +6 -0
  20. package/dist/cjs/ssr/mind-map.js +326 -0
  21. package/dist/cjs/ssr/network-graph.d.ts +6 -0
  22. package/dist/cjs/ssr/network-graph.js +72 -0
  23. package/dist/cjs/ssr/pie.d.ts +6 -0
  24. package/dist/cjs/ssr/pie.js +64 -0
  25. package/dist/cjs/ssr/radar.d.ts +6 -0
  26. package/dist/cjs/ssr/radar.js +92 -0
  27. package/dist/cjs/ssr/scatter.d.ts +6 -0
  28. package/dist/cjs/ssr/scatter.js +56 -0
  29. package/dist/cjs/ssr/treemap.d.ts +6 -0
  30. package/dist/cjs/ssr/treemap.js +57 -0
  31. package/dist/cjs/ssr/type.d.ts +30 -0
  32. package/dist/cjs/ssr/type.js +17 -0
  33. package/dist/cjs/ssr/word-cloud.d.ts +6 -0
  34. package/dist/cjs/ssr/word-cloud.js +48 -0
  35. package/dist/cjs/version.d.ts +1 -1
  36. package/dist/cjs/version.js +1 -1
  37. package/dist/esm/ssr/area.d.ts +6 -0
  38. package/dist/esm/ssr/area.js +67 -0
  39. package/dist/esm/ssr/bar.d.ts +6 -0
  40. package/dist/esm/ssr/bar.js +71 -0
  41. package/dist/esm/ssr/column.d.ts +6 -0
  42. package/dist/esm/ssr/column.js +65 -0
  43. package/dist/esm/ssr/dual-axes.d.ts +6 -0
  44. package/dist/esm/ssr/dual-axes.js +122 -0
  45. package/dist/esm/ssr/fishbone-diagram.d.ts +6 -0
  46. package/dist/esm/ssr/fishbone-diagram.js +195 -0
  47. package/dist/esm/ssr/flow-diagram.d.ts +6 -0
  48. package/dist/esm/ssr/flow-diagram.js +89 -0
  49. package/dist/esm/ssr/histogram.d.ts +6 -0
  50. package/dist/esm/ssr/histogram.js +56 -0
  51. package/dist/esm/ssr/index.d.ts +2 -0
  52. package/dist/esm/ssr/index.js +68 -0
  53. package/dist/esm/ssr/line.d.ts +6 -0
  54. package/dist/esm/ssr/line.js +61 -0
  55. package/dist/esm/ssr/mind-map.d.ts +6 -0
  56. package/dist/esm/ssr/mind-map.js +416 -0
  57. package/dist/esm/ssr/network-graph.d.ts +6 -0
  58. package/dist/esm/ssr/network-graph.js +79 -0
  59. package/dist/esm/ssr/pie.d.ts +6 -0
  60. package/dist/esm/ssr/pie.js +66 -0
  61. package/dist/esm/ssr/radar.d.ts +6 -0
  62. package/dist/esm/ssr/radar.js +88 -0
  63. package/dist/esm/ssr/scatter.d.ts +6 -0
  64. package/dist/esm/ssr/scatter.js +52 -0
  65. package/dist/esm/ssr/treemap.d.ts +6 -0
  66. package/dist/esm/ssr/treemap.js +51 -0
  67. package/dist/esm/ssr/type.d.ts +30 -0
  68. package/dist/esm/ssr/type.js +1 -0
  69. package/dist/esm/ssr/word-cloud.d.ts +6 -0
  70. package/dist/esm/ssr/word-cloud.js +40 -0
  71. package/dist/esm/version.d.ts +1 -1
  72. package/dist/esm/version.js +1 -1
  73. package/dist/umd/424.async.js +1 -0
  74. package/dist/umd/index.min.js +1 -1
  75. package/package.json +58 -31
  76. package/dist/umd/100.async.js +0 -1
@@ -0,0 +1,122 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
+ var _excluded = ["type", "axisYTitle"];
6
+ import { createChart } from '@antv/g2-ssr';
7
+ export function DualAxes(_x) {
8
+ return _DualAxes.apply(this, arguments);
9
+ }
10
+ function _DualAxes() {
11
+ _DualAxes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
12
+ var series, categories, title, width, height, ChartType, transform, config;
13
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14
+ while (1) switch (_context.prev = _context.next) {
15
+ case 0:
16
+ transform = function _transform(series, categories) {
17
+ var newChildren = series.map(function (item) {
18
+ var type = item.type,
19
+ axisYTitle = item.axisYTitle,
20
+ others = _objectWithoutProperties(item, _excluded);
21
+ var baseConfig = _objectSpread(_objectSpread({}, others), {}, {
22
+ axis: {
23
+ y: {
24
+ title: axisYTitle
25
+ }
26
+ },
27
+ encode: {
28
+ x: 'category',
29
+ y: axisYTitle,
30
+ color: function color() {
31
+ return axisYTitle;
32
+ }
33
+ },
34
+ legend: {
35
+ color: {
36
+ itemMarker: function itemMarker(v) {
37
+ if (v === axisYTitle) return 'smooth';
38
+ return 'rect';
39
+ }
40
+ }
41
+ },
42
+ data: undefined
43
+ });
44
+ if (type === ChartType.Column) {
45
+ return _objectSpread(_objectSpread({}, baseConfig), {}, {
46
+ type: 'interval'
47
+ });
48
+ }
49
+ if (type === ChartType.Line) {
50
+ return _objectSpread(_objectSpread({}, baseConfig), {}, {
51
+ type: type,
52
+ axis: {
53
+ y: {
54
+ position: 'right',
55
+ title: axisYTitle
56
+ }
57
+ },
58
+ encode: {
59
+ x: 'category',
60
+ y: axisYTitle,
61
+ shape: 'smooth',
62
+ color: function color() {
63
+ return axisYTitle;
64
+ }
65
+ },
66
+ style: {
67
+ lineWidth: 2,
68
+ stroke: '#5AD8A6'
69
+ },
70
+ scale: {
71
+ y: {
72
+ independent: true
73
+ }
74
+ }
75
+ });
76
+ }
77
+ return baseConfig;
78
+ });
79
+ var newData = categories.map(function (item, index) {
80
+ var temp = {
81
+ category: item
82
+ };
83
+ series.forEach(function (s, i) {
84
+ var defaultYField = s.axisYTitle || "value_".concat(i + 1);
85
+ temp[defaultYField] = s.data[index];
86
+ });
87
+ return temp;
88
+ });
89
+ var legendTypeList = series.map(function (item) {
90
+ return item.type === ChartType.Line ? 'smooth' : 'rect';
91
+ });
92
+ return {
93
+ children: newChildren,
94
+ data: newData,
95
+ legendTypeList: legendTypeList
96
+ };
97
+ };
98
+ series = options.series, categories = options.categories, title = options.title, width = options.width, height = options.height;
99
+ ChartType = /*#__PURE__*/function (ChartType) {
100
+ ChartType["Column"] = "column";
101
+ ChartType["Line"] = "line";
102
+ return ChartType;
103
+ }({});
104
+ config = transform(series, categories);
105
+ _context.next = 6;
106
+ return createChart(_objectSpread({
107
+ type: 'view',
108
+ autoFit: true,
109
+ title: title,
110
+ width: width,
111
+ height: height
112
+ }, config));
113
+ case 6:
114
+ return _context.abrupt("return", _context.sent);
115
+ case 7:
116
+ case "end":
117
+ return _context.stop();
118
+ }
119
+ }, _callee);
120
+ }));
121
+ return _DualAxes.apply(this, arguments);
122
+ }
@@ -0,0 +1,6 @@
1
+ import { type FishboneDiagramProps } from '../export';
2
+ import { type BaseChartConfig } from './type';
3
+ export type FishboneDiagramOptions = BaseChartConfig & {
4
+ type: 'fishbone-diagram';
5
+ } & FishboneDiagramProps;
6
+ export declare function FishboneDiagram(options: FishboneDiagramOptions): Promise<import("@antv/g6-ssr").Graph>;
@@ -0,0 +1,195 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
7
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
8
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
9
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
+ var _excluded = ["children"];
11
+ import { BaseTransform, ExtensionCategory, treeToGraphData } from '@antv/g6';
12
+ import { createGraph, register } from '@antv/g6-ssr';
13
+ import { createCanvas } from 'canvas';
14
+ var canvas = null;
15
+ var ctx = null;
16
+ var measureText = function measureText(style) {
17
+ if (!canvas) {
18
+ canvas = createCanvas(0, 0);
19
+ ctx = canvas.getContext('2d');
20
+ }
21
+ var font = [style.fontStyle || 'normal', style.fontWeight || 'normal', "".concat(style.fontSize || 12, "px"), style.fontFamily || 'sans-serif'].join(' ');
22
+ ctx.font = font;
23
+ return ctx.measureText(style.text).width;
24
+ };
25
+ var AssignColorByBranch = /*#__PURE__*/function (_BaseTransform) {
26
+ _inherits(AssignColorByBranch, _BaseTransform);
27
+ var _super = _createSuper(AssignColorByBranch);
28
+ function AssignColorByBranch(context, options) {
29
+ _classCallCheck(this, AssignColorByBranch);
30
+ return _super.call(this, context, Object.assign({}, AssignColorByBranch.defaultOptions, options));
31
+ }
32
+ _createClass(AssignColorByBranch, [{
33
+ key: "beforeDraw",
34
+ value: function beforeDraw(input) {
35
+ var _this = this;
36
+ var nodes = this.context.model.getNodeData();
37
+ if (nodes.length === 0) return input;
38
+ var colorIndex = 0;
39
+ var dfs = function dfs(nodeId, color) {
40
+ var _node$children;
41
+ var node = nodes.find(function (datum) {
42
+ return datum.id == nodeId;
43
+ });
44
+ if (!node) return;
45
+ node.style || (node.style = {});
46
+ node.style.color = color || _this.options.colors[colorIndex++ % _this.options.colors.length];
47
+ (_node$children = node.children) === null || _node$children === void 0 || _node$children.forEach(function (childId) {
48
+ var _node$style;
49
+ return dfs(childId, (_node$style = node.style) === null || _node$style === void 0 ? void 0 : _node$style.color);
50
+ });
51
+ };
52
+ // @ts-ignore
53
+ nodes.filter(function (node) {
54
+ return node.depth === 1;
55
+ }).forEach(function (rootNode) {
56
+ return dfs(rootNode.id);
57
+ });
58
+ return input;
59
+ }
60
+ }]);
61
+ return AssignColorByBranch;
62
+ }(BaseTransform);
63
+ _defineProperty(AssignColorByBranch, "defaultOptions", {
64
+ colors: ['#1783FF', '#F08F56', '#D580FF', '#00C9C9', '#7863FF', '#DB9D0D', '#60C42D', '#FF80CA', '#2491B3', '#17C76F']
65
+ });
66
+ register(ExtensionCategory.TRANSFORM, 'assign-color-by-branch', AssignColorByBranch);
67
+ var getNodeSize = function getNodeSize(id, depth) {
68
+ var FONT_FAMILY = 'system-ui, sans-serif';
69
+ return depth === 0 ? [measureText({
70
+ text: id,
71
+ fontSize: 24,
72
+ fontWeight: 'bold',
73
+ fontFamily: FONT_FAMILY
74
+ }) + 80, 70] : depth === 1 ? [measureText({
75
+ text: id,
76
+ fontSize: 18,
77
+ fontFamily: FONT_FAMILY
78
+ }) + 50, 42] : [2, 30];
79
+ };
80
+ function visTreeData2GraphData(data) {
81
+ return treeToGraphData(data, {
82
+ getNodeData: function getNodeData(datum, depth) {
83
+ datum.id = datum.name;
84
+ datum.depth = depth;
85
+ if (!datum.children) return datum;
86
+ var children = datum.children,
87
+ restDatum = _objectWithoutProperties(datum, _excluded);
88
+ return _objectSpread(_objectSpread({}, restDatum), {}, {
89
+ children: children.map(function (child) {
90
+ return child.name;
91
+ })
92
+ });
93
+ },
94
+ getEdgeData: function getEdgeData(source, target) {
95
+ return {
96
+ source: source.name,
97
+ target: target.name
98
+ };
99
+ }
100
+ });
101
+ }
102
+ export function FishboneDiagram(_x) {
103
+ return _FishboneDiagram.apply(this, arguments);
104
+ }
105
+ function _FishboneDiagram() {
106
+ _FishboneDiagram = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
107
+ var data, _options$width, width, _options$height, height, dataParse;
108
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
109
+ while (1) switch (_context.prev = _context.next) {
110
+ case 0:
111
+ data = options.data, _options$width = options.width, width = _options$width === void 0 ? 600 : _options$width, _options$height = options.height, height = _options$height === void 0 ? 400 : _options$height;
112
+ dataParse = visTreeData2GraphData(data);
113
+ _context.next = 4;
114
+ return createGraph({
115
+ autoFit: {
116
+ type: 'view',
117
+ options: {
118
+ when: 'overflow',
119
+ direction: 'x'
120
+ }
121
+ },
122
+ width: width,
123
+ height: height,
124
+ data: dataParse,
125
+ padding: 20,
126
+ node: {
127
+ type: 'rect',
128
+ // @ts-ignore
129
+ style: function style(d) {
130
+ var style = {
131
+ radius: 8,
132
+ size: getNodeSize(d.id, d.depth),
133
+ labelText: d.id,
134
+ labelPlacement: 'left',
135
+ labelFontFamily: 'Gill Sans'
136
+ };
137
+ if (d.depth === 0) {
138
+ Object.assign(style, {
139
+ fill: '#EFF0F0',
140
+ labelFill: '#262626',
141
+ labelFontWeight: 'bold',
142
+ labelFontSize: 24,
143
+ labelOffsetY: 4,
144
+ labelPlacement: 'center',
145
+ labelLineHeight: 24
146
+ });
147
+ } else if (d.depth === 1) {
148
+ var _d$style;
149
+ Object.assign(style, {
150
+ labelFontSize: 18,
151
+ labelFill: '#fff',
152
+ labelFillOpacity: 0.9,
153
+ labelOffsetY: 5,
154
+ labelPlacement: 'center',
155
+ fill: (_d$style = d.style) === null || _d$style === void 0 ? void 0 : _d$style.color
156
+ });
157
+ } else {
158
+ Object.assign(style, {
159
+ fill: 'transparent',
160
+ labelFontSize: 16,
161
+ labeFill: '#262626'
162
+ });
163
+ }
164
+ return style;
165
+ }
166
+ },
167
+ edge: {
168
+ type: 'polyline',
169
+ style: {
170
+ lineWidth: 3,
171
+ // @ts-ignore
172
+ stroke: function stroke(data) {
173
+ // @ts-ignore
174
+ return this.getNodeData(data.target).style.color || '#99ADD1';
175
+ }
176
+ }
177
+ },
178
+ transforms: ['assign-color-by-branch'],
179
+ layout: {
180
+ type: 'fishbone',
181
+ direction: 'RL',
182
+ hGap: 40,
183
+ vGap: 60
184
+ }
185
+ });
186
+ case 4:
187
+ return _context.abrupt("return", _context.sent);
188
+ case 5:
189
+ case "end":
190
+ return _context.stop();
191
+ }
192
+ }, _callee);
193
+ }));
194
+ return _FishboneDiagram.apply(this, arguments);
195
+ }
@@ -0,0 +1,6 @@
1
+ import { type FlowDiagramProps } from '../export';
2
+ import { type BaseChartConfig } from './type';
3
+ export type FlowDiagramOptions = BaseChartConfig & {
4
+ type: 'flow-diagram';
5
+ } & FlowDiagramProps;
6
+ export declare function FlowDiagram(options: FlowDiagramOptions): Promise<import("@antv/g6-ssr").Graph>;
@@ -0,0 +1,89 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import { createGraph } from '@antv/g6-ssr';
5
+ export function FlowDiagram(_x) {
6
+ return _FlowDiagram.apply(this, arguments);
7
+ }
8
+ function _FlowDiagram() {
9
+ _FlowDiagram = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
10
+ var data, _options$width, width, _options$height, height, graphData;
11
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ data = options.data, _options$width = options.width, width = _options$width === void 0 ? 600 : _options$width, _options$height = options.height, height = _options$height === void 0 ? 400 : _options$height;
15
+ graphData = {
16
+ nodes: data.nodes.map(function (node) {
17
+ return _objectSpread(_objectSpread({}, node), {}, {
18
+ id: node.name
19
+ });
20
+ }),
21
+ edges: data.edges.map(function (edge) {
22
+ return _objectSpread(_objectSpread({}, edge), {}, {
23
+ id: "".concat(edge.source, "-").concat(edge.target)
24
+ });
25
+ })
26
+ };
27
+ _context.next = 4;
28
+ return createGraph({
29
+ data: graphData,
30
+ width: width,
31
+ height: height,
32
+ devicePixelRatio: 3,
33
+ autoFit: 'view',
34
+ padding: 20,
35
+ animation: false,
36
+ node: {
37
+ type: 'rect',
38
+ style: {
39
+ size: function size(d) {
40
+ return [d.name.length * 15 + 30, 35];
41
+ },
42
+ radius: 6,
43
+ // @ts-ignore
44
+ iconText: function iconText(d) {
45
+ return d.name;
46
+ },
47
+ iconFontSize: 12,
48
+ iconFontWeight: 800
49
+ }
50
+ },
51
+ edge: {
52
+ type: 'polyline',
53
+ style: {
54
+ lineWidth: 2,
55
+ radius: 10,
56
+ stroke: '#99ADD1',
57
+ endArrow: true,
58
+ // @ts-ignore
59
+ labelText: function labelText(d) {
60
+ return d.name;
61
+ },
62
+ labelFill: '#555555',
63
+ labelFontWeight: 800,
64
+ labelBackground: true,
65
+ labelBackgroundFill: 'rgba(255,255,255,0.6)',
66
+ labelBackgroundOpacity: 1,
67
+ labelBackgroundLineWidth: 2,
68
+ labelPadding: [2, 5],
69
+ labelBackgroundRadius: 2,
70
+ router: {
71
+ type: 'orth'
72
+ }
73
+ }
74
+ },
75
+ layout: {
76
+ type: 'dagre',
77
+ rankdir: 'LR'
78
+ }
79
+ });
80
+ case 4:
81
+ return _context.abrupt("return", _context.sent);
82
+ case 5:
83
+ case "end":
84
+ return _context.stop();
85
+ }
86
+ }, _callee);
87
+ }));
88
+ return _FlowDiagram.apply(this, arguments);
89
+ }
@@ -0,0 +1,6 @@
1
+ import { type HistogramProps } from '../export';
2
+ import { type BaseChartConfig } from './type';
3
+ export type HistogramOptions = BaseChartConfig & {
4
+ type: 'histogram';
5
+ } & HistogramProps;
6
+ export declare function Histogram(options: HistogramOptions): Promise<import("@antv/g2-ssr").Chart>;
@@ -0,0 +1,56 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import { createChart } from '@antv/g2-ssr';
4
+ export function Histogram(_x) {
5
+ return _Histogram.apply(this, arguments);
6
+ }
7
+ function _Histogram() {
8
+ _Histogram = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
9
+ var data, title, width, height, axisYTitle, axisXTitle, binNumber;
10
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
11
+ while (1) switch (_context.prev = _context.next) {
12
+ case 0:
13
+ data = options.data, title = options.title, width = options.width, height = options.height, axisYTitle = options.axisYTitle, axisXTitle = options.axisXTitle, binNumber = options.binNumber; // TODO 有问题
14
+ _context.next = 3;
15
+ return createChart({
16
+ type: 'interval',
17
+ width: width,
18
+ height: height,
19
+ data: data,
20
+ title: title,
21
+ encode: {
22
+ x: function x(d) {
23
+ return d;
24
+ },
25
+ y: 'count'
26
+ },
27
+ transform: [{
28
+ type: 'binX',
29
+ y: 'count',
30
+ thresholds: binNumber
31
+ }],
32
+ style: {
33
+ minHeight: 1,
34
+ columnWidthRatio: 1,
35
+ inset: 0.5
36
+ },
37
+ axis: {
38
+ x: {
39
+ title: axisXTitle
40
+ },
41
+ y: {
42
+ title: axisYTitle
43
+ }
44
+ },
45
+ animate: false
46
+ });
47
+ case 3:
48
+ return _context.abrupt("return", _context.sent);
49
+ case 4:
50
+ case "end":
51
+ return _context.stop();
52
+ }
53
+ }, _callee);
54
+ }));
55
+ return _Histogram.apply(this, arguments);
56
+ }
@@ -0,0 +1,2 @@
1
+ import type { Options } from './type';
2
+ export declare function render(options: Options): Promise<import("@antv/g2-ssr").Chart>;
@@ -0,0 +1,68 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import { Area } from "./area";
4
+ import { Bar } from "./bar";
5
+ import { Column } from "./column";
6
+ import { DualAxes } from "./dual-axes";
7
+ import { FishboneDiagram } from "./fishbone-diagram";
8
+ import { FlowDiagram } from "./flow-diagram";
9
+ import { Histogram } from "./histogram";
10
+ import { Line } from "./line";
11
+ import { MindMap } from "./mind-map";
12
+ import { NetworkGraph } from "./network-graph";
13
+ import { Pie } from "./pie";
14
+ import { Radar } from "./radar";
15
+ import { Scatter } from "./scatter";
16
+ import { Treemap } from "./treemap";
17
+ import { WordCloud } from "./word-cloud";
18
+ export function render(_x) {
19
+ return _render.apply(this, arguments);
20
+ }
21
+ function _render() {
22
+ _render = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
23
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
24
+ while (1) switch (_context.prev = _context.next) {
25
+ case 0:
26
+ _context.t0 = options.type;
27
+ _context.next = _context.t0 === 'line' ? 3 : _context.t0 === 'column' ? 4 : _context.t0 === 'pie' ? 5 : _context.t0 === 'area' ? 6 : _context.t0 === 'bar' ? 7 : _context.t0 === 'histogram' ? 8 : _context.t0 === 'scatter' ? 9 : _context.t0 === 'word-cloud' ? 10 : _context.t0 === 'treemap' ? 11 : _context.t0 === 'dual-axes' ? 12 : _context.t0 === 'radar' ? 13 : _context.t0 === 'mind-map' ? 14 : _context.t0 === 'network-graph' ? 15 : _context.t0 === 'flow-diagram' ? 16 : _context.t0 === 'fishbone-diagram' ? 17 : 18;
28
+ break;
29
+ case 3:
30
+ return _context.abrupt("return", Line(options));
31
+ case 4:
32
+ return _context.abrupt("return", Column(options));
33
+ case 5:
34
+ return _context.abrupt("return", Pie(options));
35
+ case 6:
36
+ return _context.abrupt("return", Area(options));
37
+ case 7:
38
+ return _context.abrupt("return", Bar(options));
39
+ case 8:
40
+ return _context.abrupt("return", Histogram(options));
41
+ case 9:
42
+ return _context.abrupt("return", Scatter(options));
43
+ case 10:
44
+ return _context.abrupt("return", WordCloud(options));
45
+ case 11:
46
+ return _context.abrupt("return", Treemap(options));
47
+ case 12:
48
+ return _context.abrupt("return", DualAxes(options));
49
+ case 13:
50
+ return _context.abrupt("return", Radar(options));
51
+ case 14:
52
+ return _context.abrupt("return", MindMap(options));
53
+ case 15:
54
+ return _context.abrupt("return", NetworkGraph(options));
55
+ case 16:
56
+ return _context.abrupt("return", FlowDiagram(options));
57
+ case 17:
58
+ return _context.abrupt("return", FishboneDiagram(options));
59
+ case 18:
60
+ throw new Error("Unknown chart type: ".concat(options.type));
61
+ case 19:
62
+ case "end":
63
+ return _context.stop();
64
+ }
65
+ }, _callee);
66
+ }));
67
+ return _render.apply(this, arguments);
68
+ }
@@ -0,0 +1,6 @@
1
+ import { type LineProps } from '../export';
2
+ import { type BaseChartConfig } from './type';
3
+ export type LineOptions = BaseChartConfig & {
4
+ type: 'line';
5
+ } & LineProps;
6
+ export declare function Line(options: LineOptions): Promise<import("@antv/g2-ssr").Chart>;
@@ -0,0 +1,61 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import { createChart } from '@antv/g2-ssr';
4
+ export function Line(_x) {
5
+ return _Line.apply(this, arguments);
6
+ }
7
+ function _Line() {
8
+ _Line = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
9
+ var _;
10
+ var data, title, _options$width, width, _options$height, height, axisYTitle, axisXTitle, hasGroupField, encode;
11
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ data = options.data, title = options.title, _options$width = options.width, width = _options$width === void 0 ? 600 : _options$width, _options$height = options.height, height = _options$height === void 0 ? 400 : _options$height, axisYTitle = options.axisYTitle, axisXTitle = options.axisXTitle;
15
+ hasGroupField = ((_ = (data || [])[0]) === null || _ === void 0 ? void 0 : _.group) !== undefined;
16
+ encode = {};
17
+ if (hasGroupField) {
18
+ encode = {
19
+ x: 'time',
20
+ y: 'value',
21
+ color: 'group'
22
+ };
23
+ } else {
24
+ encode = {
25
+ x: 'time',
26
+ y: 'value'
27
+ };
28
+ }
29
+ _context.next = 6;
30
+ return createChart({
31
+ type: 'view',
32
+ title: title,
33
+ data: data,
34
+ width: width,
35
+ height: height,
36
+ encode: encode,
37
+ style: {
38
+ minHeight: 1
39
+ },
40
+ axis: {
41
+ y: {
42
+ title: axisYTitle || false
43
+ },
44
+ x: {
45
+ title: axisXTitle || false
46
+ }
47
+ },
48
+ children: [{
49
+ type: 'line'
50
+ }]
51
+ });
52
+ case 6:
53
+ return _context.abrupt("return", _context.sent);
54
+ case 7:
55
+ case "end":
56
+ return _context.stop();
57
+ }
58
+ }, _callee);
59
+ }));
60
+ return _Line.apply(this, arguments);
61
+ }
@@ -0,0 +1,6 @@
1
+ import { type MindMapProps } from '../export';
2
+ import { type BaseChartConfig } from './type';
3
+ export type MindMapOptions = BaseChartConfig & {
4
+ type: 'mind-map';
5
+ } & MindMapProps;
6
+ export declare function MindMap(options: MindMapOptions): Promise<import("@antv/g6-ssr").Graph>;