@antv/gpt-vis 1.0.0 → 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 (92) hide show
  1. package/README.md +66 -1
  2. package/README.zh-CN.md +66 -1
  3. package/dist/cjs/types/index.d.ts +2 -1
  4. package/dist/cjs/util/animation.d.ts +2 -0
  5. package/dist/cjs/util/animation.js +38 -0
  6. package/dist/cjs/util/components.d.ts +15 -0
  7. package/dist/cjs/util/components.js +94 -0
  8. package/dist/cjs/util/crosshair-axis-labels.d.ts +9 -0
  9. package/dist/cjs/util/crosshair-axis-labels.js +304 -0
  10. package/dist/cjs/util/index.d.ts +6 -0
  11. package/dist/cjs/util/index.js +33 -0
  12. package/dist/cjs/util/interaction.d.ts +14 -0
  13. package/dist/cjs/util/interaction.js +89 -0
  14. package/dist/cjs/util/theme.d.ts +18 -24
  15. package/dist/cjs/util/theme.js +303 -120
  16. package/dist/cjs/util/tokens.d.ts +31 -0
  17. package/dist/cjs/util/tokens.js +98 -0
  18. package/dist/cjs/vis/area/index.d.ts +2 -2
  19. package/dist/cjs/vis/area/index.js +76 -31
  20. package/dist/cjs/vis/bar/index.d.ts +2 -2
  21. package/dist/cjs/vis/bar/index.js +22 -19
  22. package/dist/cjs/vis/boxplot/index.js +1 -4
  23. package/dist/cjs/vis/column/index.d.ts +2 -2
  24. package/dist/cjs/vis/column/index.js +28 -18
  25. package/dist/cjs/vis/dual-axes/index.d.ts +2 -2
  26. package/dist/cjs/vis/dual-axes/index.js +89 -34
  27. package/dist/cjs/vis/funnel/index.d.ts +4 -2
  28. package/dist/cjs/vis/funnel/index.js +171 -92
  29. package/dist/cjs/vis/histogram/index.js +1 -4
  30. package/dist/cjs/vis/line/index.d.ts +2 -2
  31. package/dist/cjs/vis/line/index.js +71 -31
  32. package/dist/cjs/vis/liquid/index.d.ts +2 -2
  33. package/dist/cjs/vis/liquid/index.js +41 -16
  34. package/dist/cjs/vis/pie/index.d.ts +2 -2
  35. package/dist/cjs/vis/pie/index.js +26 -16
  36. package/dist/cjs/vis/radar/index.d.ts +2 -2
  37. package/dist/cjs/vis/radar/index.js +21 -29
  38. package/dist/cjs/vis/sankey/index.js +1 -4
  39. package/dist/cjs/vis/scatter/index.d.ts +2 -2
  40. package/dist/cjs/vis/scatter/index.js +40 -17
  41. package/dist/cjs/vis/treemap/index.js +1 -4
  42. package/dist/cjs/vis/venn/index.js +1 -4
  43. package/dist/cjs/vis/violin/index.js +1 -1
  44. package/dist/cjs/vis/waterfall/index.js +1 -1
  45. package/dist/cjs/vis/word-cloud/index.d.ts +3 -2
  46. package/dist/cjs/vis/word-cloud/index.js +125 -10
  47. package/dist/esm/types/index.d.ts +2 -1
  48. package/dist/esm/util/animation.d.ts +2 -0
  49. package/dist/esm/util/animation.js +17 -0
  50. package/dist/esm/util/components.d.ts +15 -0
  51. package/dist/esm/util/components.js +67 -0
  52. package/dist/esm/util/crosshair-axis-labels.d.ts +9 -0
  53. package/dist/esm/util/crosshair-axis-labels.js +328 -0
  54. package/dist/esm/util/index.d.ts +6 -0
  55. package/dist/esm/util/index.js +6 -0
  56. package/dist/esm/util/interaction.d.ts +14 -0
  57. package/dist/esm/util/interaction.js +73 -0
  58. package/dist/esm/util/theme.d.ts +18 -24
  59. package/dist/esm/util/theme.js +302 -126
  60. package/dist/esm/util/tokens.d.ts +31 -0
  61. package/dist/esm/util/tokens.js +64 -0
  62. package/dist/esm/vis/area/index.d.ts +2 -2
  63. package/dist/esm/vis/area/index.js +91 -41
  64. package/dist/esm/vis/bar/index.d.ts +2 -2
  65. package/dist/esm/vis/bar/index.js +28 -29
  66. package/dist/esm/vis/boxplot/index.js +4 -5
  67. package/dist/esm/vis/column/index.d.ts +2 -2
  68. package/dist/esm/vis/column/index.js +36 -29
  69. package/dist/esm/vis/dual-axes/index.d.ts +2 -2
  70. package/dist/esm/vis/dual-axes/index.js +115 -42
  71. package/dist/esm/vis/funnel/index.d.ts +4 -2
  72. package/dist/esm/vis/funnel/index.js +156 -83
  73. package/dist/esm/vis/histogram/index.js +4 -5
  74. package/dist/esm/vis/line/index.d.ts +2 -2
  75. package/dist/esm/vis/line/index.js +80 -37
  76. package/dist/esm/vis/liquid/index.d.ts +2 -2
  77. package/dist/esm/vis/liquid/index.js +41 -14
  78. package/dist/esm/vis/pie/index.d.ts +2 -2
  79. package/dist/esm/vis/pie/index.js +36 -16
  80. package/dist/esm/vis/radar/index.d.ts +2 -2
  81. package/dist/esm/vis/radar/index.js +21 -34
  82. package/dist/esm/vis/sankey/index.js +4 -5
  83. package/dist/esm/vis/scatter/index.d.ts +2 -2
  84. package/dist/esm/vis/scatter/index.js +41 -25
  85. package/dist/esm/vis/treemap/index.js +4 -5
  86. package/dist/esm/vis/venn/index.js +4 -5
  87. package/dist/esm/vis/violin/index.js +5 -13
  88. package/dist/esm/vis/waterfall/index.js +5 -7
  89. package/dist/esm/vis/word-cloud/index.d.ts +3 -2
  90. package/dist/esm/vis/word-cloud/index.js +158 -10
  91. package/dist/umd/index.min.js +1 -1
  92. package/package.json +18 -15
