@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
@@ -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[];
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
8
+ import { CHART_STYLE_DEFAULTS, bindCrosshairAxisLabels, getBackgroundColor, getCartesianAxis, getCartesianLayout, getChartAnimation, getColorLegend, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction, getThemeObject, normalizePalette } from "../../util";
9
9
 
10
10
  /**
11
11
  * AreaDataItem is the type for each data item in the area chart.
@@ -20,7 +20,8 @@ import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util
20
20
  */
21
21
 
22
22
  var getLinearGradientColor = function getLinearGradientColor(color) {
23
- return "linear-gradient(-90deg, white 0%, ".concat(color, " 100%)");
23
+ var backgroundColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'white';
24
+ return "linear-gradient(-90deg, ".concat(backgroundColor, " 0%, ").concat(color, " 100%)");
24
25
  };
25
26
  var DEFAULT_COLOR = '#3A95FF';
26
27
 
@@ -57,6 +58,8 @@ export var Area = function Area(options) {
57
58
  _options$theme = options.theme,
58
59
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
59
60
  var chart = null;
61
+ var hasRendered = false;
62
+ var cleanupCrosshairAxisLabels = null;
60
63
 
61
64
  /**
62
65
  * Render the area chart with the given configuration.
@@ -77,14 +80,36 @@ export var Area = function Area(options) {
77
80
 
78
81
  // Clean up previous chart if exists
79
82
  if (chart) {
83
+ var _cleanupCrosshairAxis;
84
+ (_cleanupCrosshairAxis = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis === void 0 || _cleanupCrosshairAxis();
85
+ cleanupCrosshairAxisLabels = null;
80
86
  chart.destroy();
81
87
  }
82
88
  var _style$lineWidth = style.lineWidth,
83
- lineWidth = _style$lineWidth === void 0 ? 2 : _style$lineWidth;
89
+ lineWidth = _style$lineWidth === void 0 ? CHART_STYLE_DEFAULTS.lineWidth : _style$lineWidth;
84
90
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
85
91
  var colors = normalizePalette(style.palette, theme);
86
92
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
87
- var fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR);
93
+ var fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
94
+ var areaOpacity = CHART_STYLE_DEFAULTS.areaOpacity;
95
+ var lineOpacity = CHART_STYLE_DEFAULTS.lineOpacity;
96
+ var cartesianAxisOptions = {
97
+ axisXTitle: axisXTitle,
98
+ axisYTitle: axisYTitle,
99
+ xLabels: data.map(function (_ref) {
100
+ var time = _ref.time;
101
+ return time;
102
+ }),
103
+ chartWidth: width
104
+ };
105
+ var tooltip = {
106
+ items: [function (d) {
107
+ return {
108
+ name: hasGroupField ? d.group : axisYTitle || d.time,
109
+ value: d.value
110
+ };
111
+ }]
112
+ };
88
113
 
89
114
  // Create chart
90
115
  chart = new Chart({
@@ -119,13 +144,13 @@ export var Area = function Area(options) {
119
144
  children = [{
120
145
  type: 'area',
121
146
  style: {
122
- fillOpacity: 0.6
147
+ fillOpacity: areaOpacity
123
148
  }
124
149
  }, {
125
150
  type: 'line',
126
151
  style: {
127
152
  lineWidth: lineWidth,
128
- strokeOpacity: 0.6
153
+ strokeOpacity: lineOpacity
129
154
  }
130
155
  }];
131
156
  } else if (hasGroupField) {
@@ -141,13 +166,13 @@ export var Area = function Area(options) {
141
166
  children = [{
142
167
  type: 'area',
143
168
  style: {
144
- fillOpacity: 0.6
169
+ fillOpacity: areaOpacity
145
170
  }
146
171
  }, {
147
172
  type: 'line',
148
173
  style: {
149
174
  lineWidth: lineWidth,
150
- strokeOpacity: 0.6
175
+ strokeOpacity: lineOpacity
151
176
  }
152
177
  }];
153
178
  } else {
@@ -159,60 +184,81 @@ export var Area = function Area(options) {
159
184
  children = [{
160
185
  type: 'area',
161
186
  style: {
162
- fillOpacity: 0.6,
187
+ fillOpacity: areaOpacity,
163
188
  fill: fillColor
164
189
  }
165
190
  }, {
166
191
  type: 'line',
167
- style: _objectSpread({
192
+ style: {
168
193
  lineWidth: lineWidth,
169
- strokeOpacity: 0.6
170
- }, style.palette ? {
194
+ strokeOpacity: lineOpacity,
195
+ lineCap: 'round',
196
+ lineJoin: 'round',
171
197
  stroke: colors[0]
172
- } : {})
198
+ }
173
199
  }];
174
200
  }
201
+ children = children.map(function (child) {
202
+ return _objectSpread(_objectSpread({}, child), {}, {
203
+ animate: getChartAnimation(hasRendered, child.type === 'line' ? 'pathIn' : 'fadeIn'),
204
+ tooltip: child.type === 'line' ? tooltip : false,
205
+ state: hasGroupField ? child.type === 'area' ? {
206
+ active: {
207
+ fillOpacity: Math.min(areaOpacity + 0.1, 1)
208
+ },
209
+ inactive: {
210
+ fillOpacity: 0.07
211
+ }
212
+ } : getLineHighlightState(lineWidth) : undefined
213
+ });
214
+ });
215
+ if (!hasGroupField && data.length <= 24) {
216
+ children.push({
217
+ type: 'point',
218
+ encode: {
219
+ x: 'time',
220
+ y: 'value',
221
+ shape: 'point',
222
+ size: CHART_STYLE_DEFAULTS.pointSize
223
+ },
224
+ animate: getChartAnimation(hasRendered, 'fadeIn'),
225
+ tooltip: false,
226
+ style: {
227
+ lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
228
+ fill: colors[0],
229
+ stroke: backgroundColor
230
+ }
231
+ });
232
+ }
175
233
 
176
234
  // Configure chart options
177
235
  // Note: Using 'any' type due to G2's complex type system with transformations
178
236
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
179
- var chartOptions = {
180
- animate: false,
237
+ var chartOptions = _objectSpread(_objectSpread({
181
238
  type: 'view',
182
239
  data: data,
183
- title: title !== null && title !== void 0 ? title : '',
240
+ title: title || '',
184
241
  encode: encode,
185
242
  transform: transform,
186
243
  children: children,
187
- scale: scaleConfig,
188
- axis: {
189
- x: {
190
- title: axisXTitle || false
191
- },
192
- y: {
193
- title: axisYTitle || false
194
- }
195
- },
196
- legend: hasGroupField ? {
197
- color: {
198
- position: 'top'
199
- }
200
- } : false,
201
- tooltip: {
202
- items: [function (d) {
203
- return {
204
- name: axisYTitle || d.time,
205
- value: d.value
206
- };
207
- }]
208
- },
209
- viewStyle: {
244
+ scale: scaleConfig
245
+ }, getCartesianLayout(cartesianAxisOptions)), {}, {
246
+ axis: getCartesianAxis(cartesianAxisOptions),
247
+ legend: getColorLegend(hasGroupField),
248
+ interaction: _objectSpread({
249
+ tooltip: getSharedTooltipInteraction({
250
+ crosshairs: true
251
+ })
252
+ }, hasGroupField ? getSeriesHighlightByColorInteraction() : {}),
253
+ viewStyle: style.backgroundColor ? {
210
254
  viewFill: backgroundColor
211
- },
255
+ } : undefined,
212
256
  theme: getThemeObject(theme)
213
- };
257
+ });
214
258
  chart.options(chartOptions);
259
+ cleanupCrosshairAxisLabels = bindCrosshairAxisLabels(chart, theme);
215
260
  chart.render();
261
+ hasRendered = true;
216
262
  };
217
263
 
218
264
  /**
@@ -220,9 +266,13 @@ export var Area = function Area(options) {
220
266
  */
221
267
  var destroy = function destroy() {
222
268
  if (chart) {
269
+ var _cleanupCrosshairAxis2;
270
+ (_cleanupCrosshairAxis2 = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis2 === void 0 || _cleanupCrosshairAxis2();
271
+ cleanupCrosshairAxisLabels = null;
223
272
  chart.destroy();
224
273
  chart = null;
225
274
  }
275
+ hasRendered = false;
226
276
  };
227
277
  return {
228
278
  render: 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[];
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
8
+ import { CHART_STYLE_DEFAULTS, getCartesianAxis, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction, getChartAnimation, getColorLegend, getThemeObject, normalizePalette } from "../../util";
9
9
 
10
10
  /**
11
11
  * BarDataItem is the type for each data item in the bar chart.
@@ -52,6 +52,7 @@ export var Bar = function Bar(options) {
52
52
  _options$theme = options.theme,
53
53
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
54
54
  var chart = null;
55
+ var hasRendered = false;
55
56
 
56
57
  /**
57
58
  * Render the bar chart with the given configuration.
@@ -78,7 +79,6 @@ export var Bar = function Bar(options) {
78
79
  }
79
80
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
80
81
  var colors = normalizePalette(style.palette, theme);
81
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
82
82
 
83
83
  // Create chart
84
84
  chart = new Chart({
@@ -93,11 +93,10 @@ export var Bar = function Bar(options) {
93
93
  var transform = [];
94
94
  var radiusStyle = {};
95
95
 
96
- // academy theme uses no rounded corners; other themes use rounded top corners
96
+ // Academy uses square corners; other themes use a subtle radius on every corner.
97
97
  if (theme !== 'academy') {
98
98
  radiusStyle = {
99
- radiusTopLeft: 4,
100
- radiusTopRight: 4
99
+ radius: 4
101
100
  };
102
101
  }
103
102
 
@@ -123,8 +122,7 @@ export var Bar = function Bar(options) {
123
122
  } else {
124
123
  encode = {
125
124
  x: 'category',
126
- y: 'value',
127
- color: 'category'
125
+ y: 'value'
128
126
  };
129
127
  }
130
128
 
@@ -133,7 +131,7 @@ export var Bar = function Bar(options) {
133
131
  y: {
134
132
  nice: true
135
133
  }
136
- }, style.palette ? {
134
+ }, hasGroupField ? {
137
135
  color: {
138
136
  range: colors
139
137
  }
@@ -143,10 +141,10 @@ export var Bar = function Bar(options) {
143
141
  // Note: Using 'any' type due to G2's complex type system with transformations
144
142
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
145
143
  var chartOptions = {
146
- animate: false,
144
+ animate: getChartAnimation(hasRendered, 'growInX'),
147
145
  type: 'interval',
148
146
  data: data,
149
- title: title !== null && title !== void 0 ? title : '',
147
+ title: title || '',
150
148
  encode: encode,
151
149
  transform: transform,
152
150
  coordinate: {
@@ -155,37 +153,37 @@ export var Bar = function Bar(options) {
155
153
  }]
156
154
  },
157
155
  scale: scaleConfig,
158
- axis: {
159
- x: {
160
- title: axisXTitle || false
161
- },
162
- y: {
163
- title: axisYTitle || false
164
- }
165
- },
166
- legend: hasGroupField ? {
167
- color: {
168
- position: 'top'
169
- }
170
- } : false,
156
+ axis: getCartesianAxis({
157
+ axisXTitle: axisXTitle,
158
+ axisYTitle: axisYTitle
159
+ }),
160
+ legend: getColorLegend(hasGroupField),
171
161
  tooltip: {
172
162
  items: [function (d) {
173
163
  return {
174
- name: axisYTitle || d.category,
164
+ name: hasGroupField ? d.group : axisYTitle || d.category,
175
165
  value: d.value
176
166
  };
177
167
  }]
178
168
  },
179
- style: _objectSpread(_objectSpread({}, radiusStyle), {}, {
180
- columnWidthRatio: 0.8
181
- }),
182
- viewStyle: {
183
- viewFill: backgroundColor
169
+ state: getCategoryBackgroundHighlightState(theme),
170
+ interaction: {
171
+ tooltip: true,
172
+ elementHighlight: getCategoryHighlightInteraction()
184
173
  },
174
+ style: _objectSpread(_objectSpread({}, radiusStyle), {}, {
175
+ columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
176
+ }, !hasGroupField ? {
177
+ fill: colors[0]
178
+ } : {}),
179
+ viewStyle: style.backgroundColor ? {
180
+ viewFill: style.backgroundColor
181
+ } : undefined,
185
182
  theme: getThemeObject(theme)
186
183
  };
187
184
  chart.options(chartOptions);
188
185
  chart.render();
186
+ hasRendered = true;
189
187
  };
190
188
 
191
189
  /**
@@ -196,6 +194,7 @@ export var Bar = function Bar(options) {
196
194
  chart.destroy();
197
195
  chart = null;
198
196
  }
197
+ hasRendered = false;
199
198
  };
200
199
  return {
201
200
  render: render,
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
8
+ import { getThemeObject, normalizePalette } from "../../util/theme";
9
9
 
10
10
  /**
11
11
  * BoxplotDataItem is the type for each data item in the boxplot chart.
@@ -75,7 +75,6 @@ export var Boxplot = function Boxplot(options) {
75
75
 
76
76
  // Get colors from style.palette or theme defaults
77
77
  var colors = normalizePalette(style.palette, theme);
78
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
79
78
  var startAtZero = style.startAtZero || false;
80
79
 
81
80
  // Determine if data has group field for grouped boxplot
@@ -152,9 +151,9 @@ export var Boxplot = function Boxplot(options) {
152
151
  position: 'top'
153
152
  } : false
154
153
  },
155
- viewStyle: {
156
- viewFill: backgroundColor
157
- },
154
+ viewStyle: style.backgroundColor ? {
155
+ viewFill: style.backgroundColor
156
+ } : undefined,
158
157
  theme: getThemeObject(theme)
159
158
  };
160
159
  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[];
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { Chart } from '@antv/g2';
8
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
8
+ import { CHART_STYLE_DEFAULTS, getCartesianAxis, getCartesianLayout, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction, getChartAnimation, getColorLegend, getThemeObject, normalizePalette } from "../../util";
9
9
 
10
10
  /**
11
11
  * ColumnDataItem is the type for each data item in the column chart.
@@ -52,6 +52,7 @@ export var Column = function Column(options) {
52
52
  _options$theme = options.theme,
53
53
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
54
54
  var chart = null;
55
+ var hasRendered = false;
55
56
 
56
57
  /**
57
58
  * Render the column chart with the given configuration.
@@ -78,7 +79,6 @@ export var Column = function Column(options) {
78
79
  }
79
80
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
80
81
  var colors = normalizePalette(style.palette, theme);
81
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
82
82
 
83
83
  // Create chart
84
84
  chart = new Chart({
@@ -123,8 +123,7 @@ export var Column = function Column(options) {
123
123
  } else {
124
124
  encode = {
125
125
  x: 'category',
126
- y: 'value',
127
- color: 'category'
126
+ y: 'value'
128
127
  };
129
128
  }
130
129
 
@@ -133,54 +132,61 @@ export var Column = function Column(options) {
133
132
  y: {
134
133
  nice: true
135
134
  }
136
- }, style.palette ? {
135
+ }, hasGroupField ? {
137
136
  color: {
138
137
  range: colors
139
138
  }
140
139
  } : {});
140
+ var cartesianAxisOptions = {
141
+ axisXTitle: axisXTitle,
142
+ axisYTitle: axisYTitle,
143
+ xLabels: data.map(function (_ref) {
144
+ var category = _ref.category;
145
+ return category;
146
+ }),
147
+ chartWidth: width
148
+ };
141
149
 
142
150
  // Configure chart options
143
151
  // Note: Using 'any' type due to G2's complex type system with transformations
144
152
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
145
- var chartOptions = {
146
- animate: false,
153
+ var chartOptions = _objectSpread(_objectSpread({
154
+ animate: getChartAnimation(hasRendered, 'growInY'),
147
155
  type: 'interval',
148
156
  data: data,
149
- title: title !== null && title !== void 0 ? title : '',
157
+ title: title || '',
150
158
  encode: encode,
151
159
  transform: transform,
152
- scale: scaleConfig,
153
- axis: {
154
- x: {
155
- title: axisXTitle || false
156
- },
157
- y: {
158
- title: axisYTitle || false
159
- }
160
- },
161
- legend: hasGroupField ? {
162
- color: {
163
- position: 'top'
164
- }
165
- } : false,
160
+ scale: scaleConfig
161
+ }, getCartesianLayout(cartesianAxisOptions)), {}, {
162
+ axis: getCartesianAxis(cartesianAxisOptions),
163
+ legend: getColorLegend(hasGroupField),
166
164
  tooltip: {
167
165
  items: [function (d) {
168
166
  return {
169
- name: axisYTitle || d.category,
167
+ name: hasGroupField ? d.group : axisYTitle || d.category,
170
168
  value: d.value
171
169
  };
172
170
  }]
173
171
  },
174
- style: _objectSpread(_objectSpread({}, radiusStyle), {}, {
175
- columnWidthRatio: 0.8
176
- }),
177
- viewStyle: {
178
- viewFill: backgroundColor
172
+ state: getCategoryBackgroundHighlightState(theme),
173
+ interaction: {
174
+ tooltip: true,
175
+ elementHighlight: getCategoryHighlightInteraction()
179
176
  },
177
+ style: _objectSpread(_objectSpread({}, radiusStyle), {}, {
178
+ columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
179
+ }, !hasGroupField ? {
180
+ fill: colors[0]
181
+ } : {}),
182
+ viewStyle: style.backgroundColor ? {
183
+ viewFill: style.backgroundColor
184
+ } : undefined,
180
185
  theme: getThemeObject(theme)
181
- };
186
+ });
182
187
  chart.options(chartOptions);
183
188
  chart.render();
189
+ hasRendered = true;
184
190
  };
185
191
 
186
192
  /**
@@ -191,6 +197,7 @@ export var Column = function Column(options) {
191
197
  chart.destroy();
192
198
  chart = null;
193
199
  }
200
+ hasRendered = false;
194
201
  };
195
202
  return {
196
203
  render: 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[];