@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
@@ -22,12 +22,17 @@ __export(animation_exports, {
22
22
  getChartAnimation: () => getChartAnimation
23
23
  });
24
24
  module.exports = __toCommonJS(animation_exports);
25
+ var import_tokens = require("./tokens");
25
26
  var prefersReducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
26
27
  var getChartAnimation = (hasRendered, enterType) => {
27
28
  if (hasRendered || prefersReducedMotion())
28
29
  return false;
29
30
  return {
30
- enter: enterType ? { type: enterType } : {},
31
+ enter: {
32
+ ...enterType ? { type: enterType } : {},
33
+ duration: import_tokens.CHART_STYLE_DEFAULTS.animationDuration,
34
+ easing: "ease-out"
35
+ },
31
36
  update: { type: null },
32
37
  exit: { type: null }
33
38
  };
@@ -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
+ };
@@ -22,6 +22,8 @@ __export(components_exports, {
22
22
  getCartesianAxis: () => getCartesianAxis,
23
23
  getCartesianLayout: () => getCartesianLayout,
24
24
  getColorLegend: () => getColorLegend,
25
+ getDataLabels: () => getDataLabels,
26
+ getGraphTitle: () => getGraphTitle,
25
27
  resolveChartLocale: () => resolveChartLocale
26
28
  });
27
29
  module.exports = __toCommonJS(components_exports);
@@ -85,10 +87,48 @@ var getCartesianAxis = ({
85
87
  };
86
88
  };
87
89
  var getColorLegend = (visible) => visible ? { color: {} } : false;
90
+ function getDataLabels(theme, {
91
+ visible,
92
+ defaultVisible = false,
93
+ contrast,
94
+ style,
95
+ transform,
96
+ ...content
97
+ }) {
98
+ var _a, _b;
99
+ if (visible === false)
100
+ return [];
101
+ if (visible !== true && !defaultVisible)
102
+ return void 0;
103
+ const paint = contrast === "inside" ? theme.innerLabel : theme.label;
104
+ const textColor = (_a = theme.label) == null ? void 0 : _a.fill;
105
+ const inverseColor = (_b = theme.innerLabel) == null ? void 0 : _b.fill;
106
+ const contrastTransform = contrast === "inside" && textColor !== inverseColor ? [{ type: "contrastReverse", palette: [textColor, inverseColor] }] : [];
107
+ const transforms = [...contrastTransform, ...transform ?? []];
108
+ return [
109
+ { ...content, ...transforms.length ? { transform: transforms } : {}, ...style, ...paint }
110
+ ];
111
+ }
112
+ function getGraphTitle(title, subtitle, style = {}) {
113
+ if (!title)
114
+ return {
115
+ plugins: [],
116
+ padding: 20
117
+ };
118
+ const contentHeight = Math.ceil((style.titleFontSize ?? 16) * 1.2) + (subtitle ? (style.spacing ?? 8) + Math.ceil((style.subtitleFontSize ?? 12) * 1.2) : 0);
119
+ return {
120
+ plugins: [
121
+ { key: "title", type: "title", title, subtitle, ...style, size: Math.max(44, contentHeight) }
122
+ ],
123
+ padding: [Math.max(46, Math.ceil(contentHeight + 24)), 20, 20, 20]
124
+ };
125
+ }
88
126
  // Annotate the CommonJS export names for ESM import in node:
89
127
  0 && (module.exports = {
90
128
  getCartesianAxis,
91
129
  getCartesianLayout,
92
130
  getColorLegend,
131
+ getDataLabels,
132
+ getGraphTitle,
93
133
  resolveChartLocale
94
134
  });
@@ -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);
@@ -26,6 +26,7 @@ var import_component = require("@antv/component");
26
26
  var import_g2 = require("@antv/g2");
27
27
  var import_tokens = require("./tokens");
28
28
  var MAX_CROSSHAIR_DECIMAL_PLACES = 6;