@@ -0,0 +1,98 @@
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/tokens.ts
20
+ var tokens_exports = {};
21
+ __export(tokens_exports, {
22
+ CHART_FONT_FAMILY: () => CHART_FONT_FAMILY,
23
+ CHART_STYLE_DEFAULTS: () => CHART_STYLE_DEFAULTS,
24
+ getChartVisualTokens: () => getChartVisualTokens
25
+ });
26
+ module.exports = __toCommonJS(tokens_exports);
27
+ var CHART_FONT_FAMILY = 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';
28
+ var CHART_STYLE_DEFAULTS = {
29
+ animationDuration: 260,
30
+ interactionDelay: 40,
31
+ lineWidth: 2.5,
32
+ areaOpacity: 0.24,
33
+ lineOpacity: 0.92,
34
+ inactiveOpacity: 0.24,
35
+ pointSize: 3.5,
36
+ scatterPointSize: 5,
37
+ pointLineWidth: 1.5,
38
+ pointActiveLineWidth: 5,
39
+ intervalWidthRatio: 0.64
40
+ };
41
+ var LIGHT_TOKENS = {
42
+ background: "#FFFFFF",
43
+ textPrimary: "#1F2937",
44
+ textSecondary: "#667085",
45
+ grid: "#E7EAF0",
46
+ axisGrid: "#EAECF0",
47
+ axisLine: "#D0D5DD",
48
+ axisTick: "#98A2B3",
49
+ separator: "#FFFFFF",
50
+ tooltipBackground: "rgba(255, 255, 255, 0.96)",
51
+ tooltipBorder: "rgba(15, 23, 42, 0.09)",
52
+ tooltipDivider: "rgba(15, 23, 42, 0.08)",
53
+ tooltipMarkerShadow: "0 0 0 2px #FFFFFF, 0 1px 3px rgba(15, 23, 42, 0.20)",
54
+ 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
+ var DARK_TOKENS = {
57
+ background: "#141414",
58
+ textPrimary: "#F3F4F6",
59
+ textSecondary: "#A7AFBE",
60
+ grid: "#343841",
61
+ axisGrid: "#2B2F36",
62
+ axisLine: "#454B56",
63
+ axisTick: "#596170",
64
+ separator: "#141414",
65
+ tooltipBackground: "rgba(26, 27, 31, 0.96)",
66
+ tooltipBorder: "rgba(255, 255, 255, 0.12)",
67
+ tooltipDivider: "rgba(255, 255, 255, 0.10)",
68
+ tooltipMarkerShadow: "0 0 0 2px #1A1B1F, 0 1px 3px rgba(0, 0, 0, 0.42)",
69
+ 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
+ };
71
+ var ACADEMY_TOKENS = {
72
+ background: "#FFFFFF",
73
+ textPrimary: "#23262D",
74
+ textSecondary: "#626975",
75
+ grid: "#DDDDDD",
76
+ axisGrid: "#DDDDDD",
77
+ axisLine: "#888888",
78
+ axisTick: "#000000",
79
+ separator: "#FFFFFF",
80
+ tooltipBackground: "rgba(255, 253, 249, 0.98)",
81
+ tooltipBorder: "rgba(83, 72, 60, 0.14)",
82
+ tooltipDivider: "rgba(83, 72, 60, 0.12)",
83
+ tooltipMarkerShadow: "0 0 0 2px #FFFDF9, 0 1px 3px rgba(63, 49, 38, 0.20)",
84
+ tooltipShadow: "0 12px 30px rgba(63, 49, 38, 0.11), 0 3px 8px rgba(63, 49, 38, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.88)"
85
+ };
86
+ var getChartVisualTokens = (theme) => {
87
+ if (theme === "dark")
88
+ return DARK_TOKENS;
89
+ if (theme === "academy")
90
+ return ACADEMY_TOKENS;
91
+ return LIGHT_TOKENS;
92
+ };
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ CHART_FONT_FAMILY,
96
+ CHART_STYLE_DEFAULTS,
97
+ getChartVisualTokens
98
+ });
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * AreaDataItem is the type for each data item in the area chart.
4
4
  */
