@antv/gpt-vis 1.0.2 → 1.3.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 (168) hide show
  1. package/README.md +29 -6
  2. package/README.zh-CN.md +32 -9
  3. package/dist/cjs/index.d.ts +1 -1
  4. package/dist/cjs/theme/g2.d.ts +9 -0
  5. package/dist/cjs/theme/g2.js +605 -0
  6. package/dist/cjs/theme/g6.d.ts +28 -0
  7. package/dist/cjs/theme/g6.js +124 -0
  8. package/dist/cjs/theme/merge.d.ts +2 -0
  9. package/dist/cjs/theme/merge.js +49 -0
  10. package/dist/cjs/theme/resolve.d.ts +7 -0
  11. package/dist/cjs/theme/resolve.js +58 -0
  12. package/dist/cjs/theme/shared.d.ts +7 -0
  13. package/dist/cjs/theme/shared.js +61 -0
  14. package/dist/cjs/theme/summary.d.ts +11 -0
  15. package/dist/cjs/theme/summary.js +61 -0
  16. package/dist/cjs/theme/table.d.ts +13 -0
  17. package/dist/cjs/theme/table.js +121 -0
  18. package/dist/cjs/types/index.d.ts +8 -5
  19. package/dist/cjs/types/theme.d.ts +107 -0
  20. package/dist/cjs/types/theme.js +17 -0
  21. package/dist/cjs/util/animation.js +6 -1
  22. package/dist/cjs/util/components.d.ts +20 -0
  23. package/dist/cjs/util/components.js +40 -0
  24. package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
  25. package/dist/cjs/util/crosshair-axis-labels.js +17 -0
  26. package/dist/cjs/util/index.d.ts +0 -2
  27. package/dist/cjs/util/index.js +1 -5
  28. package/dist/cjs/util/interaction.d.ts +4 -3
  29. package/dist/cjs/util/interaction.js +14 -1
  30. package/dist/cjs/util/tokens.d.ts +4 -3
  31. package/dist/cjs/util/tokens.js +9 -6
  32. package/dist/cjs/vis/area/index.d.ts +3 -6
  33. package/dist/cjs/vis/area/index.js +43 -30
  34. package/dist/cjs/vis/bar/index.d.ts +5 -5
  35. package/dist/cjs/vis/bar/index.js +34 -20
  36. package/dist/cjs/vis/boxplot/index.d.ts +4 -5
  37. package/dist/cjs/vis/boxplot/index.js +36 -23
  38. package/dist/cjs/vis/column/index.d.ts +5 -5
  39. package/dist/cjs/vis/column/index.js +38 -26
  40. package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
  41. package/dist/cjs/vis/dual-axes/index.js +70 -52
  42. package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
  43. package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
  44. package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
  45. package/dist/cjs/vis/flow-diagram/index.js +21 -22
  46. package/dist/cjs/vis/funnel/index.d.ts +3 -5
  47. package/dist/cjs/vis/funnel/index.js +63 -42
  48. package/dist/cjs/vis/histogram/index.d.ts +4 -6
  49. package/dist/cjs/vis/histogram/index.js +17 -19
  50. package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
  51. package/dist/cjs/vis/indented-tree/index.js +58 -34
  52. package/dist/cjs/vis/line/index.d.ts +3 -6
  53. package/dist/cjs/vis/line/index.js +43 -22
  54. package/dist/cjs/vis/liquid/index.d.ts +4 -6
  55. package/dist/cjs/vis/liquid/index.js +22 -17
  56. package/dist/cjs/vis/mindmap/index.d.ts +4 -6
  57. package/dist/cjs/vis/mindmap/index.js +43 -25
  58. package/dist/cjs/vis/network-graph/index.d.ts +4 -6
  59. package/dist/cjs/vis/network-graph/index.js +26 -20
  60. package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
  61. package/dist/cjs/vis/organization-chart/index.js +39 -33
  62. package/dist/cjs/vis/pie/index.d.ts +3 -5
  63. package/dist/cjs/vis/pie/index.js +45 -26
  64. package/dist/cjs/vis/radar/index.d.ts +3 -6
  65. package/dist/cjs/vis/radar/index.js +32 -24
  66. package/dist/cjs/vis/sankey/index.d.ts +4 -6
  67. package/dist/cjs/vis/sankey/index.js +17 -7
  68. package/dist/cjs/vis/scatter/index.d.ts +3 -5
  69. package/dist/cjs/vis/scatter/index.js +32 -19
  70. package/dist/cjs/vis/summary/index.js +5 -6
  71. package/dist/cjs/vis/table/index.d.ts +4 -2
  72. package/dist/cjs/vis/table/index.js +44 -4
  73. package/dist/cjs/vis/treemap/index.d.ts +4 -6
  74. package/dist/cjs/vis/treemap/index.js +11 -7
  75. package/dist/cjs/vis/venn/index.d.ts +4 -6
  76. package/dist/cjs/vis/venn/index.js +18 -16
  77. package/dist/cjs/vis/violin/index.d.ts +4 -5
  78. package/dist/cjs/vis/violin/index.js +35 -27
  79. package/dist/cjs/vis/waterfall/index.d.ts +4 -4
  80. package/dist/cjs/vis/waterfall/index.js +48 -39
  81. package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
  82. package/dist/cjs/vis/word-cloud/index.js +18 -12
  83. package/dist/esm/index.d.ts +1 -1
  84. package/dist/esm/theme/g2.d.ts +9 -0
  85. package/dist/esm/theme/g2.js +504 -0
  86. package/dist/esm/theme/g6.d.ts +28 -0
  87. package/dist/esm/theme/g6.js +84 -0
  88. package/dist/esm/theme/merge.d.ts +2 -0
  89. package/dist/esm/theme/merge.js +36 -0
  90. package/dist/esm/theme/resolve.d.ts +7 -0
  91. package/dist/esm/theme/resolve.js +27 -0
  92. package/dist/esm/theme/shared.d.ts +7 -0
  93. package/dist/esm/theme/shared.js +21 -0
  94. package/dist/esm/theme/summary.d.ts +11 -0
  95. package/dist/esm/theme/summary.js +45 -0
  96. package/dist/esm/theme/table.d.ts +13 -0
  97. package/dist/esm/theme/table.js +112 -0
  98. package/dist/esm/types/index.d.ts +8 -5
  99. package/dist/esm/types/theme.d.ts +107 -0
  100. package/dist/esm/types/theme.js +1 -0
  101. package/dist/esm/util/animation.js +12 -2
  102. package/dist/esm/util/components.d.ts +20 -0
  103. package/dist/esm/util/components.js +57 -1
  104. package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
  105. package/dist/esm/util/crosshair-axis-labels.js +18 -0
  106. package/dist/esm/util/index.d.ts +0 -2
  107. package/dist/esm/util/index.js +1 -3
  108. package/dist/esm/util/interaction.d.ts +4 -3
  109. package/dist/esm/util/interaction.js +18 -1
  110. package/dist/esm/util/tokens.d.ts +4 -3
  111. package/dist/esm/util/tokens.js +9 -6
  112. package/dist/esm/vis/area/index.d.ts +3 -6
  113. package/dist/esm/vis/area/index.js +53 -45
  114. package/dist/esm/vis/bar/index.d.ts +5 -5
  115. package/dist/esm/vis/bar/index.js +38 -27
  116. package/dist/esm/vis/boxplot/index.d.ts +4 -5
  117. package/dist/esm/vis/boxplot/index.js +47 -29
  118. package/dist/esm/vis/column/index.d.ts +5 -5
  119. package/dist/esm/vis/column/index.js +46 -36
  120. package/dist/esm/vis/dual-axes/index.d.ts +3 -4
  121. package/dist/esm/vis/dual-axes/index.js +68 -58
  122. package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
  123. package/dist/esm/vis/fishbone-diagram/index.js +52 -27
  124. package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
  125. package/dist/esm/vis/flow-diagram/index.js +28 -23
  126. package/dist/esm/vis/funnel/index.d.ts +3 -5
  127. package/dist/esm/vis/funnel/index.js +63 -54
  128. package/dist/esm/vis/histogram/index.d.ts +4 -6
  129. package/dist/esm/vis/histogram/index.js +28 -21
  130. package/dist/esm/vis/indented-tree/index.d.ts +4 -6
  131. package/dist/esm/vis/indented-tree/index.js +59 -52
  132. package/dist/esm/vis/line/index.d.ts +3 -6
  133. package/dist/esm/vis/line/index.js +44 -32
  134. package/dist/esm/vis/liquid/index.d.ts +4 -6
  135. package/dist/esm/vis/liquid/index.js +28 -21
  136. package/dist/esm/vis/mindmap/index.d.ts +4 -6
  137. package/dist/esm/vis/mindmap/index.js +32 -28
  138. package/dist/esm/vis/network-graph/index.d.ts +4 -6
  139. package/dist/esm/vis/network-graph/index.js +37 -22
  140. package/dist/esm/vis/organization-chart/index.d.ts +4 -6
  141. package/dist/esm/vis/organization-chart/index.js +47 -36
  142. package/dist/esm/vis/pie/index.d.ts +3 -5
  143. package/dist/esm/vis/pie/index.js +42 -26
  144. package/dist/esm/vis/radar/index.d.ts +3 -6
  145. package/dist/esm/vis/radar/index.js +28 -20
  146. package/dist/esm/vis/sankey/index.d.ts +4 -6
  147. package/dist/esm/vis/sankey/index.js +20 -10
  148. package/dist/esm/vis/scatter/index.d.ts +3 -5
  149. package/dist/esm/vis/scatter/index.js +32 -21
  150. package/dist/esm/vis/summary/index.js +5 -7
  151. package/dist/esm/vis/table/index.d.ts +4 -2
  152. package/dist/esm/vis/table/index.js +41 -4
  153. package/dist/esm/vis/treemap/index.d.ts +4 -6
  154. package/dist/esm/vis/treemap/index.js +16 -11
  155. package/dist/esm/vis/venn/index.d.ts +4 -6
  156. package/dist/esm/vis/venn/index.js +24 -16
  157. package/dist/esm/vis/violin/index.d.ts +4 -5
  158. package/dist/esm/vis/violin/index.js +45 -37
  159. package/dist/esm/vis/waterfall/index.d.ts +4 -4
  160. package/dist/esm/vis/waterfall/index.js +46 -36
  161. package/dist/esm/vis/word-cloud/index.d.ts +3 -5
  162. package/dist/esm/vis/word-cloud/index.js +24 -17
  163. package/dist/umd/index.min.js +1 -1
  164. package/package.json +1 -1
  165. package/dist/cjs/util/theme.d.ts +0 -20
  166. package/dist/cjs/util/theme.js +0 -372
  167. package/dist/esm/util/theme.d.ts +0 -20
  168. package/dist/esm/util/theme.js +0 -326
