@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
@@ -0,0 +1,304 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/crosshair-axis-labels.ts
20
+ var crosshair_axis_labels_exports = {};
21
+ __export(crosshair_axis_labels_exports, {
22
+ bindCrosshairAxisLabels: () => bindCrosshairAxisLabels
23
+ });
24
+ module.exports = __toCommonJS(crosshair_axis_labels_exports);
25
+ var import_component = require("@antv/component");
26
+ var import_g2 = require("@antv/g2");
27
+ var import_tokens = require("./tokens");
28
+ var formatCrosshairAxisValue = (value, formatter, precision) => {
29
+ if (value === void 0 || value === null || value === "")
30
+ return "";
31
+ try {
32
+ const formatted = formatter == null ? void 0 : formatter(value);
33
+ if (formatted !== void 0 && formatted !== null)
34
+ return String(formatted);
35
+ } catch {
36
+ }
37
+ if (value instanceof Date)
38
+ return value.toLocaleString();
39
+ if (typeof value === "number" && Number.isFinite(value) && precision !== void 0) {
40
+ return value.toFixed(precision);
41
+ }
42
+ return String(value);
43
+ };
44
+ var getNumberPrecision = (value) => {
45
+ var _a;
46
+ if (!Number.isFinite(value) || value === 0)
47
+ return 0;
48
+ const [coefficient, exponentText = "0"] = Math.abs(value).toExponential().split("e");
49
+ const coefficientPrecision = ((_a = coefficient.split(".")[1]) == null ? void 0 : _a.length) || 0;
50
+ return Math.max(0, coefficientPrecision - Number(exponentText));
51
+ };
52
+ var getCrosshairScalePrecision = (scale) => {
53
+ var _a;
54
+ const ticks = (_a = scale == null ? void 0 : scale.getTicks) == null ? void 0 : _a.call(scale);
55
+ if (!Array.isArray(ticks) || ticks.length < 2)
56
+ return void 0;
57
+ let interval = Number.POSITIVE_INFINITY;
58
+ for (let index = 1; index < ticks.length; index += 1) {
59
+ const current = Number(ticks[index]);
60
+ const previous = Number(ticks[index - 1]);
61
+ const difference = Math.abs(current - previous);
62
+ if (Number.isFinite(difference) && difference > 0)
63
+ interval = Math.min(interval, difference);
64
+ }
65
+ if (!Number.isFinite(interval))
66
+ return void 0;
67
+ return Math.min(getNumberPrecision(interval) + 2, 20);
68
+ };
69
+ var getCrosshairTagStyle = (theme, tokens) => ({
70
+ lineLineWidth: 0,
71
+ lineStrokeOpacity: 0,
72
+ linePointerEvents: "none",
73
+ tagPadding: [4, 7],
74
+ tagRadius: 6,
75
+ tagBackgroundFill: tokens.textPrimary,
76
+ tagBackgroundStroke: "transparent",
77
+ tagBackgroundLineWidth: 0,
78
+ tagBackgroundShadowColor: theme === "dark" ? "rgba(0, 0, 0, 0.38)" : "rgba(15, 23, 42, 0.18)",
79
+ tagBackgroundShadowBlur: 8,
80
+ tagBackgroundShadowOffsetY: 2,
81
+ tagLabelFill: tokens.background,
82
+ tagLabelFillOpacity: 1,
83
+ tagLabelFontFamily: import_tokens.CHART_FONT_FAMILY,
84
+ tagLabelFontSize: 11,
85
+ tagLabelFontWeight: 500,
86
+ tagLabelLineWidth: 0,
87
+ tagPointerEvents: "none"
88
+ });
89
+ var clamp = (value, min, max) => Math.min(Math.max(value, Math.min(min, max)), Math.max(min, max));
90
+ var invertCrosshairValue = (scale, value) => {
91
+ var _a, _b, _c;
92
+ if (!scale || typeof scale.invert !== "function" || value === void 0)
93
+ return void 0;
94
+ if (typeof scale.getBandWidth === "function") {
95
+ const domain = (_b = (_a = scale.getOptions) == null ? void 0 : _a.call(scale)) == null ? void 0 : _b.domain;
96
+ if (!Array.isArray(domain) || domain.length === 0 || !Number.isFinite(Number(value))) {
97
+ return void 0;
98
+ }
99
+ let nearestValue = domain[0];
100
+ let nearestDistance = Number.POSITIVE_INFINITY;
101
+ for (const domainValue of domain) {
102
+ const start = Number((_c = scale.map) == null ? void 0 : _c.call(scale, domainValue));
103
+ const bandWidth = Number(scale.getBandWidth(domainValue)) || 0;
104
+ const distance = Math.abs(start + bandWidth / 2 - Number(value));
105
+ if (Number.isFinite(distance) && distance < nearestDistance) {
106
+ nearestValue = domainValue;
107
+ nearestDistance = distance;
108
+ }
109
+ }
110
+ return nearestValue;
111
+ }
112
+ try {
113
+ return scale.invert(value);
114
+ } catch {
115
+ return void 0;
116
+ }
117
+ };
118
+ var getTooltipPlot = (context) => {
119
+ var _a;
120
+ const root = (_a = context.canvas) == null ? void 0 : _a.getRoot();
121
+ if (!root)
122
+ return void 0;
123
+ return (0, import_g2.selectPlotArea)(root);
124
+ };
125
+ var getCartesianView = (context) => {
126
+ var _a;
127
+ return (_a = context.views) == null ? void 0 : _a.find(
128
+ ({ coordinate, scale }) => Boolean((scale == null ? void 0 : scale.x) && (scale == null ? void 0 : scale.y)) && typeof (coordinate == null ? void 0 : coordinate.invert) === "function"
129
+ );
130
+ };
131
+ var getRuleLine = (rule) => {
132
+ var _a, _b, _c, _d;
133
+ const x1 = Number((_a = rule == null ? void 0 : rule.style) == null ? void 0 : _a.x1);
134
+ const x2 = Number((_b = rule == null ? void 0 : rule.style) == null ? void 0 : _b.x2);
135
+ const y1 = Number((_c = rule == null ? void 0 : rule.style) == null ? void 0 : _c.y1);
136
+ const y2 = Number((_d = rule == null ? void 0 : rule.style) == null ? void 0 : _d.y2);
137
+ if (![x1, x2, y1, y2].every(Number.isFinite))
138
+ return void 0;
139
+ return { x1, x2, y1, y2 };
140
+ };
141
+ var getPlotOffset = (plot) => {
142
+ var _a;
143
+ const [x = 0, y = 0] = ((_a = plot.getLocalPosition) == null ? void 0 : _a.call(plot)) || [];
144
+ return [Number.isFinite(Number(x)) ? Number(x) : 0, Number.isFinite(Number(y)) ? Number(y) : 0];
145
+ };
146
+ var invertCoordinate = (view, point) => {
147
+ try {
148
+ const inverted = view.coordinate.invert(point);
149
+ if (!Array.isArray(inverted) || inverted.length < 2)
150
+ return void 0;
151
+ const x = Number(inverted[0]);
152
+ const y = Number(inverted[1]);
153
+ return Number.isFinite(x) && Number.isFinite(y) ? [x, y] : void 0;
154
+ } catch {
155
+ return void 0;
156
+ }
157
+ };
158
+ var bindCrosshairAxisLabels = (chart, theme) => {
159
+ if (!chart || typeof chart.on !== "function")
160
+ return () => void 0;
161
+ const tagStyle = getCrosshairTagStyle(theme, (0, import_tokens.getChartVisualTokens)(theme));
162
+ let boundPlot = null;
163
+ let xCrosshair = null;
164
+ let yCrosshair = null;
165
+ let latestPointerY = null;
166
+ let latestXValue;
167
+ const destroyCrosshairs = () => {
168
+ xCrosshair == null ? void 0 : xCrosshair.destroy();
169
+ yCrosshair == null ? void 0 : yCrosshair.destroy();
170
+ xCrosshair = null;
171
+ yCrosshair = null;
172
+ boundPlot = null;
173
+ };
174
+ const hideCrosshairs = () => {
175
+ for (const crosshair of [xCrosshair, yCrosshair]) {
176
+ if (crosshair)
177
+ crosshair.style.visibility = "hidden";
178
+ }
179
+ };
180
+ const resetCrosshairs = () => {
181
+ latestPointerY = null;
182
+ latestXValue = void 0;
183
+ hideCrosshairs();
184
+ };
185
+ const ensureCrosshairs = (plot, xLine, yLine, xText, yText) => {
186
+ if (boundPlot !== plot)
187
+ destroyCrosshairs();
188
+ if (xCrosshair && yCrosshair)
189
+ return;
190
+ const layer = plot.parentNode || plot;
191
+ const [plotX, plotY] = getPlotOffset(plot);
192
+ const xStart = [xLine.x1 + plotX, xLine.y1 + plotY];
193
+ const xEnd = [xLine.x2 + plotX, xLine.y2 + plotY];
194
+ const yStart = [yLine.x1 + plotX, yLine.y1 + plotY];
195
+ const yEnd = [yLine.x2 + plotX, yLine.y2 + plotY];
196
+ if (!xCrosshair) {
197
+ xCrosshair = new import_component.LineCrosshair({
198
+ style: { ...tagStyle, startPos: xStart, endPos: xEnd, tagText: xText, tagPosition: "end" }
199
+ });
200
+ xCrosshair.style.zIndex = 7;
201
+ xCrosshair.style.pointerEvents = "none";
202
+ layer.appendChild(xCrosshair);
203
+ }
204
+ if (!yCrosshair) {
205
+ yCrosshair = new import_component.LineCrosshair({
206
+ style: {
207
+ ...tagStyle,
208
+ startPos: yStart,
209
+ endPos: yEnd,
210
+ tagText: yText,
211
+ tagPosition: "start"
212
+ }
213
+ });
214
+ yCrosshair.style.zIndex = 7;
215
+ yCrosshair.style.pointerEvents = "none";
216
+ layer.appendChild(yCrosshair);
217
+ }
218
+ boundPlot = plot;
219
+ };
220
+ const updateCrosshairs = (event) => {
221
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
222
+ const context = chart.getContext();
223
+ const plot = getTooltipPlot(context);
224
+ const view = getCartesianView(context);
225
+ if (!plot || !view) {
226
+ hideCrosshairs();
227
+ return;
228
+ }
229
+ const verticalRule = getRuleLine(plot.ruleY);
230
+ const horizontalRule = getRuleLine(plot.ruleX);
231
+ if (!verticalRule || !horizontalRule) {
232
+ hideCrosshairs();
233
+ return;
234
+ }
235
+ const [plotX, plotY] = getPlotOffset(plot);
236
+ const eventY = Number(event.offsetY ?? event.canvasY);
237
+ const globalY = Number.isFinite(eventY) ? eventY : latestPointerY;
238
+ const pointerY = Number.isFinite(globalY) ? Number(globalY) - plotY : horizontalRule.y1;
239
+ const x = clamp(verticalRule.x1, horizontalRule.x1, horizontalRule.x2);
240
+ const y = clamp(pointerY, verticalRule.y1, verticalRule.y2);
241
+ const invertedPosition = invertCoordinate(view, [x, y]);
242
+ const xValue = latestXValue ?? invertCrosshairValue(view.scale.x, invertedPosition == null ? void 0 : invertedPosition[0]);
243
+ const yValue = invertCrosshairValue(view.scale.y, invertedPosition == null ? void 0 : invertedPosition[1]) ?? ((_c = (_b = (_a = event.data) == null ? void 0 : _a.items) == null ? void 0 : _b[0]) == null ? void 0 : _c.value);
244
+ const xText = formatCrosshairAxisValue(xValue, (_e = (_d = view.scale.x).getFormatter) == null ? void 0 : _e.call(_d));
245
+ const yText = formatCrosshairAxisValue(
246
+ yValue,
247
+ (_g = (_f = view.scale.y).getFormatter) == null ? void 0 : _g.call(_f),
248
+ getCrosshairScalePrecision(view.scale.y)
249
+ );
250
+ if (!xText || !yText) {
251
+ hideCrosshairs();
252
+ return;
253
+ }
254
+ if ((_h = plot.ruleY) == null ? void 0 : _h.style) {
255
+ plot.ruleY.style.x1 = x;
256
+ plot.ruleY.style.x2 = x;
257
+ }
258
+ if ((_i = plot.ruleX) == null ? void 0 : _i.style) {
259
+ plot.ruleX.style.y1 = y;
260
+ plot.ruleX.style.y2 = y;
261
+ }
262
+ const displayVerticalRule = { ...verticalRule, x1: x, x2: x };
263
+ const displayHorizontalRule = { ...horizontalRule, y1: y, y2: y };
264
+ ensureCrosshairs(plot, displayVerticalRule, displayHorizontalRule, xText, yText);
265
+ if (!xCrosshair || !yCrosshair)
266
+ return;
267
+ xCrosshair.setText(xText);
268
+ xCrosshair.setPointer([x + plotX, verticalRule.y2 + plotY]);
269
+ xCrosshair.style.visibility = "visible";
270
+ yCrosshair.setText(yText);
271
+ yCrosshair.setPointer([horizontalRule.x1 + plotX, y + plotY]);
272
+ yCrosshair.style.visibility = "visible";
273
+ };
274
+ const onPointerMove = (event) => {
275
+ const y = Number(event.offsetY ?? event.canvasY);
276
+ if (Number.isFinite(y))
277
+ latestPointerY = y;
278
+ updateCrosshairs(event);
279
+ };
280
+ const onTooltipShow = (event) => {
281
+ var _a, _b;
282
+ if (!event.nativeEvent)
283
+ return;
284
+ if (((_b = (_a = event.data) == null ? void 0 : _a.data) == null ? void 0 : _b.x) !== void 0)
285
+ latestXValue = event.data.data.x;
286
+ updateCrosshairs(event);
287
+ };
288
+ chart.on("tooltip:show", onTooltipShow);
289
+ chart.on("tooltip:hide", resetCrosshairs);
290
+ chart.on("plot:pointermove", onPointerMove);
291
+ chart.on("plot:pointerleave", resetCrosshairs);
292
+ return () => {
293
+ var _a, _b, _c, _d;
294
+ (_a = chart.off) == null ? void 0 : _a.call(chart, "tooltip:show", onTooltipShow);
295
+ (_b = chart.off) == null ? void 0 : _b.call(chart, "tooltip:hide", resetCrosshairs);
296
+ (_c = chart.off) == null ? void 0 : _c.call(chart, "plot:pointermove", onPointerMove);
297
+ (_d = chart.off) == null ? void 0 : _d.call(chart, "plot:pointerleave", resetCrosshairs);
298
+ destroyCrosshairs();
299
+ };
300
+ };
301
+ // Annotate the CommonJS export names for ESM import in node:
302
+ 0 && (module.exports = {
303
+ bindCrosshairAxisLabels
304
+ });
@@ -0,0 +1,6 @@
1
+ export * from './animation';
2
+ export * from './components';
3
+ export * from './crosshair-axis-labels';
4
+ export * from './interaction';
5
+ export * from './theme';
6
+ export * from './tokens';
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/util/index.ts
17
+ var util_exports = {};
18
+ module.exports = __toCommonJS(util_exports);
19
+ __reExport(util_exports, require("./animation"), module.exports);
20
+ __reExport(util_exports, require("./components"), module.exports);
21
+ __reExport(util_exports, require("./crosshair-axis-labels"), module.exports);
22
+ __reExport(util_exports, require("./interaction"), module.exports);
23
+ __reExport(util_exports, require("./theme"), module.exports);
24
+ __reExport(util_exports, require("./tokens"), module.exports);
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ ...require("./animation"),
28
+ ...require("./components"),
29
+ ...require("./crosshair-axis-labels"),
30
+ ...require("./interaction"),
31
+ ...require("./theme"),
32
+ ...require("./tokens")
33
+ });
@@ -0,0 +1,14 @@
1
+ import type { VisualizationTheme } from '../types';
2
+ export type SharedTooltipInteractionOptions = {
3
+ crosshairs?: boolean;
4
+ };
5
+ export type PointHighlightStateOptions = {
6
+ activeLineWidth?: number;
7
+ inactiveOpacity?: number;
8
+ };
9
+ export declare const getSharedTooltipInteraction: ({ crosshairs, }?: SharedTooltipInteractionOptions) => Record<string, boolean>;
10
+ export declare const getCategoryBackgroundHighlightState: (theme: VisualizationTheme) => Record<string, any>;
11
+ export declare const getCategoryHighlightInteraction: () => Record<string, any>;
12
+ export declare const getPointHighlightState: ({ activeLineWidth, inactiveOpacity, }?: PointHighlightStateOptions) => Record<string, any>;
13
+ export declare const getSeriesHighlightByColorInteraction: () => Record<string, boolean>;
14
+ export declare const getLineHighlightState: (lineWidth: number) => Record<string, any>;
@@ -0,0 +1,89 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/interaction.ts
20
+ var interaction_exports = {};
21
+ __export(interaction_exports, {
22
+ getCategoryBackgroundHighlightState: () => getCategoryBackgroundHighlightState,
23
+ getCategoryHighlightInteraction: () => getCategoryHighlightInteraction,
24
+ getLineHighlightState: () => getLineHighlightState,
25
+ getPointHighlightState: () => getPointHighlightState,
26
+ getSeriesHighlightByColorInteraction: () => getSeriesHighlightByColorInteraction,
27
+ getSharedTooltipInteraction: () => getSharedTooltipInteraction
28
+ });
29
+ module.exports = __toCommonJS(interaction_exports);
30
+ var import_tokens = require("./tokens");
31
+ var getSharedTooltipInteraction = ({
32
+ crosshairs = false
33
+ } = {}) => ({
34
+ shared: true,
35
+ series: true,
36
+ crosshairs
37
+ });
38
+ var getCategoryBackgroundHighlightState = (theme) => {
39
+ const tokens = (0, import_tokens.getChartVisualTokens)(theme);
40
+ return {
41
+ active: {
42
+ backgroundFill: tokens.grid,
43
+ backgroundFillOpacity: theme === "dark" ? 0.56 : 0.58,
44
+ backgroundLineWidth: 0,
45
+ backgroundPadding: 0.08,
46
+ backgroundRadius: 4
47
+ }
48
+ };
49
+ };
50
+ var getCategoryHighlightInteraction = () => ({
51
+ background: true,
52
+ region: true
53
+ });
54
+ var getPointHighlightState = ({
55
+ activeLineWidth = import_tokens.CHART_STYLE_DEFAULTS.pointActiveLineWidth,
56
+ inactiveOpacity
57
+ } = {}) => ({
58
+ active: {
59
+ lineWidth: activeLineWidth,
60
+ stroke: (_datum, _index, _data, element) => {
61
+ var _a, _b;
62
+ return ((_a = element == null ? void 0 : element.style) == null ? void 0 : _a.fill) || ((_b = element == null ? void 0 : element.style) == null ? void 0 : _b.stroke);
63
+ },
64
+ fillOpacity: 1,
65
+ zIndex: 10
66
+ },
67
+ ...inactiveOpacity === void 0 ? {} : {
68
+ inactive: {
69
+ fillOpacity: inactiveOpacity,
70
+ strokeOpacity: inactiveOpacity
71
+ }
72
+ }
73
+ });
74
+ var getSeriesHighlightByColorInteraction = () => ({
75
+ elementHighlightByColor: true
76
+ });
77
+ var getLineHighlightState = (lineWidth) => ({
78
+ active: { lineWidth: lineWidth + 1, strokeOpacity: 1 },
79
+ inactive: { strokeOpacity: import_tokens.CHART_STYLE_DEFAULTS.inactiveOpacity }
80
+ });
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ getCategoryBackgroundHighlightState,
84
+ getCategoryHighlightInteraction,
85
+ getLineHighlightState,
86
+ getPointHighlightState,
87
+ getSeriesHighlightByColorInteraction,
88
+ getSharedTooltipInteraction
89
+ });
@@ -1,26 +1,20 @@
1
+ import type { Theme } from '@antv/g2';
2
+ import type { VisualizationTheme } from '../types';
1
3
  export declare const DEFAULT_COLOR_PALETTE: string[];