@@ -17,7 +17,7 @@ export interface AreaConfig {
17
17
  title?: string;
18
18
  axisXTitle?: string;
19
19
  axisYTitle?: string;
20
- theme?: 'default' | 'academy' | 'dark';
20
+ theme?: VisualizationTheme;
21
21
  style?: {
22
22
  backgroundColor?: string;
23
23
  palette?: string[];
@@ -23,12 +23,14 @@ __export(area_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(area_exports);
25
25
  var import_g2 = require("@antv/g2");
26
- var import_theme = require("../../util/theme");
27
- var getLinearGradientColor = (color) => `linear-gradient(-90deg, white 0%, ${color} 100%)`;
26
+ var import_util = require("../../util");
27
+ var getLinearGradientColor = (color, backgroundColor = "white") => `linear-gradient(-90deg, ${backgroundColor} 0%, ${color} 100%)`;
28
28
  var DEFAULT_COLOR = "#3A95FF";
29
29
  var Area = (options) => {
30
30
  const { container, width, height, theme: chartTheme = "default" } = options;
31
31
  let chart = null;
32
+ let hasRendered = false;
33
+ let cleanupCrosshairAxisLabels = null;
32
34
  const render = (config) => {
33
35
  var _a;
34
36
  const {
@@ -41,13 +43,31 @@ var Area = (options) => {
41
43
  style = {}
42
44
  } = config;
43
45
  if (chart) {
46
+ cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
47
+ cleanupCrosshairAxisLabels = null;
44
48
  chart.destroy();
45
49
  }
46
- const { lineWidth = 2 } = style;
50
+ const { lineWidth = import_util.CHART_STYLE_DEFAULTS.lineWidth } = style;
47
51
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
48
- const colors = (0, import_theme.normalizePalette)(style.palette, theme);
49
- const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
50
- const fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR);
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
+ const cartesianAxisOptions = {
58
+ axisXTitle,
59
+ axisYTitle,
60
+ xLabels: data.map(({ time }) => time),
61
+ chartWidth: width
62
+ };
63
+ const tooltip = {
64
+ items: [
65
+ (d) => ({
66
+ name: hasGroupField ? d.group : axisYTitle || d.time,
67
+ value: d.value
68
+ })
69
+ ]
70
+ };
51
71
  chart = new import_g2.Chart({
52
72
  container,
53
73
  width,
@@ -65,11 +85,11 @@ var Area = (options) => {
65
85
  children = [
66
86
  {
67
87
  type: "area",
68
- style: { fillOpacity: 0.6 }
88
+ style: { fillOpacity: areaOpacity }
69
89
  },
70
90
  {
71
91
  type: "line",
72
- style: { lineWidth, strokeOpacity: 0.6 }
92
+ style: { lineWidth, strokeOpacity: lineOpacity }
73
93
  }
74
94
  ];
75
95
  } else if (hasGroupField) {
@@ -78,11 +98,11 @@ var Area = (options) => {
78
98
  children = [
79
99
  {
80
100
  type: "area",
81
- style: { fillOpacity: 0.6 }
101
+ style: { fillOpacity: areaOpacity }
82
102
  },
83
103
  {
84
104
  type: "line",
85
- style: { lineWidth, strokeOpacity: 0.6 }
105
+ style: { lineWidth, strokeOpacity: lineOpacity }
86
106
  }
87
107
  ];
88
108
  } else {
@@ -91,7 +111,7 @@ var Area = (options) => {
91
111
  {
92
112
  type: "area",
93
113
  style: {
94
- fillOpacity: 0.6,
114
+ fillOpacity: areaOpacity,
95
115
  fill: fillColor
96
116
  }
97
117
  },
@@ -99,47 +119,72 @@ var Area = (options) => {
99
119
  type: "line",
100
120
  style: {
101
121
  lineWidth,
102
- strokeOpacity: 0.6,
103
- ...style.palette ? { stroke: colors[0] } : {}
122
+ strokeOpacity: lineOpacity,
123
+ lineCap: "round",
124
+ lineJoin: "round",
125
+ stroke: colors[0]
104
126
  }
105
127
  }
106
128
  ];
107
129
  }
130
+ children = children.map((child) => ({
131
+ ...child,
132
+ animate: (0, import_util.getChartAnimation)(hasRendered, child.type === "line" ? "pathIn" : "fadeIn"),
133
+ tooltip: child.type === "line" ? tooltip : false,
134
+ state: hasGroupField ? child.type === "area" ? {
135
+ active: { fillOpacity: Math.min(areaOpacity + 0.1, 1) },
136
+ inactive: { fillOpacity: 0.07 }
137
+ } : (0, import_util.getLineHighlightState)(lineWidth) : void 0
138
+ }));
139
+ if (!hasGroupField && data.length <= 24) {
140
+ children.push({
141
+ type: "point",
142
+ encode: {
143
+ x: "time",
144
+ y: "value",
145
+ shape: "point",
146
+ size: import_util.CHART_STYLE_DEFAULTS.pointSize
147
+ },
148
+ animate: (0, import_util.getChartAnimation)(hasRendered, "fadeIn"),
149
+ tooltip: false,
150
+ style: {
151
+ lineWidth: import_util.CHART_STYLE_DEFAULTS.pointLineWidth,
152
+ fill: colors[0],
153
+ stroke: backgroundColor
154
+ }
155
+ });
156
+ }
108
157
  const chartOptions = {
109
- animate: false,
110
158
  type: "view",
111
159
  data,
112
- title: title ?? "",
160
+ title: title || "",
113
161
  encode,
114
162
  transform,
115
163
  children,
116
164
  scale: scaleConfig,
117
- axis: {
118
- x: { title: axisXTitle || false },
119
- y: { title: axisYTitle || false }
120
- },
121
- legend: hasGroupField ? { color: { position: "top" } } : false,
122
- tooltip: {
123
- items: [
124
- (d) => ({
125
- name: axisYTitle || d.time,
126
- value: d.value
127
- })
128
- ]
129
- },
130
- viewStyle: {
131
- viewFill: backgroundColor
165
+ ...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
166
+ axis: (0, import_util.getCartesianAxis)(cartesianAxisOptions),
167
+ legend: (0, import_util.getColorLegend)(hasGroupField),
168
+ interaction: {
169
+ tooltip: (0, import_util.getSharedTooltipInteraction)({ crosshairs: true }),
170
+ ...hasGroupField ? (0, import_util.getSeriesHighlightByColorInteraction)() : {}
132
171
  },
133
- theme: (0, import_theme.getThemeObject)(theme)
172
+ viewStyle: style.backgroundColor ? { viewFill: backgroundColor } : void 0,
173
+ theme: (0, import_util.getThemeObject)(theme)
134
174
  };
135
175
  chart.options(chartOptions);
176
+ cleanupCrosshairAxisLabels = (0, import_util.bindCrosshairAxisLabels)(chart, theme);
136
177
  chart.render();
178
+ hasRendered = true;
137
179
  };
138
180
  const destroy = () => {
139
181
  if (chart) {
182
+ cleanupCrosshairAxisLabels == null ? void 0 : cleanupCrosshairAxisLabels();
183
+ cleanupCrosshairAxisLabels = null;
140
184
  chart.destroy();
141
185
  chart = null;
142
186
  }
187
+ hasRendered = false;
143
188
  };
144
189
  return {
145
190
  render,
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * BarDataItem is the type for each data item in the bar chart.
4
4
  */
@@ -18,7 +18,7 @@ export interface BarConfig {
18
18
  title?: string;
19
19
  axisXTitle?: string;
20
20
  axisYTitle?: string;
21
- theme?: 'default' | 'academy' | 'dark';
21
+ theme?: VisualizationTheme;
22
22
  style?: {
23
23
  backgroundColor?: string;
24
24
  palette?: string[];
@@ -23,10 +23,11 @@ __export(bar_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(bar_exports);
25
25
  var import_g2 = require("@antv/g2");
26
- var import_theme = require("../../util/theme");
26
+ var import_util = require("../../util");
27
27
  var Bar = (options) => {
28
28
  const { container, width, height, theme: chartTheme = "default" } = options;
29
29
  let chart = null;
30
+ let hasRendered = false;
30
31
  const render = (config) => {
31
32
  var _a;
32
33
  const {
@@ -43,8 +44,7 @@ var Bar = (options) => {
43
44
  chart.destroy();
44
45
  }
45
46
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
46
- const colors = (0, import_theme.normalizePalette)(style.palette, theme);
47
- const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
47
+ const colors = (0, import_util.normalizePalette)(style.palette, theme);
48
48
  chart = new import_g2.Chart({
49
49
  container,
50
50
  width,
@@ -55,7 +55,7 @@ var Bar = (options) => {
55
55
  let transform = [];
56
56
  let radiusStyle = {};
57
57
  if (theme !== "academy") {
58
- radiusStyle = { radiusTopLeft: 4, radiusTopRight: 4 };
58
+ radiusStyle = { radius: 4 };
59
59
  }
60
60
  if (hasGroupField && group) {
61
61
  transform = [{ type: "dodgeX" }];
@@ -66,51 +66,54 @@ var Bar = (options) => {
66
66
  if (hasGroupField) {
67
67
  encode = { x: "category", y: "value", color: "group" };
68
68
  } else {
69
- encode = { x: "category", y: "value", color: "category" };
69
+ encode = { x: "category", y: "value" };
70
70
  }
71
71
  const scaleConfig = {
72
72
  y: { nice: true },
73
- ...style.palette ? { color: { range: colors } } : {}
73
+ ...hasGroupField ? { color: { range: colors } } : {}
74
74
  };
75
75
  const chartOptions = {
76
- animate: false,
76
+ animate: (0, import_util.getChartAnimation)(hasRendered, "growInX"),
77
77
  type: "interval",
78
78
  data,
79
- title: title ?? "",
79
+ title: title || "",
80
80
  encode,
81
81
  transform,
82
82
  coordinate: { transform: [{ type: "transpose" }] },
83
83
  scale: scaleConfig,
84
- axis: {
85
- x: { title: axisXTitle || false },
86
- y: { title: axisYTitle || false }
87
- },
88
- legend: hasGroupField ? { color: { position: "top" } } : false,
84
+ axis: (0, import_util.getCartesianAxis)({ axisXTitle, axisYTitle }),
85
+ legend: (0, import_util.getColorLegend)(hasGroupField),
89
86
  tooltip: {
90
87
  items: [
91
88
  (d) => ({
92
- name: axisYTitle || d.category,
89
+ name: hasGroupField ? d.group : axisYTitle || d.category,
93
90
  value: d.value
94
91
  })
95
92
  ]
96
93
  },
94
+ state: (0, import_util.getCategoryBackgroundHighlightState)(theme),
95
+ interaction: {
96
+ tooltip: true,
97
+ elementHighlight: (0, import_util.getCategoryHighlightInteraction)()
98
+ },
97
99
  style: {
98
100
  ...radiusStyle,
99
- columnWidthRatio: 0.8
100
- },
101
- viewStyle: {
102
- viewFill: backgroundColor
101
+ columnWidthRatio: import_util.CHART_STYLE_DEFAULTS.intervalWidthRatio,
102
+ ...!hasGroupField ? { fill: colors[0] } : {}
103
103
  },
104
- theme: (0, import_theme.getThemeObject)(theme)
104
+ viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
105
+ theme: (0, import_util.getThemeObject)(theme)
105
106
  };
106
107
  chart.options(chartOptions);
107
108
  chart.render();
109
+ hasRendered = true;
108
110
  };
109
111
  const destroy = () => {
110
112
  if (chart) {
111
113
  chart.destroy();
112
114
  chart = null;
113
115
  }
116
+ hasRendered = false;
114
117
  };
115
118
  return {
116
119
  render,
@@ -34,7 +34,6 @@ var Boxplot = (options) => {
34
34
  chart.destroy();
35
35
  }
36
36
  const colors = (0, import_theme.normalizePalette)(style.palette, theme);
37
- const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
38
37
  const startAtZero = style.startAtZero || false;
39
38
  const hasGroupField = ((_a = (data || [])[0]) == null ? void 0 : _a.group) !== void 0;
40
39
  let encode = {};
@@ -86,9 +85,7 @@ var Boxplot = (options) => {
86
85
  legend: {
87
86
  color: hasGroupField ? { position: "top" } : false
88
87
  },
89
- viewStyle: {
90
- viewFill: backgroundColor
91
- },
88
+ viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
92
89
  theme: (0, import_theme.getThemeObject)(theme)
93
90
  };
94
91
  chart.options(chartOptions);
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * ColumnDataItem is the type for each data item in the column chart.
4
4
  */
@@ -18,7 +18,7 @@ export interface ColumnConfig {
18
18
  title?: string;
19
19
  axisXTitle?: string;
20
20
  axisYTitle?: string;
21
- theme?: 'default' | 'academy' | 'dark';
21
+ theme?: VisualizationTheme;
22
22
  style?: {
23
23
  backgroundColor?: string;
24
24
  palette?: string[];
@@ -23,10 +23,11 @@ __export(column_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(column_exports);
25
25
  var import_g2 = require("@antv/g2");
26
- var import_theme = require("../../util/theme");
26
+ var import_util = require("../../util");
27
27
  var Column = (options) => {
28
28
  const { container, width, height, theme: chartTheme = "default" } = options;
29
29
  let chart = null;
30
+ let hasRendered = false;
30
31
  const render = (config) => {
31
32
  var _a;
32
33
  const {
@@ -43,8 +44,7 @@ var Column = (options) => {
43
44
  chart.destroy();
44
45
  }
45
46
  const hasGroupField = data.length > 0 && ((_a = data[0]) == null ? void 0 : _a.group) !== void 0;
46
- const colors = (0, import_theme.normalizePalette)(style.palette, theme);
47
- const backgroundColor = style.backgroundColor || (0, import_theme.getBackgroundColor)(theme);
47
+ const colors = (0, import_util.normalizePalette)(style.palette, theme);
48
48
  chart = new import_g2.Chart({
49
49
  container,
50
50
  width,
@@ -66,50 +66,60 @@ var Column = (options) => {
66
66
  if (hasGroupField) {
67
67
  encode = { x: "category", y: "value", color: "group" };
68
68
  } else {
69
- encode = { x: "category", y: "value", color: "category" };
69
+ encode = { x: "category", y: "value" };
70
70
  }
71
71
  const scaleConfig = {
72
72
  y: { nice: true },
73
- ...style.palette ? { color: { range: colors } } : {}
73
+ ...hasGroupField ? { color: { range: colors } } : {}
74
+ };
75
+ const cartesianAxisOptions = {
76
+ axisXTitle,
77
+ axisYTitle,
78
+ xLabels: data.map(({ category }) => category),
79
+ chartWidth: width
74
80
  };
75
81
  const chartOptions = {
76
- animate: false,
82
+ animate: (0, import_util.getChartAnimation)(hasRendered, "growInY"),
77
83
  type: "interval",
78
84
  data,
79
- title: title ?? "",
85
+ title: title || "",
80
86
  encode,
81
87
  transform,
82
88
  scale: scaleConfig,
83
- axis: {
84
- x: { title: axisXTitle || false },
85
- y: { title: axisYTitle || false }
86
- },
87
- legend: hasGroupField ? { color: { position: "top" } } : false,
89
+ ...(0, import_util.getCartesianLayout)(cartesianAxisOptions),
90
+ axis: (0, import_util.getCartesianAxis)(cartesianAxisOptions),
91
+ legend: (0, import_util.getColorLegend)(hasGroupField),
88
92
  tooltip: {
89
93
  items: [
90
94
  (d) => ({
91
- name: axisYTitle || d.category,
95
+ name: hasGroupField ? d.group : axisYTitle || d.category,
92
96
  value: d.value
93
97
  })
94
98
  ]
95
99
  },
100
+ state: (0, import_util.getCategoryBackgroundHighlightState)(theme),
101
+ interaction: {
102
+ tooltip: true,
103
+ elementHighlight: (0, import_util.getCategoryHighlightInteraction)()
104
+ },
96
105
  style: {
97
106
  ...radiusStyle,
98
- columnWidthRatio: 0.8
99
- },
100
- viewStyle: {
101
- viewFill: backgroundColor
107
+ columnWidthRatio: import_util.CHART_STYLE_DEFAULTS.intervalWidthRatio,
108
+ ...!hasGroupField ? { fill: colors[0] } : {}
102
109
  },
103
- theme: (0, import_theme.getThemeObject)(theme)
110
+ viewStyle: style.backgroundColor ? { viewFill: style.backgroundColor } : void 0,
111
+ theme: (0, import_util.getThemeObject)(theme)
104
112
  };
105
113
  chart.options(chartOptions);
106
114
  chart.render();
115
+ hasRendered = true;
107
116
  };
108
117
  const destroy = () => {
109
118
  if (chart) {
110
119
  chart.destroy();
111
120
  chart = null;
112
121
  }
122
+ hasRendered = false;
113
123
  };
114
124
  return {
115
125
  render,
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * DualAxesSeriesItem defines a single series in the dual-axes chart.
4
4
  */
@@ -16,7 +16,7 @@ export interface DualAxesConfig {
16
16
  series: DualAxesSeriesItem[];
17
17
  title?: string;
18
18
  axisXTitle?: string;
19
- theme?: 'default' | 'academy' | 'dark';
19
+ theme?: VisualizationTheme;
20
20
  style?: {
21
21
  backgroundColor?: string;
22
22
  palette?: string[];