@@ -0,0 +1,36 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ 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."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ 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); }
9
+ 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; }
10
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+ /** Theme objects merge recursively; arrays replace and undefined keeps the previous value. */
13
+ export function mergeTheme() {
14
+ var result = {};
15
+ for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
16
+ sources[_key] = arguments[_key];
17
+ }
18
+ for (var _i = 0, _sources = sources; _i < _sources.length; _i++) {
19
+ var source = _sources[_i];
20
+ for (var _i2 = 0, _Object$entries = Object.entries(source !== null && source !== void 0 ? source : {}); _i2 < _Object$entries.length; _i2++) {
21
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
22
+ key = _Object$entries$_i[0],
23
+ value = _Object$entries$_i[1];
24
+ if (value === undefined || key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
25
+ if (Array.isArray(value)) {
26
+ result[key] = _toConsumableArray(value);
27
+ } else if (value && _typeof(value) === 'object') {
28
+ var previous = result[key];
29
+ result[key] = mergeTheme(previous && _typeof(previous) === 'object' && !Array.isArray(previous) ? previous : undefined, value);
30
+ } else {
31
+ result[key] = value;
32
+ }
33
+ }
34
+ }
35
+ return result;
36
+ }
@@ -0,0 +1,7 @@
1
+ import type { ChartType, ThemeStyle, VisualizationTheme } from '../types';
2
+ /** Keep the override layers in order; each renderer expands only its own tokens. */
3
+ export declare function resolveTheme(type: ChartType, theme?: VisualizationTheme, localStyle?: ThemeStyle): {
4
+ baseTheme: "light" | "dark" | "academy";
5
+ tokens: import("../types").ThemeTokens;
6
+ styles: (ThemeStyle | undefined)[];
7
+ };
@@ -0,0 +1,27 @@
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
+ /** Keep the override layers in order; each renderer expands only its own tokens. */
3
+ export function resolveTheme(type, theme, localStyle) {
4
+ var _spec$tokens, _spec$baseTheme, _ref, _tokens$category, _spec$charts;
5
+ var spec = _typeof(theme) === 'object' ? theme : undefined;
6
+ var tokens = (_spec$tokens = spec === null || spec === void 0 ? void 0 : spec.tokens) !== null && _spec$tokens !== void 0 ? _spec$tokens : {};
7
+ var name = (_spec$baseTheme = spec === null || spec === void 0 ? void 0 : spec.baseTheme) !== null && _spec$baseTheme !== void 0 ? _spec$baseTheme : typeof theme === 'string' ? theme : 'default';
8
+ var baseTheme = name === 'dark' || name === 'academy' ? name : 'light';
9
+ return {
10
+ baseTheme: baseTheme,
11
+ tokens: tokens,
12
+ styles: [{
13
+ backgroundColor: tokens.colorBackground,
14
+ palette: (_ref = (_tokens$category = tokens.category10) !== null && _tokens$category !== void 0 ? _tokens$category : tokens.category20) !== null && _ref !== void 0 ? _ref : tokens.colorDefault ? [tokens.colorDefault] : undefined,
15
+ title: {
16
+ titleFill: tokens.colorText,
17
+ subtitleFill: tokens.colorTextSecondary,
18
+ titleFontFamily: tokens.fontFamily,
19
+ subtitleFontFamily: tokens.fontFamily,
20
+ titleFontSize: tokens.fontSize === undefined ? undefined : tokens.fontSize + 4,
21
+ subtitleFontSize: tokens.fontSize,
22
+ titleFontWeight: tokens.fontWeight,
23
+ spacing: tokens.spacingMedium
24
+ }
25
+ }, spec === null || spec === void 0 ? void 0 : spec.style, spec === null || spec === void 0 || (_spec$charts = spec.charts) === null || _spec$charts === void 0 || (_spec$charts = _spec$charts[type]) === null || _spec$charts === void 0 ? void 0 : _spec$charts.style, localStyle]
26
+ };
27
+ }
@@ -0,0 +1,7 @@
1
+ export declare const DEFAULT_COLOR_PALETTE: string[];
2
+ export declare const ACADEMY_COLOR_PALETTE: string[];
3
+ export declare const normalizePalette: (palette: string | string[] | undefined, theme: string) => string[];
4
+ /** Renderer field whitelists consume appearance fields only. */
5
+ export declare const pickStyle: (style: Record<string, any> | undefined, keys?: readonly string[]) => {
6
+ [k: string]: any;
7
+ };
@@ -0,0 +1,21 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ 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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ export var DEFAULT_COLOR_PALETTE = ['#5B6CFF', '#2DAF9E', '#F2B84B', '#EF6A6A', '#55A6D9', '#3AA76D', '#F58A57', '#8B6FD6', '#D96C9B'];
8
+ export var ACADEMY_COLOR_PALETTE = ['#4e79a7', '#f28e2c', '#e15759', '#76b7b2', '#59a14f', '#edc949', '#af7aa1', '#ff9da7', '#9c755f', '#bab0ab'];
9
+ export var normalizePalette = function normalizePalette(palette, theme) {
10
+ return palette && (!Array.isArray(palette) || palette.length) ? Array.isArray(palette) ? _toConsumableArray(palette) : [palette] : _toConsumableArray(theme === 'academy' ? ACADEMY_COLOR_PALETTE : DEFAULT_COLOR_PALETTE);
11
+ };
12
+
13
+ /** Renderer field whitelists consume appearance fields only. */
14
+ export var pickStyle = function pickStyle(style) {
15
+ var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Object.keys(style !== null && style !== void 0 ? style : {});
16
+ return Object.fromEntries(keys.filter(function (key) {
17
+ return (style === null || style === void 0 ? void 0 : style[key]) !== undefined;
18
+ }).map(function (key) {
19
+ return [key, style[key]];
20
+ }));
21
+ };
@@ -0,0 +1,11 @@
1
+ import type { ThemeStyle, VisualizationTheme } from '../types';
2
+ export declare function getThemeObject(type: 'summary', theme?: VisualizationTheme, localStyle?: ThemeStyle): {
3
+ theme: "light" | "dark";
4
+ backgrounds: {
5
+ light: string;
6
+ dark: string;
7
+ };
8
+ summary: {
9
+ [k: string]: any;
10
+ };
11
+ };
@@ -0,0 +1,45 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ 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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ import { getChartVisualTokens } from "../util/tokens";
8
+ import { mergeTheme } from "./merge";
9
+ import { resolveTheme } from "./resolve";
10
+ import { pickStyle } from "./shared";
11
+ export function getThemeObject(type, theme, localStyle) {
12
+ var _style$backgroundColo, _style$backgroundColo2;
13
+ var _resolveTheme = resolveTheme(type, theme, localStyle),
14
+ baseTheme = _resolveTheme.baseTheme,
15
+ t = _resolveTheme.tokens,
16
+ styles = _resolveTheme.styles;
17
+ var summary = {
18
+ fontFamily: t.fontFamily,
19
+ fontSize: t.fontSize,
20
+ lineHeight: t.lineHeight,
21
+ borderColor: t.colorStroke,
22
+ colorBase: t.colorText,
23
+ colorEntityBase: t.colorText,
24
+ colorHeadingBase: t.colorText,
25
+ colorPositive: t.colorPositive,
26
+ colorNegative: t.colorNegative,
27
+ colorConclusion: t.colorText,
28
+ colorDimensionValue: t.colorText,
29
+ colorMetricName: t.colorText,
30
+ colorMetricValue: t.colorDefault,
31
+ colorOtherValue: t.colorNeutral,
32
+ colorLink: t.colorDefault
33
+ };
34
+ var style = mergeTheme.apply(void 0, [{
35
+ summary: summary
36
+ }].concat(_toConsumableArray(styles)));
37
+ return {
38
+ theme: baseTheme === 'dark' ? 'dark' : 'light',
39
+ backgrounds: {
40
+ light: (_style$backgroundColo = style.backgroundColor) !== null && _style$backgroundColo !== void 0 ? _style$backgroundColo : '',
41
+ dark: (_style$backgroundColo2 = style.backgroundColor) !== null && _style$backgroundColo2 !== void 0 ? _style$backgroundColo2 : getChartVisualTokens('dark').background
42
+ },
43
+ summary: pickStyle(style.summary, Object.keys(summary))
44
+ };
45
+ }
@@ -0,0 +1,13 @@
1
+ import type { ThemeStyle, VisualizationTheme } from '../types';
2
+ export declare function getThemeObject(type: 'table', theme?: VisualizationTheme, localStyle?: ThemeStyle): {
3
+ theme: "light" | "dark";
4
+ backgroundColor: string | undefined;
5
+ title: Record<string, string>;
6
+ subtitle: Record<string, string>;
7
+ header: Record<string, string>;
8
+ cell: Record<string, string>;
9
+ border: {
10
+ table: Record<string, string>;
11
+ cell: Record<string, string>;
12
+ };
13
+ };
@@ -0,0 +1,112 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ 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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ import { mergeTheme } from "./merge";
8
+ import { resolveTheme } from "./resolve";
9
+ export function getThemeObject(type, theme, localStyle) {
10
+ var _style$title, _title$titleFillOpaci, _title$titleFontWeigh, _title$subtitleFillOp, _title$subtitleFontWe, _style$table, _style$table2, _style$table3;
11
+ var _resolveTheme = resolveTheme(type, theme, localStyle),
12
+ baseTheme = _resolveTheme.baseTheme,
13
+ t = _resolveTheme.tokens,
14
+ styles = _resolveTheme.styles;
15
+ var cell = {
16
+ fontFamily: t.fontFamily,
17
+ fontSize: t.fontSize,
18
+ fontWeight: t.fontWeight,
19
+ fill: t.colorText,
20
+ backgroundColor: t.colorSurface,
21
+ padding: t.spacingMedium
22
+ };
23
+ var style = mergeTheme.apply(void 0, [{
24
+ table: {
25
+ header: cell,
26
+ cell: cell,
27
+ border: {
28
+ color: t.colorStroke,
29
+ width: t.lineWidth,
30
+ radius: t.radius
31
+ }
32
+ }
33
+ }].concat(_toConsumableArray(styles)));
34
+ var title = (_style$title = style.title) !== null && _style$title !== void 0 ? _style$title : {};
35
+ return {
36
+ theme: baseTheme === 'dark' ? 'dark' : 'light',
37
+ backgroundColor: style.backgroundColor,
38
+ title: compactStyle({
39
+ color: title.titleFill,
40
+ opacity: (_title$titleFillOpaci = title.titleFillOpacity) === null || _title$titleFillOpaci === void 0 ? void 0 : _title$titleFillOpaci.toString(),
41
+ fontFamily: title.titleFontFamily,
42
+ fontSize: toPixels(title.titleFontSize),
43
+ fontWeight: (_title$titleFontWeigh = title.titleFontWeight) === null || _title$titleFontWeigh === void 0 ? void 0 : _title$titleFontWeigh.toString(),
44
+ textAlign: title.align
45
+ }),
46
+ subtitle: compactStyle({
47
+ color: title.subtitleFill,
48
+ opacity: (_title$subtitleFillOp = title.subtitleFillOpacity) === null || _title$subtitleFillOp === void 0 ? void 0 : _title$subtitleFillOp.toString(),
49
+ fontFamily: title.subtitleFontFamily,
50
+ fontSize: toPixels(title.subtitleFontSize),
51
+ fontWeight: (_title$subtitleFontWe = title.subtitleFontWeight) === null || _title$subtitleFontWe === void 0 ? void 0 : _title$subtitleFontWe.toString(),
52
+ marginTop: toPixels(title.spacing),
53
+ textAlign: title.align
54
+ }),
55
+ header: adaptTableCellStyle((_style$table = style.table) === null || _style$table === void 0 ? void 0 : _style$table.header),
56
+ cell: adaptTableCellStyle((_style$table2 = style.table) === null || _style$table2 === void 0 ? void 0 : _style$table2.cell),
57
+ border: adaptTableBorderStyle((_style$table3 = style.table) === null || _style$table3 === void 0 ? void 0 : _style$table3.border)
58
+ };
59
+ }
60
+ var toPixels = function toPixels(value) {
61
+ return value === undefined ? undefined : "".concat(value, "px");
62
+ };
63
+ var toPadding = function toPadding(value) {
64
+ if (value === undefined) return undefined;
65
+ if (typeof value === 'number') return toPixels(value);
66
+ return value.map(toPixels).join(' ');
67
+ };
68
+ var compactStyle = function compactStyle(style) {
69
+ return Object.fromEntries(Object.entries(style).filter(function (entry) {
70
+ return !!entry[1];
71
+ }));
72
+ };
73
+
74
+ /** Translate table header/cell text and box styles to safe DOM declarations. */
75
+ var adaptTableCellStyle = function adaptTableCellStyle(style) {
76
+ var _style$fontWeight;
77
+ return compactStyle({
78
+ color: style === null || style === void 0 ? void 0 : style.fill,
79
+ backgroundColor: style === null || style === void 0 ? void 0 : style.backgroundColor,
80
+ padding: toPadding(style === null || style === void 0 ? void 0 : style.padding),
81
+ fontFamily: style === null || style === void 0 ? void 0 : style.fontFamily,
82
+ fontSize: toPixels(style === null || style === void 0 ? void 0 : style.fontSize),
83
+ fontWeight: style === null || style === void 0 || (_style$fontWeight = style.fontWeight) === null || _style$fontWeight === void 0 ? void 0 : _style$fontWeight.toString(),
84
+ fontStyle: style === null || style === void 0 ? void 0 : style.fontStyle,
85
+ lineHeight: toPixels(style === null || style === void 0 ? void 0 : style.lineHeight)
86
+ });
87
+ };
88
+
89
+ /** Translate one table border contract to outer and row-separator DOM styles. */
90
+ var adaptTableBorderStyle = function adaptTableBorderStyle(style) {
91
+ var _style$width, _style$style, _style$color;
92
+ if (!style) return {
93
+ table: {},
94
+ cell: {}
95
+ };
96
+ var width = toPixels((_style$width = style.width) !== null && _style$width !== void 0 ? _style$width : 1);
97
+ var lineStyle = (_style$style = style.style) !== null && _style$style !== void 0 ? _style$style : 'solid';
98
+ var color = (_style$color = style.color) !== null && _style$color !== void 0 ? _style$color : 'currentColor';
99
+ return {
100
+ table: compactStyle({
101
+ borderColor: color,
102
+ borderWidth: width,
103
+ borderStyle: lineStyle,
104
+ borderRadius: toPixels(style.radius)
105
+ }),
106
+ cell: compactStyle({
107
+ borderBottomColor: color,
108
+ borderBottomWidth: width,
109
+ borderBottomStyle: lineStyle
110
+ })
111
+ };
112
+ };
@@ -1,14 +1,17 @@
1
- /**
2
- * Common visualization options for all chart components.
3
- * Defines the container and dimensions for rendering visualizations.
4
- */
5
- export type VisualizationTheme = 'default' | 'light' | 'dark' | 'academy';
1
+ import type { ThemeSpec } from './theme';
2
+ export type { ChartType, ThemeSpec, ThemeStyle, ThemeTokens } from './theme';
3
+ /** Built-in visualization themes supported by GPT-Vis. */
4
+ export type VisualizationTheme = 'default' | 'light' | 'dark' | 'academy' | ThemeSpec;
5
+ /** Common construction options shared by every visualization. */
6
6
  export interface VisualizationOptions {
7
7
  container: string | HTMLElement;
8
8
  width?: number;
9
9
  height?: number;
10
+ /** A built-in theme name or reusable ThemeSpec. Defaults to `default`. */
10
11
  theme?: VisualizationTheme;
12
+ /** Whether to render the outer wrapper. Defaults to `false`. */
11
13
  wrapper?: boolean;
14
+ /** Locale used by user-facing labels and number formatting. */
12
15
  locale?: string;
13
16
  }
