@antv/gpt-vis 1.0.0-beta.2 → 1.0.1

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 (106) hide show
  1. package/README.md +282 -43
  2. package/README.zh-CN.md +286 -47
  3. package/dist/cjs/gpt-vis/index.js +1 -1
  4. package/dist/cjs/types/index.d.ts +2 -1
  5. package/dist/cjs/util/animation.d.ts +2 -0
  6. package/dist/cjs/util/animation.js +38 -0
  7. package/dist/cjs/util/components.d.ts +15 -0
  8. package/dist/cjs/util/components.js +94 -0
  9. package/dist/cjs/util/crosshair-axis-labels.d.ts +9 -0
  10. package/dist/cjs/util/crosshair-axis-labels.js +304 -0
  11. package/dist/cjs/util/index.d.ts +6 -0
  12. package/dist/cjs/util/index.js +33 -0
  13. package/dist/cjs/util/interaction.d.ts +14 -0
  14. package/dist/cjs/util/interaction.js +89 -0
  15. package/dist/cjs/util/theme.d.ts +18 -24
  16. package/dist/cjs/util/theme.js +303 -120
  17. package/dist/cjs/util/tokens.d.ts +31 -0
  18. package/dist/cjs/util/tokens.js +98 -0
  19. package/dist/cjs/vis/area/index.d.ts +2 -2
  20. package/dist/cjs/vis/area/index.js +76 -31
  21. package/dist/cjs/vis/bar/index.d.ts +2 -2
  22. package/dist/cjs/vis/bar/index.js +22 -19
  23. package/dist/cjs/vis/boxplot/index.js +1 -4
  24. package/dist/cjs/vis/column/index.d.ts +2 -2
  25. package/dist/cjs/vis/column/index.js +28 -18
  26. package/dist/cjs/vis/dual-axes/index.d.ts +2 -2
  27. package/dist/cjs/vis/dual-axes/index.js +90 -36
  28. package/dist/cjs/vis/fishbone-diagram/index.js +12 -4
  29. package/dist/cjs/vis/flow-diagram/index.js +27 -11
  30. package/dist/cjs/vis/funnel/index.d.ts +4 -2
  31. package/dist/cjs/vis/funnel/index.js +171 -92
  32. package/dist/cjs/vis/histogram/index.js +1 -4
  33. package/dist/cjs/vis/indented-tree/index.js +13 -3
  34. package/dist/cjs/vis/line/index.d.ts +2 -2
  35. package/dist/cjs/vis/line/index.js +71 -31
  36. package/dist/cjs/vis/liquid/index.d.ts +2 -2
  37. package/dist/cjs/vis/liquid/index.js +41 -16
  38. package/dist/cjs/vis/mindmap/index.js +12 -4
  39. package/dist/cjs/vis/network-graph/index.js +11 -2
  40. package/dist/cjs/vis/organization-chart/index.js +12 -3
  41. package/dist/cjs/vis/pie/index.d.ts +2 -2
  42. package/dist/cjs/vis/pie/index.js +26 -16
  43. package/dist/cjs/vis/radar/index.d.ts +2 -2
  44. package/dist/cjs/vis/radar/index.js +21 -29
  45. package/dist/cjs/vis/sankey/index.js +1 -4
  46. package/dist/cjs/vis/scatter/index.d.ts +4 -2
  47. package/dist/cjs/vis/scatter/index.js +43 -16
  48. package/dist/cjs/vis/treemap/index.js +1 -4
  49. package/dist/cjs/vis/venn/index.js +1 -4
  50. package/dist/cjs/vis/violin/index.js +1 -1
  51. package/dist/cjs/vis/waterfall/index.js +2 -2
  52. package/dist/cjs/vis/word-cloud/index.d.ts +3 -2
  53. package/dist/cjs/vis/word-cloud/index.js +125 -10
  54. package/dist/esm/gpt-vis/index.js +1 -1
  55. package/dist/esm/types/index.d.ts +2 -1
  56. package/dist/esm/util/animation.d.ts +2 -0
  57. package/dist/esm/util/animation.js +17 -0
  58. package/dist/esm/util/components.d.ts +15 -0
  59. package/dist/esm/util/components.js +67 -0
  60. package/dist/esm/util/crosshair-axis-labels.d.ts +9 -0
  61. package/dist/esm/util/crosshair-axis-labels.js +328 -0
  62. package/dist/esm/util/index.d.ts +6 -0
  63. package/dist/esm/util/index.js +6 -0
  64. package/dist/esm/util/interaction.d.ts +14 -0
  65. package/dist/esm/util/interaction.js +73 -0
  66. package/dist/esm/util/theme.d.ts +18 -24
  67. package/dist/esm/util/theme.js +302 -126
  68. package/dist/esm/util/tokens.d.ts +31 -0
  69. package/dist/esm/util/tokens.js +64 -0
  70. package/dist/esm/vis/area/index.d.ts +2 -2
  71. package/dist/esm/vis/area/index.js +91 -41
  72. package/dist/esm/vis/bar/index.d.ts +2 -2
  73. package/dist/esm/vis/bar/index.js +28 -29
  74. package/dist/esm/vis/boxplot/index.js +4 -5
  75. package/dist/esm/vis/column/index.d.ts +2 -2
  76. package/dist/esm/vis/column/index.js +36 -29
  77. package/dist/esm/vis/dual-axes/index.d.ts +2 -2
  78. package/dist/esm/vis/dual-axes/index.js +123 -43
  79. package/dist/esm/vis/fishbone-diagram/index.js +6 -5
  80. package/dist/esm/vis/flow-diagram/index.js +17 -10
  81. package/dist/esm/vis/funnel/index.d.ts +4 -2
  82. package/dist/esm/vis/funnel/index.js +156 -83
  83. package/dist/esm/vis/histogram/index.js +4 -5
  84. package/dist/esm/vis/indented-tree/index.js +9 -4
  85. package/dist/esm/vis/line/index.d.ts +2 -2
  86. package/dist/esm/vis/line/index.js +80 -37
  87. package/dist/esm/vis/liquid/index.d.ts +2 -2
  88. package/dist/esm/vis/liquid/index.js +41 -14
  89. package/dist/esm/vis/mindmap/index.js +6 -5
  90. package/dist/esm/vis/network-graph/index.js +5 -3
  91. package/dist/esm/vis/organization-chart/index.js +6 -4
  92. package/dist/esm/vis/pie/index.d.ts +2 -2
  93. package/dist/esm/vis/pie/index.js +36 -16
  94. package/dist/esm/vis/radar/index.d.ts +2 -2
  95. package/dist/esm/vis/radar/index.js +21 -34
  96. package/dist/esm/vis/sankey/index.js +4 -5
  97. package/dist/esm/vis/scatter/index.d.ts +4 -2
  98. package/dist/esm/vis/scatter/index.js +45 -19
  99. package/dist/esm/vis/treemap/index.js +4 -5
  100. package/dist/esm/vis/venn/index.js +4 -5
  101. package/dist/esm/vis/violin/index.js +5 -13
  102. package/dist/esm/vis/waterfall/index.js +11 -11
  103. package/dist/esm/vis/word-cloud/index.d.ts +3 -2
  104. package/dist/esm/vis/word-cloud/index.js +158 -10
  105. package/dist/umd/index.min.js +1 -1
  106. package/package.json +18 -19