2
4
  export declare const ACADEMY_COLOR_PALETTE: string[];
3
- export declare const THEME_MAP: Record<string, any>;
4
- /**
5
- * Get normalized theme name for G2.
6
- * Converts 'default' to 'light' for G2 compatibility.
7
- */
8
- export declare const getTheme: (theme: string) => string;
9
- /**
10
- * Get theme object from THEME_MAP.
11
- * This should be used for visualization components to properly support dark theme with multiple marks.
12
- */
13
- export declare const getThemeObject: (theme: string) => any;
14
- /**
15
- * Get theme color palette based on theme name.
16
- */
17
- export declare const getThemeColors: (theme: string) => string[];
18
- /**
19
- * Get background color based on theme.
20
- */
21
- export declare const getBackgroundColor: (theme: string) => string;
22
- /**
23
- * Normalize palette to always return an array.
24
- * Handles the case where a single color is parsed as a string instead of an array.
25
- */
26
- export declare const normalizePalette: (palette: string | string[] | undefined, theme: string) => string[];
5
+ type G2ThemeType = 'light' | 'dark' | 'academy';
6
+ type ChartTheme = Theme & {
7
+ enter?: {
8
+ duration?: number;
9
+ easing?: string;
10
+ };
11
+ elementHighlightByColor?: Record<string, unknown>;
12
+ elementHoverScale?: Record<string, unknown>;
13
+ };
14
+ export declare const THEME_MAP: Record<VisualizationTheme, ChartTheme>;
15
+ export declare const getTheme: (theme: VisualizationTheme) => G2ThemeType;
16
+ export declare const getThemeObject: (theme: VisualizationTheme) => ChartTheme;
17
+ export declare const getThemeColors: (theme: VisualizationTheme) => string[];
18
+ export declare const getBackgroundColor: (theme: VisualizationTheme) => string;
19
+ export declare const normalizePalette: (palette: string | string[] | undefined, theme: VisualizationTheme) => string[];
20
+ export {};