14
17
  /**
@@ -0,0 +1,107 @@
1
+ export type ChartType = 'area' | 'bar' | 'boxplot' | 'column' | 'dual-axes' | 'fishbone-diagram' | 'flow-diagram' | 'funnel' | 'histogram' | 'indented-tree' | 'line' | 'liquid' | 'mindmap' | 'network-graph' | 'organization-chart' | 'pie' | 'radar' | 'sankey' | 'scatter' | 'summary' | 'table' | 'treemap' | 'venn' | 'violin' | 'waterfall' | 'word-cloud';
2
+ /** Reusable visual theme. Local chart config takes precedence over this spec. */
3
+ export interface ThemeSpec {
4
+ /** Stable identifier; does not register a theme name. */
5
+ id: string;
6
+ /** Human-readable theme name. */
7
+ label: string;
8
+ description?: string;
9
+ baseTheme?: string;
10
+ tokens?: ThemeTokens;
11
+ /** Shared visual overrides, applied after token expansion. */
12
+ style?: ThemeStyle;
13
+ /** Additional visual overrides for individual chart types. */
14
+ charts?: Partial<Record<ChartType, {
15
+ style?: ThemeStyle;
16
+ }>>;
17
+ }
18
+ /**
19
+ * Visual style namespaces. Each adapter consumes the supported appearance fields;
20
+ * data, layout and behavior remain part of the chart configuration.
21
+ */
22
+ export interface ThemeStyle {
23
+ backgroundColor?: string;
24
+ palette?: string[];
25
+ title?: Record<string, unknown>;
26
+ axis?: Record<string, unknown>;
27
+ legend?: Record<string, unknown>;
28
+ label?: Record<string, unknown>;
29
+ mark?: {
30
+ line?: Record<string, unknown>;
31
+ area?: Record<string, unknown>;
32
+ point?: Record<string, unknown>;
33
+ interval?: Record<string, unknown>;
34
+ box?: Record<string, unknown>;
35
+ connector?: Record<string, unknown>;
36
+ path?: Record<string, unknown>;
37
+ density?: Record<string, unknown>;
38
+ link?: Record<string, unknown>;
39
+ liquid?: Record<string, unknown>;
40
+ treemap?: Record<string, unknown>;
41
+ sankey?: Record<string, unknown>;
42
+ wordCloud?: Record<string, unknown>;
43
+ };
44
+ node?: Record<string, unknown>;
45
+ edge?: Record<string, unknown>;
46
+ table?: {
47
+ header?: Record<string, unknown>;
48
+ cell?: Record<string, unknown>;
49
+ border?: Record<string, unknown>;
50
+ };
51
+ summary?: Record<string, unknown>;
52
+ /** Fishbone drawing texture. */
53
+ texture?: 'rough' | 'default';
54
+ /** @deprecated Line, Area and Radar: use `mark.line.lineWidth`. */
55
+ lineWidth?: number;
56
+ }
57
+ /**
58
+ * High-frequency seed tokens for authoring a GPT-Vis theme.
59
+ *
60
+ * Names reuse G2, G6 and T8 terminology where it is stable and semantic.
61
+ * Renderer adapters expand these seeds into concrete component and mark styles.
62
+ */
63
+ export interface ThemeTokens {
64
+ /** Primary series or emphasis color. Matches G2's seed token name. */
65
+ colorDefault?: string;
66
+ /** Canvas background. Matches G2's seed token name. */
67
+ colorBackground?: string;
68
+ /** Table/Liquid surfaces and existing tooltip backgrounds. */
69
+ colorSurface?: string;
70
+ /** Primary text color across G2 components, G6 labels, Table and T8. */
71
+ colorText?: string;
72
+ /** Secondary text used by subtitles, axes and supporting copy. */
73
+ colorTextSecondary?: string;
74
+ /** Text displayed on a contrasting filled surface. */
75
+ colorTextInverse?: string;
76
+ /**
77
+ * Base structural stroke color. The resolver derives axes, grids, borders,
78
+ * nodes and edges from this value. The name matches G2's seed token.
79
+ */
80
+ colorStroke?: string;
81
+ /** Positive semantic color. Matches T8's seed token name. */
82
+ colorPositive?: string;
83
+ /** Negative semantic color. Matches T8's seed token name. */
84
+ colorNegative?: string;
85
+ /** Neutral semantic color for unchanged or unknown status. */
86
+ colorNeutral?: string;
87
+ /** Primary categorical palette. Matches G2's theme field and seed token name. */
88
+ category10?: string[];
89
+ /** Extended categorical palette. Matches G2's theme field and seed token name. */
90
+ category20?: string[];
91
+ /** Base font family. Matches T8 and renderer text style names. */
92
+ fontFamily?: string;
93
+ /** Base font size in pixels. Matches T8 and renderer text style names. */
94
+ fontSize?: number;
95
+ /** Base font weight. Matches renderer text style names. */
96
+ fontWeight?: number | 'normal' | 'bold';
97
+ /** Line height in pixels for G2 labels/legend text, Summary and existing tooltips. */
98
+ lineHeight?: number;
99
+ /** Compact gap in pixels: axis labels, legend spacing and tooltip vertical padding. */
100
+ spacingSmall?: number;
101
+ /** Roomier gap in pixels: title/subtitle, axes, legends, table cells and tooltip horizontal padding. */
102
+ spacingMedium?: number;
103
+ /** Default mark and structural line width. */
104
+ lineWidth?: number;
105
+ /** Default corner radius for intervals, nodes and surfaces. */
106
+ radius?: number;
107
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,12 +1,22 @@
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
+ import { CHART_STYLE_DEFAULTS } from "./tokens";
1
8
  var prefersReducedMotion = function prefersReducedMotion() {
2
9
  return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
3
10
  };
4
11
  export var getChartAnimation = function getChartAnimation(hasRendered, enterType) {
5
12
  if (hasRendered || prefersReducedMotion()) return false;
6
13
  return {
7
- enter: enterType ? {
14
+ enter: _objectSpread(_objectSpread({}, enterType ? {
8
15
  type: enterType
9
- } : {},
16
+ } : {}), {}, {
17
+ duration: CHART_STYLE_DEFAULTS.animationDuration,
18
+ easing: 'ease-out'
19
+ }),
10
20
  update: {
11
21
  type: null
12
22
  },
@@ -1,3 +1,5 @@
1
+ import type { Theme } from '@antv/g2';
2
+ import type { PluginOptions } from '@antv/g6';
1
3
  export type ChartLocale = 'en-US' | 'zh-CN';
2
4
  export type CartesianXAxisOptions = {
3
5
  xLabels?: unknown[];
@@ -13,3 +15,21 @@ export declare const getCartesianAxis: ({ axisXTitle, axisYTitle, xLabels, chart
13
15
  export declare const getColorLegend: (visible: boolean) => false | {
14
16
  color: Record<string, never>;
15
17
  };
18
+ /** Label content and placement belong to the chart; paint comes from the native theme. */
19
+ export declare function getDataLabels(theme: Theme, { visible, defaultVisible, contrast, style, transform, ...content }: {
20
+ visible?: boolean;
21
+ defaultVisible?: boolean;
22
+ contrast?: 'inside' | 'outside';
23
+ style?: Record<string, unknown>;
24
+ transform?: Record<string, unknown>[];
25
+ text: unknown;
26
+ position?: string;
27
+ dx?: number;
28
+ dy?: number;
29
+ formatter?: string;
30
+ }): Record<string, unknown>[] | undefined;
31
+ /** Keep the title plugin's canvas and graph padding in step with its typography. */
32
+ export declare function getGraphTitle(title?: string, subtitle?: string, style?: Record<string, any>): {
33
+ plugins: PluginOptions;
34
+ padding: number | [number, number, number, number];
35
+ };
@@ -1,4 +1,13 @@
1
+ var _excluded = ["visible", "defaultVisible", "contrast", "style", "transform"];
1
2
  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); }
3
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ 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."); }
5
+ 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); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
+ 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; }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2
11
  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
12
  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
13
  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; }
@@ -64,4 +73,51 @@ export var getColorLegend = function getColorLegend(visible) {
64
73
  return visible ? {
65
74
  color: {}
66
75
  } : false;
67
- };
76
+ };
77
+
78
+ /** Label content and placement belong to the chart; paint comes from the native theme. */
79
+ export function getDataLabels(theme, _ref3) {
80
+ var _theme$label, _theme$innerLabel;
81
+ var visible = _ref3.visible,
82
+ _ref3$defaultVisible = _ref3.defaultVisible,
83
+ defaultVisible = _ref3$defaultVisible === void 0 ? false : _ref3$defaultVisible,
84
+ contrast = _ref3.contrast,
85
+ style = _ref3.style,
86
+ transform = _ref3.transform,
87
+ content = _objectWithoutProperties(_ref3, _excluded);
88
+ if (visible === false) return [];
89
+ if (visible !== true && !defaultVisible) return undefined;
90
+ var paint = contrast === 'inside' ? theme.innerLabel : theme.label;
91
+ var textColor = (_theme$label = theme.label) === null || _theme$label === void 0 ? void 0 : _theme$label.fill;
92
+ var inverseColor = (_theme$innerLabel = theme.innerLabel) === null || _theme$innerLabel === void 0 ? void 0 : _theme$innerLabel.fill;
93
+ var contrastTransform = contrast === 'inside' && textColor !== inverseColor ? [{
94
+ type: 'contrastReverse',
95
+ palette: [textColor, inverseColor]
96
+ }] : [];
97
+ var transforms = [].concat(contrastTransform, _toConsumableArray(transform !== null && transform !== void 0 ? transform : []));
98
+ return [_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, content), transforms.length ? {
99
+ transform: transforms
100
+ } : {}), style), paint)];
101
+ }
102
+
103
+ /** Keep the title plugin's canvas and graph padding in step with its typography. */
104
+ export function getGraphTitle(title, subtitle) {
105
+ var _style$titleFontSize, _style$spacing, _style$subtitleFontSi;
106
+ var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
107
+ if (!title) return {
108
+ plugins: [],
109
+ padding: 20
110
+ };
111
+ var contentHeight = Math.ceil(((_style$titleFontSize = style.titleFontSize) !== null && _style$titleFontSize !== void 0 ? _style$titleFontSize : 16) * 1.2) + (subtitle ? ((_style$spacing = style.spacing) !== null && _style$spacing !== void 0 ? _style$spacing : 8) + Math.ceil(((_style$subtitleFontSi = style.subtitleFontSize) !== null && _style$subtitleFontSi !== void 0 ? _style$subtitleFontSi : 12) * 1.2) : 0);
112
+ return {
113
+ plugins: [_objectSpread(_objectSpread({
114
+ key: 'title',
115
+ type: 'title',
116
+ title: title,
117
+ subtitle: subtitle
118
+ }, style), {}, {
119
+ size: Math.max(44, contentHeight)
120
+ })],
121
+ padding: [Math.max(46, Math.ceil(contentHeight + 24)), 20, 20, 20]
122
+ };
123
+ }
@@ -1,5 +1,4 @@
1
1
  import { type Chart } from '@antv/g2';