29
+ var CROSSHAIR_LABEL_MARGIN = 4;
29
30
  var formatCrosshairAxisValue = (value, formatter, precision) => {
30
31
  if (value === void 0 || value === null || value === "")
31
32
  return "";
@@ -120,6 +121,19 @@ var getStandaloneTagStyle = (theme, tokens) => ({
120
121
  pointerEvents: "none"
121
122
  });
122
123
  var clamp = (value, min, max) => Math.min(Math.max(value, Math.min(min, max)), Math.max(min, max));
124
+ var keepTagInCanvas = (tag, canvas) => {
125
+ if (!tag || !canvas)
126
+ return;
127
+ const { width, height } = canvas.getConfig();
128
+ if (width === void 0 || height === void 0)
129
+ return;
130
+ const { min, max } = tag.getBounds();
131
+ const margin = CROSSHAIR_LABEL_MARGIN;
132
+ const dx = Math.max(margin - min[0], Math.min(0, width - margin - max[0]));
133
+ const dy = Math.max(margin - min[1], Math.min(0, height - margin - max[1]));
134
+ if (dx || dy)
135
+ tag.translate(dx, dy);
136
+ };
123
137
  var invertCrosshairValue = (scale, value) => {
124
138
  var _a, _b, _c;
125
139
  if (!scale || typeof scale.invert !== "function" || value === void 0)
@@ -346,6 +360,7 @@ var bindCrosshairAxisLabels = (chart, theme, {
346
360
  xCrosshair.setText(xText);
347
361
  xCrosshair.setPointer([x + plotX, verticalRule.y2 + plotY]);
348
362
  xCrosshair.style.visibility = "visible";
363
+ keepTagInCanvas(xCrosshair.querySelector(".crosshair-tag"), context.canvas);
349
364
  }
350
365
  if (yCrosshair) {
351
366
  yCrosshair.setText(yText);
@@ -354,6 +369,7 @@ var bindCrosshairAxisLabels = (chart, theme, {
354
369
  y + plotY
355
370
  ]);
356
371
  yCrosshair.style.visibility = "visible";
372
+ keepTagInCanvas(yCrosshair.querySelector(".crosshair-tag"), context.canvas);
357
373
  }
358
374
  if (standaloneYTag) {
359
375
  const yAxisX = getYAxisLinePosition(
@@ -366,6 +382,7 @@ var bindCrosshairAxisLabels = (chart, theme, {
366
382
  standaloneYTag.update({ text: yText });
367
383
  standaloneYTag.setLocalPosition([yAxisX + plotX, y + plotY]);
368
384
  standaloneYTag.style.visibility = "visible";
385
+ keepTagInCanvas(standaloneYTag, context.canvas);
369
386
  }
370
387
  };
371
388
  const 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';
@@ -20,14 +20,10 @@ __reExport(util_exports, require("./animation"), module.exports);
20
20
  __reExport(util_exports, require("./components"), module.exports);
21
21
  __reExport(util_exports, require("./crosshair-axis-labels"), module.exports);
22
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
23
  // Annotate the CommonJS export names for ESM import in node:
26
24
  0 && (module.exports = {
27
25
  ...require("./animation"),
28
26
  ...require("./components"),
29
27
  ...require("./crosshair-axis-labels"),
30
- ...require("./interaction"),
31
- ...require("./theme"),
32
- ...require("./tokens")
28
+ ...require("./interaction")
33
29
  });
@@ -1,4 +1,3 @@
1
- import type { VisualizationTheme } from '../types';
2
1
  export type SharedTooltipInteractionOptions = {
3
2
  crosshairs?: boolean;
4
3
  };
@@ -7,8 +6,10 @@ export type PointHighlightStateOptions = {
7
6
  inactiveOpacity?: number;
8
7
  };
9
8
  export declare const getSharedTooltipInteraction: ({ crosshairs, }?: SharedTooltipInteractionOptions) => Record<string, boolean>;
10
- export declare const getCategoryBackgroundHighlightState: (theme: VisualizationTheme) => Record<string, any>;
9
+ export declare const getCategoryBackgroundHighlightState: (theme: string) => Record<string, any>;
11
10
  export declare const getCategoryHighlightInteraction: () => Record<string, any>;
12
11
  export declare const getPointHighlightState: ({ activeLineWidth, inactiveOpacity, }?: PointHighlightStateOptions) => Record<string, any>;
13
- export declare const getSeriesHighlightByColorInteraction: () => Record<string, boolean>;
12
+ export declare const getSeriesHighlightByColorInteraction: () => Record<string, any>;
14
13
  export declare const getLineHighlightState: (lineWidth: number) => Record<string, any>;
14
+ /** Preserve GPT-Vis hover feedback independently of the visual theme. */
15
+ export declare const getElementHoverScaleInteraction: (theme: string) => Record<string, unknown>;
@@ -21,6 +21,7 @@ var interaction_exports = {};
21
21
  __export(interaction_exports, {
22
22
  getCategoryBackgroundHighlightState: () => getCategoryBackgroundHighlightState,
23
23
  getCategoryHighlightInteraction: () => getCategoryHighlightInteraction,
24
+ getElementHoverScaleInteraction: () => getElementHoverScaleInteraction,
24
25
  getLineHighlightState: () => getLineHighlightState,
25
26
  getPointHighlightState: () => getPointHighlightState,
26
27
  getSeriesHighlightByColorInteraction: () => getSeriesHighlightByColorInteraction,
@@ -48,6 +49,7 @@ var getCategoryBackgroundHighlightState = (theme) => {
48
49
  };
49
50
  };
50
51
  var getCategoryHighlightInteraction = () => ({
52
+ delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay,
51
53
  background: true,
52
54
  region: true
53
55
  });
@@ -72,16 +74,27 @@ var getPointHighlightState = ({
72
74
  }
73
75
  });
74
76
  var getSeriesHighlightByColorInteraction = () => ({
75
- elementHighlightByColor: true
77
+ elementHighlightByColor: { delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay }
76
78
  });
77
79
  var getLineHighlightState = (lineWidth) => ({
78
80
  active: { lineWidth: lineWidth + 1, strokeOpacity: 1 },
79
81
  inactive: { strokeOpacity: import_tokens.CHART_STYLE_DEFAULTS.inactiveOpacity }
80
82
  });
83
+ var getElementHoverScaleInteraction = (theme) => ({
84
+ delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay,
85
+ scale: 1.04,
86
+ shadow: true,
87
+ shadowBlur: theme === "dark" ? 7 : theme === "academy" ? 5 : 6,
88
+ shadowColor: theme === "dark" ? "rgba(226, 232, 240, 0.38)" : theme === "academy" ? "rgba(63, 49, 38, 0.44)" : "rgba(15, 23, 42, 0.46)",
89
+ shadowOffsetX: 0,
90
+ shadowOffsetY: theme === "dark" ? 0 : 3,
91
+ zIndex: 10
92
+ });
81
93
  // Annotate the CommonJS export names for ESM import in node:
82
94
  0 && (module.exports = {
83
95
  getCategoryBackgroundHighlightState,
84
96
  getCategoryHighlightInteraction,
97
+ getElementHoverScaleInteraction,
85
98
  getLineHighlightState,
86
99
  getPointHighlightState,
87
100
  getSeriesHighlightByColorInteraction,
@@ -1,4 +1,3 @@
1
- import type { VisualizationTheme } from '../types';
2
1
  export declare const CHART_FONT_FAMILY = "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif";
3
2
  export declare const CHART_STYLE_DEFAULTS: {
4
3
  readonly animationDuration: 260;
@@ -13,9 +12,10 @@ export declare const CHART_STYLE_DEFAULTS: {
13
12
  readonly pointActiveLineWidth: 5;
14
13
  readonly intervalWidthRatio: 0.64;
15
14
  };
16
- export type ChartVisualTokens = {
15
+ type BuiltInThemeValues = {
17
16
  background: string;
18
17
  textPrimary: string;
18
+ textInverse: string;
19
19
  textSecondary: string;
20
20
  grid: string;
21
21
  axisGrid: string;
@@ -28,4 +28,5 @@ export type ChartVisualTokens = {
28
28
  tooltipMarkerShadow: string;
29
29
  tooltipShadow: string;
30
30
  };
31
- export declare const getChartVisualTokens: (theme: VisualizationTheme) => ChartVisualTokens;
31
+ export declare const getChartVisualTokens: (theme: string) => BuiltInThemeValues;
32
+ export {};
@@ -38,9 +38,10 @@ var CHART_STYLE_DEFAULTS = {
38
38
  pointActiveLineWidth: 5,
39
39
  intervalWidthRatio: 0.64
40
40
  };
41
- var LIGHT_TOKENS = {
41
+ var LIGHT_THEME_VALUES = {
42
42
  background: "#FFFFFF",
43
43
  textPrimary: "#1F2937",
44
+ textInverse: "#FFFFFF",
44
45
  textSecondary: "#667085",
45
46
  grid: "#E7EAF0",
46
47
  axisGrid: "#D0D5DD",
@@ -53,9 +54,10 @@ var LIGHT_TOKENS = {
53
54
  tooltipMarkerShadow: "0 0 0 2px #FFFFFF, 0 1px 3px rgba(15, 23, 42, 0.20)",
54
55
  tooltipShadow: "0 12px 32px rgba(15, 23, 42, 0.12), 0 3px 8px rgba(15, 23, 42, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.82)"
55
56
  };
56
- var DARK_TOKENS = {
57
+ var DARK_THEME_VALUES = {
57
58
  background: "#141414",
58
59
  textPrimary: "#F3F4F6",
60
+ textInverse: "#111827",
59
61
  textSecondary: "#A7AFBE",
60
62
  grid: "#343841",
61
63
  axisGrid: "#475467",
@@ -68,9 +70,10 @@ var DARK_TOKENS = {
68
70
  tooltipMarkerShadow: "0 0 0 2px #1A1B1F, 0 1px 3px rgba(0, 0, 0, 0.42)",
69
71
  tooltipShadow: "0 14px 36px rgba(0, 0, 0, 0.34), 0 3px 10px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08)"
70
72
  };
71
- var ACADEMY_TOKENS = {
73
+ var ACADEMY_THEME_VALUES = {
72
74
  background: "#FFFFFF",
73
75
  textPrimary: "#23262D",
76
+ textInverse: "#FFFFFF",
74
77
  textSecondary: "#626975",
75
78
  grid: "#DDDDDD",
76
79
  axisGrid: "#DDDDDD",
@@ -85,10 +88,10 @@ var ACADEMY_TOKENS = {
85
88
  };
86
89
  var getChartVisualTokens = (theme) => {
87
90
  if (theme === "dark")
88
- return DARK_TOKENS;
91
+ return DARK_THEME_VALUES;
89
92
  if (theme === "academy")
90
- return ACADEMY_TOKENS;
91
- return LIGHT_TOKENS;
93
+ return ACADEMY_THEME_VALUES;
94
+ return LIGHT_THEME_VALUES;
92
95
  };
93
96
  // Annotate the CommonJS export names for ESM import in node:
94
97
  0 && (module.exports = {
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * AreaDataItem is the type for each data item in the area chart.
4
4
  */
@@ -15,14 +15,11 @@ export interface AreaConfig {
15
15
  data: AreaDataItem[];
16
16
  stack?: boolean;
17
17
  title?: string;
18
+ subtitle?: string;
18
19
  axisXTitle?: string;
19
20
  axisYTitle?: string;
20
21
  theme?: VisualizationTheme;
21
- style?: {
22
- backgroundColor?: string;
23
- palette?: string[];
24
- lineWidth?: number;
25
- };
22
+ style?: ThemeStyle;
26
23
  }
27
24
  /**
28
25
  * AreaInstance represents an area chart instance with render and destroy methods.
@@ -23,7 +23,10 @@ __export(area_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(area_exports);
25
25
  var import_g2 = require("@antv/g2");
26
+ var import_g22 = require("../../theme/g2");
26
27
  var import_util = require("../../util");
28
+ var import_components = require("../../util/components");
29
+ var import_tokens = require("../../util/tokens");
27
30
  var getLinearGradientColor = (color, backgroundColor = "white") => `linear-gradient(-90deg, ${backgroundColor} 0%, ${color} 100%)`;
28
31
  var DEFAULT_COLOR = "#3A95FF";
29
32
  var Area = (options) => {
@@ -37,29 +40,48 @@ var Area = (options) => {
37
40
  data = [],
38
41
  theme = chartTheme,
39
42
  title,
43
+ subtitle,
40
44
  axisXTitle,
41
45
  axisYTitle,
42
46
  stack = false,
43
- style = {}
47
+ style: localStyle = {}
44
48
  } = config;
45
49
  if (chart) {
46
50
  cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
47
51
  cleanupCrosshairAxisLabels = null;
48
52
  chart.destroy();
49
53
  }
50
- const { lineWidth = import_util.CHART_STYLE_DEFAULTS.lineWidth } = style;
51
54
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
52
- const colors = (0, import_util.normalizePalette)(style.palette, theme);
53
- const backgroundColor = style.backgroundColor || (0, import_util.getBackgroundColor)(theme);
54
- const fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
55
- const areaOpacity = import_util.CHART_STYLE_DEFAULTS.areaOpacity;
56
- const lineOpacity = import_util.CHART_STYLE_DEFAULTS.lineOpacity;
57
55
  const cartesianAxisOptions = {
58
56
  axisXTitle,
59
57
  axisYTitle,
60
58
  xLabels: data.map(({ time }) => time),
61
59
  chartWidth: width
62
60
  };
61
+ const appearance = (0, import_g22.getThemeObject)("area", theme, localStyle);
62
+ const { theme: rendererTheme } = appearance;
63
+ const areaMark = {
64
+ fillOpacity: import_tokens.CHART_STYLE_DEFAULTS.areaOpacity,
65
+ ...appearance.mark.area
66
+ };
67
+ const lineMark = {
68
+ lineWidth: import_tokens.CHART_STYLE_DEFAULTS.lineWidth,
69
+ strokeOpacity: import_tokens.CHART_STYLE_DEFAULTS.lineOpacity,
70
+ ...appearance.mark.line
71
+ };
72
+ const pointStyle = {
73
+ shape: "point",
74
+ size: import_tokens.CHART_STYLE_DEFAULTS.pointSize,
75
+ lineWidth: import_tokens.CHART_STYLE_DEFAULTS.pointLineWidth,
76
+ stroke: rendererTheme.view.viewFill,
77
+ ...appearance.mark.point
78
+ };
79
+ const baseTheme = rendererTheme.type;
80
+ const lineWidth = lineMark.lineWidth;
81
+ const colors = rendererTheme.category10;
82
+ const backgroundColor = rendererTheme.view.viewFill;
83
+ const fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
84
+ const areaOpacity = areaMark.fillOpacity ?? import_tokens.CHART_STYLE_DEFAULTS.areaOpacity;
63
85
  const tooltip = {
64
86
  items: [
65
87
  (d) => ({
@@ -85,12 +107,9 @@ var Area = (options) => {
85
107
  children = [
86
108
  {
87
109
  type: "area",
88
- style: { fillOpacity: areaOpacity }
110
+ style: areaMark
89
111
  },
90
- {
91
- type: "line",
92
- style: { lineWidth, strokeOpacity: lineOpacity }
93
- }
112
+ { type: "line", style: lineMark }
94
113
  ];
95
114
  } else if (hasGroupField) {
96
115
  encode = { x: "time", y: "value", color: "group" };
@@ -98,12 +117,9 @@ var Area = (options) => {
98
117
  children = [
99
118
  {
100
119
  type: "area",
101
- style: { fillOpacity: areaOpacity }
120
+ style: areaMark
102
121
  },
103
- {
104
- type: "line",
105
- style: { lineWidth, strokeOpacity: lineOpacity }
106
- }
122
+ { type: "line", style: lineMark }
107
123
  ];
108
124
  } else {
109
125
  encode = { x: "time", y: "value" };
@@ -111,17 +127,16 @@ var Area = (options) => {
111
127
  {
112
128
  type: "area",
113
129
  style: {
114
- fillOpacity: areaOpacity,
130
+ ...areaMark,
115
131
  fill: fillColor
116
132
  }
117
133
  },
118
134
  {
119
135
  type: "line",
120
136
  style: {
121
- lineWidth,
122
- strokeOpacity: lineOpacity,
123
137
  lineCap: "round",
124
138
  lineJoin: "round",
139
+ ...lineMark,
125
140
  stroke: colors[0]
126
141
  }
127
142
  }
@@ -137,43 +152,41 @@ var Area = (options) => {
137
152
  } : (0, import_util.getLineHighlightState)(lineWidth) : void 0
138
153
  }));
139
154
  if (!hasGroupField && data.length <= 24) {
155
+ const { size: pointSize, ...pointMark } = pointStyle;
140
156
  children.push({
141
157
  type: "point",
142
158
  encode: {
143
159
  x: "time",
144
160
  y: "value",
145
- shape: "point",
146
- size: import_util.CHART_STYLE_DEFAULTS.pointSize
161
+ size: pointSize
147
162
  },
148
163
  animate: (0, import_util.getChartAnimation)(hasRendered, "fadeIn"),
149
164
  tooltip: false,
150
165
  style: {
151
- lineWidth: import_util.CHART_STYLE_DEFAULTS.pointLineWidth,
152
- fill: colors[0],
153
- stroke: backgroundColor
166
+ ...pointMark,
167
+ fill: colors[0]
154
168
  }
155
169
  });
156
170
  }
157
171
  const chartOptions = {
158
172
  type: "view",
159
173
  data,
160
- title: title || "",
174
+ title: title ? { title, subtitle } : "",
161
175
  encode,
162
176
  transform,
163
177
  children,
164
178
  scale: scaleConfig,
165
179
  ...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
166
180
  axis: (0, import_util.getCartesianAxis)(cartesianAxisOptions),
167
- legend: (0, import_util.getColorLegend)(hasGroupField),
181
+ legend: (0, import_components.getColorLegend)(hasGroupField),
168
182
  interaction: {
169
183
  tooltip: (0, import_util.getSharedTooltipInteraction)({ crosshairs: true }),
170
184
  ...hasGroupField ? (0, import_util.getSeriesHighlightByColorInteraction)() : {}
171
185
  },
172
- viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
173
- theme: (0, import_util.getThemeObject)(theme)
186
+ theme: rendererTheme
174
187
  };
175
188
  chart.options(chartOptions);
176
- cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart, theme);
189
+ cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart, baseTheme);
177
190
  chart.render();
178
191
  hasRendered = true;
179
192
  };
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * BarDataItem is the type for each data item in the bar chart.
4
4
  */
@@ -16,13 +16,13 @@ export interface BarConfig {
16
16
  group?: boolean;
17
17
  stack?: boolean;
18
18
  title?: string;
19
+ subtitle?: string;
20
+ /** Show value labels. Defaults to `true`. */
21
+ label?: boolean;
19
22
  axisXTitle?: string;
20
23
  axisYTitle?: string;
21
24
  theme?: VisualizationTheme;
22
- style?: {
23
- backgroundColor?: string;
24
- palette?: string[];
25
- };
25
+ style?: ThemeStyle;
26
26
  }
27
27
  /**
28
28
  * BarInstance represents a bar chart instance with render and destroy methods.
@@ -23,28 +23,41 @@ __export(bar_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(bar_exports);
25
25
  var import_g2 = require("@antv/g2");
26
+ var import_g22 = require("../../theme/g2");
26
27
  var import_util = require("../../util");
28
+ var import_components = require("../../util/components");
29
+ var import_tokens = require("../../util/tokens");
27
30
  var Bar = (options) => {
28
31
  const { container, width, height, theme: chartTheme = "default" } = options;
29
32
  let chart = null;
30
- let hasRendered = false;
31
33
  const render = (config) => {
32
34
  var _a;
33
35
  const {
34
36
  data = [],
35
37
  theme = chartTheme,
36
38
  title,
39
+ subtitle,
40
+ label,
37
41
  axisXTitle,
38
42
  axisYTitle,
39
43
  group = false,
40
44
  stack = false,
41
- style = {}
45
+ style: localStyle = {}
42
46
  } = config;
43
47
  if (chart) {
44
48
  chart.destroy();
45
49
  }
46
50
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
47
- const colors = (0, import_util.normalizePalette)(style.palette, theme);
51
+ const appearance = (0, import_g22.getThemeObject)("bar", theme, localStyle);
52
+ const { theme: rendererTheme } = appearance;
53
+ const intervalMark = {
54
+ ...rendererTheme.type !== "academy" ? { radius: 4 } : {},
55
+ columnWidthRatio: import_tokens.CHART_STYLE_DEFAULTS.intervalWidthRatio,
56
+ ...!hasGroupField ? { fill: rendererTheme.category10[0] } : {},
57
+ ...appearance.mark.interval
58
+ };
59
+ const baseTheme = rendererTheme.type;
60
+ const colors = rendererTheme.category10;
48
61
  chart = new import_g2.Chart({
49
62
  container,
50
63
  width,
@@ -53,10 +66,6 @@ var Bar = (options) => {
53
66
  });
54
67
  let encode = {};
55
68
  let transform = [];
56
- let radiusStyle = {};
57
- if (theme !== "academy") {
58
- radiusStyle = { radius: 4 };
59
- }
60
69
  if (hasGroupField && group) {
61
70
  transform = [{ type: "dodgeX" }];
62
71
  }
@@ -73,16 +82,28 @@ var Bar = (options) => {
73
82
  ...hasGroupField ? { color: { range: colors } } : {}
74
83
  };
75
84
  const chartOptions = {
76
- animate: (0, import_util.getChartAnimation)(hasRendered, "growInX"),
85
+ // G2 growInX currently computes interval label bounds from the animated
86
+ // clip path, which leaves inside labels at the axis baseline. Keep the
87
+ // interval and its labels in sync until the upstream runtime is fixed.
88
+ animate: false,
77
89
  type: "interval",
78
90
  data,
79
- title: title || "",
91
+ title: title ? { title, subtitle } : "",
80
92
  encode,
81
93
  transform,
82
94
  coordinate: { transform: [{ type: "transpose" }] },
83
95
  scale: scaleConfig,
84
96
  axis: (0, import_util.getCartesianAxis)({ axisXTitle, axisYTitle }),
85
- legend: (0, import_util.getColorLegend)(hasGroupField),
97
+ legend: (0, import_components.getColorLegend)(hasGroupField),
98
+ labels: (0, import_components.getDataLabels)(rendererTheme, {
99
+ visible: label,
100
+ defaultVisible: true,
101
+ text: "value",
102
+ position: "right",
103
+ contrast: "inside",
104
+ dx: -4,
105
+ dy: 0
106
+ }),
86
107
  tooltip: {
87
108
  items: [
88
109
  (d) => ({
@@ -91,29 +112,22 @@ var Bar = (options) => {
91
112
  })
92
113
  ]
93
114
  },
94
- state: (0, import_util.getCategoryBackgroundHighlightState)(theme),
115
+ state: (0, import_util.getCategoryBackgroundHighlightState)(baseTheme),
95
116
  interaction: {
96
117
  tooltip: true,
97
118
  elementHighlight: (0, import_util.getCategoryHighlightInteraction)()
98
119
  },
99
- style: {
100
- ...radiusStyle,
101
- columnWidthRatio: import_util.CHART_STYLE_DEFAULTS.intervalWidthRatio,
102
- ...!hasGroupField ? { fill: colors[0] } : {}
103
- },
104
- viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
105
- theme: (0, import_util.getThemeObject)(theme)
120
+ style: intervalMark,
121
+ theme: rendererTheme
106
122
  };
107
123
  chart.options(chartOptions);
108
124
  chart.render();
109
- hasRendered = true;
110
125
  };
111
126
  const destroy = () => {
112
127
  if (chart) {
113
128
  chart.destroy();
114
129
  chart = null;
115
130
  }
116
- hasRendered = false;
117
131
  };
118
132
  return {
119
133
  render,