@@ -1,5 +1,17 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1
13
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
14
+ import { CHART_FONT_FAMILY, getBackgroundColor, getChartVisualTokens, getThemeObject, normalizePalette, resolveChartLocale } from "../../util";
3
15
 
4
16
  /**
5
17
  * FunnelDataItem is the type for each data item in the funnel chart.
@@ -13,6 +25,32 @@ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util
13
25
  * FunnelInstance represents a funnel chart instance with render and destroy methods.
14
26
  */
15
27
 
28
+ var FUNNEL_LABELS = {
29
+ 'en-US': {
30
+ baseline: 'Baseline',
31
+ conversionRate: 'Conversion Rate',
32
+ currentValue: 'Current value',
33
+ dropOff: 'Drop-off from previous',
34
+ overallConversionRate: 'Overall conversion',
35
+ stageConversion: 'Stage conversion'
36
+ },
37
+ 'zh-CN': {
38
+ baseline: '基准',
39
+ conversionRate: '转化率',
40
+ currentValue: '当前值',
41
+ dropOff: '较上一步流失',
42
+ overallConversionRate: '整体转化率',
43
+ stageConversion: '阶段转化率'
44
+ }
45
+ };
46
+ var formatConversionRate = function formatConversionRate(start, end) {
47
+ if (!Number.isFinite(start) || !Number.isFinite(end) || start === 0) return '—';
48
+ return "".concat((end / start * 100).toFixed(1), "%");
49
+ };
50
+ var formatMetricLabel = function formatMetricLabel(label, value, locale) {
51
+ return locale === 'zh-CN' ? "".concat(label, "\uFF1A").concat(value) : "".concat(label, ": ").concat(value);
52
+ };
53
+
16
54
  /**
17
55
  * Funnel chart component using G2 5.0.
18
56
  *
@@ -42,6 +80,7 @@ export var Funnel = function Funnel(options) {
42
80
  var container = options.container,
43
81
  width = options.width,
44
82
  height = options.height,
83
+ locale = options.locale,
45
84
  _options$theme = options.theme,
46
85
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
47
86
  var chart = null;
@@ -50,14 +89,21 @@ export var Funnel = function Funnel(options) {
50
89
  * Render the funnel chart with the given configuration.
51
90
  */