2
- import type { VisualizationTheme } from '../types';
3
2
  export type CrosshairAxisLabelsOptions = {
4
3
  showXLabel?: boolean;
5
4
  useStandaloneYLabel?: boolean;
@@ -12,4 +11,4 @@ export type CrosshairAxisLabelsOptions = {
12
11
  * G2 does not currently expose axis tags for tooltip crosshairs, so this adapter
13
12
  * reads the rule geometry created by G2 5.4 and renders labels with LineCrosshair.
14
13
  */
15
- export declare const bindCrosshairAxisLabels: (chart: Chart, theme: VisualizationTheme, { showXLabel, useStandaloneYLabel, yAxisPosition, yField, }?: CrosshairAxisLabelsOptions) => (() => void);
14
+ export declare const bindCrosshairAxisLabels: (chart: Chart, theme: string, { showXLabel, useStandaloneYLabel, yAxisPosition, yField, }?: CrosshairAxisLabelsOptions) => (() => void);
@@ -15,6 +15,7 @@ import { LineCrosshair, Tag } from '@antv/component';
15
15
  import { selectPlotArea } from '@antv/g2';
16
16
  import { CHART_FONT_FAMILY, getChartVisualTokens } from "./tokens";
17
17
  var MAX_CROSSHAIR_DECIMAL_PLACES = 6;
18
+ var CROSSHAIR_LABEL_MARGIN = 4;
18
19
  var formatCrosshairAxisValue = function formatCrosshairAxisValue(value, formatter, precision) {
19
20
  if (value === undefined || value === null || value === '') return '';
20
21
  var displayValue = value;
@@ -110,6 +111,20 @@ var getStandaloneTagStyle = function getStandaloneTagStyle(theme, tokens) {
110
111
  var clamp = function clamp(value, min, max) {
111
112
  return Math.min(Math.max(value, Math.min(min, max)), Math.max(min, max));
112
113
  };
114
+ var keepTagInCanvas = function keepTagInCanvas(tag, canvas) {
115
+ if (!tag || !canvas) return;
116
+ var _canvas$getConfig = canvas.getConfig(),
117
+ width = _canvas$getConfig.width,
118
+ height = _canvas$getConfig.height;
119
+ if (width === undefined || height === undefined) return;
120
+ var _tag$getBounds = tag.getBounds(),
121
+ min = _tag$getBounds.min,
122
+ max = _tag$getBounds.max;
123
+ var margin = CROSSHAIR_LABEL_MARGIN;
124
+ var dx = Math.max(margin - min[0], Math.min(0, width - margin - max[0]));
125
+ var dy = Math.max(margin - min[1], Math.min(0, height - margin - max[1]));
126
+ if (dx || dy) tag.translate(dx, dy);
127
+ };
113
128
  var invertCrosshairValue = function invertCrosshairValue(scale, value) {
114
129
  if (!scale || typeof scale.invert !== 'function' || value === undefined) return undefined;
115
130
  if (typeof scale.getBandWidth === 'function') {
@@ -389,11 +404,13 @@ export var bindCrosshairAxisLabels = function bindCrosshairAxisLabels(chart, the
389
404
  xCrosshair.setText(xText);
390
405
  xCrosshair.setPointer([x + plotX, verticalRule.y2 + plotY]);
391
406
  xCrosshair.style.visibility = 'visible';
407
+ keepTagInCanvas(xCrosshair.querySelector('.crosshair-tag'), context.canvas);
392
408
  }
393
409
  if (yCrosshair) {
394
410
  yCrosshair.setText(yText);
395
411
  yCrosshair.setPointer([(yAxisPosition === 'right' ? horizontalRule.x2 : horizontalRule.x1) + plotX, y + plotY]);
396
412
  yCrosshair.style.visibility = 'visible';
413
+ keepTagInCanvas(yCrosshair.querySelector('.crosshair-tag'), context.canvas);
397
414
  }
398
415
  if (standaloneYTag) {
399
416
  var yAxisX = getYAxisLinePosition(view, yField, yAxisPosition, yAxisPosition === 'right' ? horizontalRule.x2 : horizontalRule.x1, plotX);
@@ -402,6 +419,7 @@ export var bindCrosshairAxisLabels = function bindCrosshairAxisLabels(chart, the
402
419
  });
403
420
  standaloneYTag.setLocalPosition([yAxisX + plotX, y + plotY]);
404
421
  standaloneYTag.style.visibility = 'visible';
422
+ keepTagInCanvas(standaloneYTag, context.canvas);
405
423
  }
406
424
  };
407
425
  var onPointerMove = function onPointerMove(event) {
@@ -2,5 +2,3 @@ export * from './animation';
2
2
  export * from './components';
3
3
  export * from './crosshair-axis-labels';
4
4
  export * from './interaction';
5
- export * from './theme';
6
- export * from './tokens';
@@ -1,6 +1,4 @@
1
1
  export * from "./animation";
2
2
  export * from "./components";
3
3
  export * from "./crosshair-axis-labels";
4
- export * from "./interaction";
5
- export * from "./theme";
6
- export * from "./tokens";
4
+ export * from "./interaction";