52
91
  var render = function render(config) {
53
- var _data$, _data, _data$2, _data2, _data$3, _data3;
54
92
  var _config$data = config.data,
55
93
  data = _config$data === void 0 ? [] : _config$data,
56
94
  _config$theme = config.theme,
57
95
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
58
96
  title = config.title,
97
+ _config$locale = config.locale,
98
+ renderLocale = _config$locale === void 0 ? locale : _config$locale,
99
+ conversionRateLabel = config.conversionRateLabel,
59
100
  _config$style = config.style,
60
101
  style = _config$style === void 0 ? {} : _config$style;
102
+ var chartLocale = resolveChartLocale(renderLocale);
103
+ var labels = FUNNEL_LABELS[chartLocale];
104
+ var numberFormatter = new Intl.NumberFormat(chartLocale);
105
+ var stageConversionRateLabel = conversionRateLabel !== null && conversionRateLabel !== void 0 ? conversionRateLabel : labels.conversionRate;
106
+ var overallConversionRateLabel = conversionRateLabel !== null && conversionRateLabel !== void 0 ? conversionRateLabel : labels.overallConversionRate;
61
107
 
62
108
  // Clean up previous chart if exists
63
109
  if (chart) {
@@ -67,10 +113,37 @@ export var Funnel = function Funnel(options) {
67
113
  // Get colors from style.palette or theme defaults
68
114
  var colors = normalizePalette(style.palette, theme);
69
115
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
70
-
71
- // Helper function to calculate conversion rate
72
- var conversionRate = function conversionRate(start, end) {
73
- return "".concat((end / start * 100).toFixed(2), " %");
116
+ var tokens = getChartVisualTokens(theme);
117
+ var formatValue = function formatValue(value) {
118
+ return Number.isFinite(value) ? numberFormatter.format(value) : '—';
119
+ };
120
+ var metricsByCategory = new Map(data.map(function (item, index) {
121
+ var previous = data[index - 1];
122
+ return [item.category, {
123
+ conversion: previous ? formatConversionRate(previous.value, item.value) : labels.baseline,
124
+ dropOff: previous ? Math.max(0, previous.value - item.value) : null
125
+ }];
126
+ }));
127
+ var funnelTooltip = {
128
+ title: 'category',
129
+ items: [function (d) {
130
+ return {
131
+ name: labels.currentValue,
132
+ value: formatValue(d.value)
133
+ };
134
+ }, function (d) {
135
+ var _metricsByCategory$ge, _metricsByCategory$ge2;
136
+ return {
137
+ name: labels.stageConversion,
138
+ value: (_metricsByCategory$ge = (_metricsByCategory$ge2 = metricsByCategory.get(d.category)) === null || _metricsByCategory$ge2 === void 0 ? void 0 : _metricsByCategory$ge2.conversion) !== null && _metricsByCategory$ge !== void 0 ? _metricsByCategory$ge : '—'
139
+ };
140
+ }, function (d) {
141
+ var _metricsByCategory$ge3, _metricsByCategory$ge4, _metricsByCategory$ge5;
142
+ return {
143
+ name: labels.dropOff,
144
+ value: ((_metricsByCategory$ge3 = metricsByCategory.get(d.category)) === null || _metricsByCategory$ge3 === void 0 ? void 0 : _metricsByCategory$ge3.dropOff) === null ? '—' : formatValue((_metricsByCategory$ge4 = (_metricsByCategory$ge5 = metricsByCategory.get(d.category)) === null || _metricsByCategory$ge5 === void 0 ? void 0 : _metricsByCategory$ge5.dropOff) !== null && _metricsByCategory$ge4 !== void 0 ? _metricsByCategory$ge4 : Number.NaN)
145
+ };
146
+ }]
74
147
  };
75
148
 
76
149
  // Create chart
@@ -79,8 +152,8 @@ export var Funnel = function Funnel(options) {
79
152
  width: width,
80
153
  height: height,
81
154
  autoFit: true,
82
- paddingLeft: 40,
83
- paddingRight: 68
155
+ paddingLeft: 56,
156
+ paddingRight: 118
84
157
  });
85
158
 
86
159
  // Configure chart options
@@ -90,7 +163,7 @@ export var Funnel = function Funnel(options) {
90
163
  animate: false,
91
164
  type: 'view',
92
165
  data: data,
93
- title: title !== null && title !== void 0 ? title : '',
166
+ title: title || '',
94
167
  children: [{
95
168
  type: 'interval',
96
169
  data: data,
@@ -116,73 +189,78 @@ export var Funnel = function Funnel(options) {
116
189
  range: colors
117
190
  }
118
191
  },
119
- legend: {
120
- color: {
121
- position: 'top',
122
- layout: {
123
- justifyContent: 'center'
124
- }
125
- }
126
- },
127
- labels: [
128
- // Inside label showing category and value
129
- {
192
+ legend: false,
193
+ tooltip: funnelTooltip,
194
+ labels: [{
130
195
  text: function text(d) {
131
- return "".concat(d.category, "\n").concat(d.value);
196
+ return "".concat(d.category, "\n").concat(formatValue(d.value));
132
197
  },
133
198
  position: 'inside',
134
199
  transform: [{
135
200
  type: 'contrastReverse'
136
- }]
137
- },
138
- // Connecting line for conversion rate
139
- {
140
- text: function text(d, i) {
141
- return i !== 0 ? '———' : '';
142
- },
201
+ }, {
202
+ type: 'overflowStroke'
203
+ }],
143
204
  style: {
144
- 'font-size': '1px',
145
- color: '#666',
146
- 'letter-spacing': '0px'
147
- },
148
- position: 'top-right',
149
- fill: '#666',
150
- dx: 35,
151
- dy: -8
152
- },
153
- // Conversion rate label text
154
- {
155
- text: function text(d, i) {
156
- return i !== 0 ? '转化率' : '';
205
+ fontFamily: CHART_FONT_FAMILY,
206
+ fontSize: 12,
207
+ fontWeight: 500,
208
+ lineHeight: 17
209
+ }
210
+ }, {
211
+ text: function text(_d, index) {
212
+ return index === 0 ? '' : '———';
157
213
  },
158
214
  position: 'top-right',
159
- textAlign: 'left',
160
- textBaseline: 'middle',
161
- fill: '#666',
162
- dx: 40
163
- },
164
- // Conversion rate percentage
165
- {
166
- text: function text(d, i, dataArray) {
167
- return i !== 0 ? conversionRate(dataArray[i - 1].value, dataArray[i].value) : '';
215
+ fill: tokens.textSecondary,
216
+ fillOpacity: 0.72,
217
+ dx: 18,
218
+ dy: -6,
219
+ style: {
220
+ fontFamily: CHART_FONT_FAMILY,
221
+ fontSize: 8,
222
+ fontWeight: 400,
223
+ letterSpacing: -2
224
+ }
225
+ }, {
226
+ text: function text(_d, index, items) {
227
+ return index === 0 ? '' : formatMetricLabel(stageConversionRateLabel, formatConversionRate(items[index - 1].value, items[index].value), chartLocale);
168
228
  },
169
229
  position: 'top-right',
170
230
  textAlign: 'left',
171
231
  textBaseline: 'middle',
172
- dx: 80
232
+ fill: tokens.textPrimary,
233
+ dx: 44,
234
+ style: {
235
+ fontFamily: CHART_FONT_FAMILY,
236
+ fontSize: 11,
237
+ fontWeight: 500
238
+ }
173
239
  }],
174
- viewStyle: {
240
+ style: _objectSpread({
241
+ fillOpacity: 0.94,
242
+ stroke: tokens.separator,
243
+ lineWidth: 2
244
+ }, theme === 'academy' ? {} : {
245
+ radius: 4
246
+ }),
247
+ state: {
248
+ active: {
249
+ fillOpacity: 1,
250
+ stroke: tokens.separator,
251
+ lineWidth: 3
252
+ }
253
+ },
254
+ viewStyle: style.backgroundColor ? {
175
255
  viewFill: backgroundColor
176
- }
177
- },
178
- // Overall conversion rate connector
179
- {
256
+ } : undefined
257
+ }].concat(_toConsumableArray(data.length > 1 ? [{
180
258
  type: 'connector',
181
259
  data: [{
182
- startX: (_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.category,
183
- startY: (_data = data[data.length - 1]) === null || _data === void 0 ? void 0 : _data.category,
260
+ startX: data[0].category,
261
+ startY: data[data.length - 1].category,
184
262
  endX: 0,
185
- endY: (((_data$2 = data[0]) === null || _data$2 === void 0 ? void 0 : _data$2.value) - ((_data2 = data[data.length - 1]) === null || _data2 === void 0 ? void 0 : _data2.value)) / 2
263
+ endY: (data[0].value - data[data.length - 1].value) / 2
186
264
  }],
187
265
  encode: {
188
266
  x: 'startX',
@@ -190,41 +268,36 @@ export var Funnel = function Funnel(options) {
190
268
  y: 'endX',
191
269
  y1: 'endY'
192
270
  },
271
+ tooltip: false,
193
272
  style: {
194
- stroke: '#666',
273
+ stroke: tokens.axisLine,
274
+ strokeOpacity: theme === 'academy' ? 1 : 0.82,
275
+ lineWidth: theme === 'academy' ? 1 : 0.75,
195
276
  markerEnd: false,
196
- connectLength1: -12,
197
- offset2: -20,
198
- connectorStroke: '#0649f2',
199
- lineDash: [12, 2]
277
+ connectLength1: -12
200
278
  },
201
279
  labels: [{
202
- text: '转化率',
280
+ text: formatMetricLabel(overallConversionRateLabel, formatConversionRate(data[0].value, data[data.length - 1].value), chartLocale),
203
281
  position: 'left',
204
282
  textAlign: 'start',
205
283
  textBaseline: 'middle',
206
- fill: '#666',
207
- dx: 10
208
- }, {
209
- text: conversionRate((_data$3 = data[0]) === null || _data$3 === void 0 ? void 0 : _data$3.value, (_data3 = data[data.length - 1]) === null || _data3 === void 0 ? void 0 : _data3.value),
210
- position: 'left',
211
- textAlign: 'start',
212
- dx: 50,
213
- fill: '#000'
284
+ fill: tokens.textPrimary,
285
+ dx: 8,
286
+ style: {
287
+ fontFamily: CHART_FONT_FAMILY,
288
+ fontSize: 11,
289
+ fontWeight: 500
290
+ }
214
291
  }]
215
- }],
292
+ }] : [])),
216
293
  axis: false,
217
- tooltip: {
218
- items: [function (d) {
219
- return {
220
- name: d.category,
221
- value: d.value
222
- };
223
- }]
294
+ interaction: {
295
+ tooltip: true,
296
+ elementHighlight: true
224
297
  },
225
- viewStyle: {
298
+ viewStyle: style.backgroundColor ? {
226
299
  viewFill: backgroundColor
227
- },
300
+ } : undefined,
228
301
  theme: getThemeObject(theme)
229
302
  };
230
303
  chart.options(chartOptions);
@@ -1,5 +1,5 @@
1
1
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
2
+ import { getThemeObject, normalizePalette } from "../../util/theme";
3
3
 
4
4
  /**
5
5
  * HistogramConfig defines the configuration for rendering the histogram chart.
@@ -61,7 +61,6 @@ export var Histogram = function Histogram(options) {
61
61
 
62
62
  // Get colors from style.palette or theme defaults
63
63
  var colors = normalizePalette(style.palette, theme);
64
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
65
64
 
66
65
  // Create chart
67
66
  chart = new Chart({
@@ -122,9 +121,9 @@ export var Histogram = function Histogram(options) {
122
121
  name: '频数'
123
122
  }]
124
123
  },
125
- viewStyle: {
126
- viewFill: backgroundColor
127
- },
124
+ viewStyle: style.backgroundColor ? {
125
+ viewFill: style.backgroundColor
126
+ } : undefined,
128
127
  theme: getThemeObject(theme)
129
128
  };
130
129
  chart.options(chartOptions);
@@ -27,7 +27,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
27
27
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
28
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
29
29
  import { Badge, BaseBehavior, BaseNode, CommonEvent, ExtensionCategory, Graph, NodeEvent, Polyline, iconfont, register, subStyleProps, treeToGraphData } from '@antv/g6';
30
- import { getBackgroundColor, normalizePalette } from "../../util/theme";
30
+ import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
31
31
 
32
32
  // ---------------------------------------------------------------------------
33
33
  // Official G6 indented-tree implementation (adapted for GPT-Vis)
@@ -449,7 +449,8 @@ export var IndentedTree = function IndentedTree(options) {
449
449
  height: height,
450
450
  autoFit: 'view',
451
451
  autoResize: true,
452
- padding: 20,
452
+ theme: getTheme(theme),
453
+ padding: title ? [46, 20, 20, 20] : 20,
453
454
  data: graphData,
454
455
  node: {
455
456
  type: GPT_VIS_INDENTED_NODE,
@@ -461,8 +462,11 @@ export var IndentedTree = function IndentedTree(options) {
461
462
  labelBackground: function labelBackground(datum) {
462
463
  return datum.id === rootId;
463
464
  },
464
- labelBackgroundRadius: 0,
465
+ labelBackgroundRadius: theme === 'academy' ? 0 : 4,
465
466
  labelBackgroundFill: (_palette$ = palette[0]) !== null && _palette$ !== void 0 ? _palette$ : '#1783FF',
467
+ labelPadding: function labelPadding(datum) {
468
+ return datum.id === rootId ? [2, 8] : 0;
469
+ },
466
470
  labelFill: function labelFill(datum) {
467
471
  return datum.id === rootId ? '#fff' : isDark ? '#d0d0d0' : '#666';
468
472
  },
@@ -538,7 +542,8 @@ export var IndentedTree = function IndentedTree(options) {
538
542
  key: 'title',
539
543
  type: 'title',
540
544
  title: title,
541
- titleFill: isDark ? '#e0e6ed' : '#1a1a2e'
545
+ titleFill: isDark ? '#e0e6ed' : '#000',
546
+ titleFontFamily: 'sans-serif'
542
547
  }] : []
543
548
  });
544
549
  graph.render();
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * LineDataItem is the type for each data item in the line chart.
4
4
  */
@@ -16,7 +16,7 @@ export interface LineConfig {
16
16
  title?: string;
17
17
  axisXTitle?: string;
18
18
  axisYTitle?: string;
19
- theme?: 'default' | 'academy' | 'dark';
19
+ theme?: VisualizationTheme;
20
20
  style?: {
21
21
  backgroundColor?: string;
22
22
  palette?: string[];
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
8
+ import { CHART_STYLE_DEFAULTS, bindCrosshairAxisLabels, getBackgroundColor, getCartesianAxis, getCartesianLayout, getChartAnimation, getColorLegend, getSharedTooltipInteraction, getThemeObject, normalizePalette } from "../../util";
9
9
 
10
10
  /**
11
11
  * LineDataItem is the type for each data item in the line chart.
@@ -52,6 +52,8 @@ export var Line = function Line(options) {
52
52
  _options$theme = options.theme,
53
53
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
54
54
  var chart = null;
55
+ var hasRendered = false;
56
+ var cleanupCrosshairAxisLabels = null;
55
57
 
56
58
  /**
57
59
  * Render the line chart with the given configuration.
@@ -70,13 +72,35 @@ export var Line = function Line(options) {
70
72
 
71
73
  // Clean up previous chart if exists
72
74
  if (chart) {
75
+ var _cleanupCrosshairAxis;
76
+ (_cleanupCrosshairAxis = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis === void 0 || _cleanupCrosshairAxis();
77
+ cleanupCrosshairAxisLabels = null;
73
78
  chart.destroy();
74
79
  }
75
80
  var _style$lineWidth = style.lineWidth,
76
- lineWidth = _style$lineWidth === void 0 ? 2 : _style$lineWidth;
81
+ lineWidth = _style$lineWidth === void 0 ? CHART_STYLE_DEFAULTS.lineWidth : _style$lineWidth;
77
82
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
78
83
  var colors = normalizePalette(style.palette, theme);
79
84
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
85
+ var tooltip = {
86
+ items: [function (d) {
87
+ return {
88
+ name: hasGroupField ? d.group : axisYTitle || d.time,
89
+ value: d.value
90
+ };
91
+ }]
92
+ };
93
+ var lineAnimation = getChartAnimation(hasRendered, 'pathIn');
94
+ var pointAnimation = getChartAnimation(hasRendered, 'fadeIn');
95
+ var cartesianAxisOptions = {
96
+ axisXTitle: axisXTitle,
97
+ axisYTitle: axisYTitle,
98
+ xLabels: data.map(function (_ref) {
99
+ var time = _ref.time;
100
+ return time;
101
+ }),
102
+ chartWidth: width
103
+ };
80
104
 
81
105
  // Create chart
82
106
  chart = new Chart({
@@ -108,53 +132,68 @@ export var Line = function Line(options) {
108
132
  y: 'value'
109
133
  };
110
134
  }
135
+ var children = [{
136
+ type: 'line',
137
+ tooltip: tooltip,
138
+ style: _objectSpread({
139
+ lineWidth: lineWidth,
140
+ lineCap: 'round',
141
+ lineJoin: 'round'
142
+ }, !hasGroupField ? {
143
+ stroke: colors[0]
144
+ } : {}),
145
+ animate: lineAnimation
146
+ }];
147
+ var showPoints = data.length <= (hasGroupField ? 36 : 24);
148
+ if (showPoints) {
149
+ children.push({
150
+ type: 'point',
151
+ encode: _objectSpread({
152
+ x: 'time',
153
+ y: 'value',
154
+ shape: 'point',
155
+ size: CHART_STYLE_DEFAULTS.pointSize
156
+ }, hasGroupField ? {
157
+ color: 'group'
158
+ } : {}),
159
+ animate: pointAnimation,
160
+ tooltip: false,
161
+ style: _objectSpread({
162
+ lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
163
+ stroke: backgroundColor
164
+ }, !hasGroupField ? {
165
+ fill: colors[0]
166
+ } : {})
167
+ });
168
+ }
111
169
 
112
170
  // Configure chart options
113
171
  // Note: Using 'any' type due to G2's complex type system with transformations
114
172
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
115
- var chartOptions = {
116
- animate: false,
173
+ var chartOptions = _objectSpread(_objectSpread({
117
174
  type: 'view',
118
175
  data: data,
119
- title: title !== null && title !== void 0 ? title : '',
176
+ title: title || '',
120
177
  encode: encode,
121
- children: [{
122
- type: 'line',
123
- style: _objectSpread({
124
- lineWidth: lineWidth
125
- }, !hasGroupField && style.palette ? {
126
- stroke: colors[0]
127
- } : {})
128
- }],
129
- scale: scaleConfig,
130
- axis: {
131
- x: {
132
- title: axisXTitle || false
133
- },
134
- y: {
135
- title: axisYTitle || false
136
- }
137
- },
138
- legend: hasGroupField ? {
139
- color: {
140
- position: 'top'
141
- }
142
- } : false,
143
- tooltip: {
144
- items: [function (d) {
145
- return {
146
- name: axisYTitle || d.time,
147
- value: d.value
148
- };
149
- }]
178
+ children: children,
179
+ scale: scaleConfig
180
+ }, getCartesianLayout(cartesianAxisOptions)), {}, {
181
+ axis: getCartesianAxis(cartesianAxisOptions),
182
+ legend: getColorLegend(hasGroupField),
183
+ interaction: {
184
+ tooltip: getSharedTooltipInteraction({
185
+ crosshairs: true
186
+ })
150
187
  },
151
- viewStyle: {
188
+ viewStyle: style.backgroundColor ? {
152
189
  viewFill: backgroundColor
153
- },
190
+ } : undefined,
154
191
  theme: getThemeObject(theme)
155
- };
192
+ });
156
193
  chart.options(chartOptions);
194
+ cleanupCrosshairAxisLabels = bindCrosshairAxisLabels(chart, theme);
157
195
  chart.render();
196
+ hasRendered = true;
158
197
  };
159
198
 
160
199
  /**
@@ -162,9 +201,13 @@ export var Line = function Line(options) {
162
201
  */
163
202
  var destroy = function destroy() {
164
203
  if (chart) {
204
+ var _cleanupCrosshairAxis2;
205
+ (_cleanupCrosshairAxis2 = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis2 === void 0 || _cleanupCrosshairAxis2();
206
+ cleanupCrosshairAxisLabels = null;
165
207
  chart.destroy();
166
208
  chart = null;
167
209
  }
210
+ hasRendered = false;
168
211
  };
169
212
  return {
170
213
  render: render,
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * LiquidConfig defines the configuration for rendering the liquid chart.
4
4
  */
@@ -6,7 +6,7 @@ export interface LiquidConfig {
6
6
  type?: 'liquid';
7
7
  percent: number;
8
8
  shape?: 'rect' | 'circle' | 'pin' | 'triangle';
9
- theme?: 'default' | 'academy' | 'dark';
9
+ theme?: VisualizationTheme;
10
10
  title?: string;
11
11
  style?: {
12
12
  backgroundColor?: string;