@antv/gpt-vis 1.0.1 → 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 (172) hide show
  1. package/README.md +113 -36
  2. package/README.zh-CN.md +113 -36
  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 +7 -2
  25. package/dist/cjs/util/crosshair-axis-labels.js +144 -30
  26. package/dist/cjs/util/html.d.ts +1 -0
  27. package/dist/cjs/util/html.js +29 -0
  28. package/dist/cjs/util/index.d.ts +0 -2
  29. package/dist/cjs/util/index.js +1 -5
  30. package/dist/cjs/util/interaction.d.ts +4 -3
  31. package/dist/cjs/util/interaction.js +14 -1
  32. package/dist/cjs/util/tokens.d.ts +4 -3
  33. package/dist/cjs/util/tokens.js +13 -10
  34. package/dist/cjs/vis/area/index.d.ts +3 -6
  35. package/dist/cjs/vis/area/index.js +43 -30
  36. package/dist/cjs/vis/bar/index.d.ts +5 -5
  37. package/dist/cjs/vis/bar/index.js +34 -20
  38. package/dist/cjs/vis/boxplot/index.d.ts +4 -5
  39. package/dist/cjs/vis/boxplot/index.js +36 -23
  40. package/dist/cjs/vis/column/index.d.ts +5 -5
  41. package/dist/cjs/vis/column/index.js +38 -26
  42. package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
  43. package/dist/cjs/vis/dual-axes/index.js +87 -51
  44. package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
  45. package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
  46. package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
  47. package/dist/cjs/vis/flow-diagram/index.js +21 -22
  48. package/dist/cjs/vis/funnel/index.d.ts +3 -6
  49. package/dist/cjs/vis/funnel/index.js +77 -58
  50. package/dist/cjs/vis/histogram/index.d.ts +4 -6
  51. package/dist/cjs/vis/histogram/index.js +17 -19
  52. package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
  53. package/dist/cjs/vis/indented-tree/index.js +58 -34
  54. package/dist/cjs/vis/line/index.d.ts +3 -6
  55. package/dist/cjs/vis/line/index.js +43 -22
  56. package/dist/cjs/vis/liquid/index.d.ts +4 -6
  57. package/dist/cjs/vis/liquid/index.js +22 -17
  58. package/dist/cjs/vis/mindmap/index.d.ts +4 -6
  59. package/dist/cjs/vis/mindmap/index.js +43 -25
  60. package/dist/cjs/vis/network-graph/index.d.ts +4 -6
  61. package/dist/cjs/vis/network-graph/index.js +26 -20
  62. package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
  63. package/dist/cjs/vis/organization-chart/index.js +39 -33
  64. package/dist/cjs/vis/pie/index.d.ts +3 -5
  65. package/dist/cjs/vis/pie/index.js +45 -26
  66. package/dist/cjs/vis/radar/index.d.ts +3 -6
  67. package/dist/cjs/vis/radar/index.js +32 -24
  68. package/dist/cjs/vis/sankey/index.d.ts +4 -6
  69. package/dist/cjs/vis/sankey/index.js +17 -7
  70. package/dist/cjs/vis/scatter/index.d.ts +3 -5
  71. package/dist/cjs/vis/scatter/index.js +32 -19
  72. package/dist/cjs/vis/summary/index.js +5 -6
  73. package/dist/cjs/vis/table/index.d.ts +4 -2
  74. package/dist/cjs/vis/table/index.js +56 -8
  75. package/dist/cjs/vis/treemap/index.d.ts +4 -6
  76. package/dist/cjs/vis/treemap/index.js +11 -7
  77. package/dist/cjs/vis/venn/index.d.ts +4 -6
  78. package/dist/cjs/vis/venn/index.js +18 -16
  79. package/dist/cjs/vis/violin/index.d.ts +4 -5
  80. package/dist/cjs/vis/violin/index.js +35 -27
  81. package/dist/cjs/vis/waterfall/index.d.ts +4 -4
  82. package/dist/cjs/vis/waterfall/index.js +48 -39
  83. package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
  84. package/dist/cjs/vis/word-cloud/index.js +18 -12
  85. package/dist/esm/index.d.ts +1 -1
  86. package/dist/esm/theme/g2.d.ts +9 -0
  87. package/dist/esm/theme/g2.js +504 -0
  88. package/dist/esm/theme/g6.d.ts +28 -0
  89. package/dist/esm/theme/g6.js +84 -0
  90. package/dist/esm/theme/merge.d.ts +2 -0
  91. package/dist/esm/theme/merge.js +36 -0
  92. package/dist/esm/theme/resolve.d.ts +7 -0
  93. package/dist/esm/theme/resolve.js +27 -0
  94. package/dist/esm/theme/shared.d.ts +7 -0
  95. package/dist/esm/theme/shared.js +21 -0
  96. package/dist/esm/theme/summary.d.ts +11 -0
  97. package/dist/esm/theme/summary.js +45 -0
  98. package/dist/esm/theme/table.d.ts +13 -0
  99. package/dist/esm/theme/table.js +112 -0
  100. package/dist/esm/types/index.d.ts +8 -5
  101. package/dist/esm/types/theme.d.ts +107 -0
  102. package/dist/esm/types/theme.js +1 -0
  103. package/dist/esm/util/animation.js +12 -2
  104. package/dist/esm/util/components.d.ts +20 -0
  105. package/dist/esm/util/components.js +57 -1
  106. package/dist/esm/util/crosshair-axis-labels.d.ts +7 -2
  107. package/dist/esm/util/crosshair-axis-labels.js +156 -35
  108. package/dist/esm/util/html.d.ts +1 -0
  109. package/dist/esm/util/html.js +3 -0
  110. package/dist/esm/util/index.d.ts +0 -2
  111. package/dist/esm/util/index.js +1 -3
  112. package/dist/esm/util/interaction.d.ts +4 -3
  113. package/dist/esm/util/interaction.js +18 -1
  114. package/dist/esm/util/tokens.d.ts +4 -3
  115. package/dist/esm/util/tokens.js +13 -10
  116. package/dist/esm/vis/area/index.d.ts +3 -6
  117. package/dist/esm/vis/area/index.js +53 -45
  118. package/dist/esm/vis/bar/index.d.ts +5 -5
  119. package/dist/esm/vis/bar/index.js +38 -27
  120. package/dist/esm/vis/boxplot/index.d.ts +4 -5
  121. package/dist/esm/vis/boxplot/index.js +47 -29
  122. package/dist/esm/vis/column/index.d.ts +5 -5
  123. package/dist/esm/vis/column/index.js +46 -36
  124. package/dist/esm/vis/dual-axes/index.d.ts +3 -4
  125. package/dist/esm/vis/dual-axes/index.js +97 -57
  126. package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
  127. package/dist/esm/vis/fishbone-diagram/index.js +52 -27
  128. package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
  129. package/dist/esm/vis/flow-diagram/index.js +28 -23
  130. package/dist/esm/vis/funnel/index.d.ts +3 -6
  131. package/dist/esm/vis/funnel/index.js +78 -68
  132. package/dist/esm/vis/histogram/index.d.ts +4 -6
  133. package/dist/esm/vis/histogram/index.js +28 -21
  134. package/dist/esm/vis/indented-tree/index.d.ts +4 -6
  135. package/dist/esm/vis/indented-tree/index.js +59 -52
  136. package/dist/esm/vis/line/index.d.ts +3 -6
  137. package/dist/esm/vis/line/index.js +44 -32
  138. package/dist/esm/vis/liquid/index.d.ts +4 -6
  139. package/dist/esm/vis/liquid/index.js +28 -21
  140. package/dist/esm/vis/mindmap/index.d.ts +4 -6
  141. package/dist/esm/vis/mindmap/index.js +32 -28
  142. package/dist/esm/vis/network-graph/index.d.ts +4 -6
  143. package/dist/esm/vis/network-graph/index.js +37 -22
  144. package/dist/esm/vis/organization-chart/index.d.ts +4 -6
  145. package/dist/esm/vis/organization-chart/index.js +47 -36
  146. package/dist/esm/vis/pie/index.d.ts +3 -5
  147. package/dist/esm/vis/pie/index.js +42 -26
  148. package/dist/esm/vis/radar/index.d.ts +3 -6
  149. package/dist/esm/vis/radar/index.js +28 -20
  150. package/dist/esm/vis/sankey/index.d.ts +4 -6
  151. package/dist/esm/vis/sankey/index.js +20 -10
  152. package/dist/esm/vis/scatter/index.d.ts +3 -5
  153. package/dist/esm/vis/scatter/index.js +32 -21
  154. package/dist/esm/vis/summary/index.js +5 -7
  155. package/dist/esm/vis/table/index.d.ts +4 -2
  156. package/dist/esm/vis/table/index.js +48 -11
  157. package/dist/esm/vis/treemap/index.d.ts +4 -6
  158. package/dist/esm/vis/treemap/index.js +16 -11
  159. package/dist/esm/vis/venn/index.d.ts +4 -6
  160. package/dist/esm/vis/venn/index.js +24 -16
  161. package/dist/esm/vis/violin/index.d.ts +4 -5
  162. package/dist/esm/vis/violin/index.js +45 -37
  163. package/dist/esm/vis/waterfall/index.d.ts +4 -4
  164. package/dist/esm/vis/waterfall/index.js +46 -36
  165. package/dist/esm/vis/word-cloud/index.d.ts +3 -5
  166. package/dist/esm/vis/word-cloud/index.js +24 -17
  167. package/dist/umd/index.min.js +1 -1
  168. package/package.json +1 -1
  169. package/dist/cjs/util/theme.d.ts +0 -20
  170. package/dist/cjs/util/theme.js +0 -372
  171. package/dist/esm/util/theme.d.ts +0 -20
  172. package/dist/esm/util/theme.js +0 -326
@@ -1,11 +1,17 @@
1
+ var _excluded = ["size"];
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 _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; }
4
+ 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
5
  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
6
  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
7
  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
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
9
  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
10
  import { Chart } from '@antv/g2';
8
- import { CHART_STYLE_DEFAULTS, bindCrosshairAxisLabels, getBackgroundColor, getCartesianAxis, getCartesianLayout, getChartAnimation, getColorLegend, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction, getThemeObject, normalizePalette } from "../../util";
11
+ import { getThemeObject } from "../../theme/g2";
12
+ import { bindCrosshairAxisLabels, getCartesianAxis, getCartesianLayout, getChartAnimation, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction } from "../../util";
13
+ import { getColorLegend } from "../../util/components";
14
+ import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
9
15
 
10
16
  /**
11
17
  * AreaDataItem is the type for each data item in the area chart.
@@ -65,18 +71,19 @@ export var Area = function Area(options) {
65
71
  * Render the area chart with the given configuration.
66
72
  */
67
73
  var render = function render(config) {
68
- var _data$;
74
+ var _data$, _areaMark$fillOpacity;
69
75
  var _config$data = config.data,
70
76
  data = _config$data === void 0 ? [] : _config$data,
71
77
  _config$theme = config.theme,
72
78
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
73
79
  title = config.title,
80
+ subtitle = config.subtitle,
74
81
  axisXTitle = config.axisXTitle,
75
82
  axisYTitle = config.axisYTitle,
76
83
  _config$stack = config.stack,
77
84
  stack = _config$stack === void 0 ? false : _config$stack,
78
85
  _config$style = config.style,
79
- style = _config$style === void 0 ? {} : _config$style;
86
+ localStyle = _config$style === void 0 ? {} : _config$style;
80
87
 
81
88
  // Clean up previous chart if exists
82
89
  if (chart) {
@@ -85,14 +92,7 @@ export var Area = function Area(options) {
85
92
  cleanupCrosshairAxisLabels = null;
86
93
  chart.destroy();
87
94
  }
88
- var _style$lineWidth = style.lineWidth,
89
- lineWidth = _style$lineWidth === void 0 ? CHART_STYLE_DEFAULTS.lineWidth : _style$lineWidth;
90
95
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
91
- var colors = normalizePalette(style.palette, theme);
92
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
93
- var fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
94
- var areaOpacity = CHART_STYLE_DEFAULTS.areaOpacity;
95
- var lineOpacity = CHART_STYLE_DEFAULTS.lineOpacity;
96
96
  var cartesianAxisOptions = {
97
97
  axisXTitle: axisXTitle,
98
98
  axisYTitle: axisYTitle,
@@ -102,6 +102,27 @@ export var Area = function Area(options) {
102
102
  }),
103
103
  chartWidth: width
104
104
  };
105
+ var appearance = getThemeObject('area', theme, localStyle);
106
+ var rendererTheme = appearance.theme;
107
+ var areaMark = _objectSpread({
108
+ fillOpacity: CHART_STYLE_DEFAULTS.areaOpacity
109
+ }, appearance.mark.area);
110
+ var lineMark = _objectSpread({
111
+ lineWidth: CHART_STYLE_DEFAULTS.lineWidth,
112
+ strokeOpacity: CHART_STYLE_DEFAULTS.lineOpacity
113
+ }, appearance.mark.line);
114
+ var pointStyle = _objectSpread({
115
+ shape: 'point',
116
+ size: CHART_STYLE_DEFAULTS.pointSize,
117
+ lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
118
+ stroke: rendererTheme.view.viewFill
119
+ }, appearance.mark.point);
120
+ var baseTheme = rendererTheme.type;
121
+ var lineWidth = lineMark.lineWidth;
122
+ var colors = rendererTheme.category10;
123
+ var backgroundColor = rendererTheme.view.viewFill;
124
+ var fillColor = getLinearGradientColor(colors[0] || DEFAULT_COLOR, backgroundColor);
125
+ var areaOpacity = (_areaMark$fillOpacity = areaMark.fillOpacity) !== null && _areaMark$fillOpacity !== void 0 ? _areaMark$fillOpacity : CHART_STYLE_DEFAULTS.areaOpacity;
105
126
  var tooltip = {
106
127
  items: [function (d) {
107
128
  return {
@@ -143,15 +164,10 @@ export var Area = function Area(options) {
143
164
  };
144
165
  children = [{
145
166
  type: 'area',
146
- style: {
147
- fillOpacity: areaOpacity
148
- }
167
+ style: areaMark
149
168
  }, {
150
169
  type: 'line',
151
- style: {
152
- lineWidth: lineWidth,
153
- strokeOpacity: lineOpacity
154
- }
170
+ style: lineMark
155
171
  }];
156
172
  } else if (hasGroupField) {
157
173
  // Multi-line area chart (not stacked)
@@ -165,15 +181,10 @@ export var Area = function Area(options) {
165
181
  };
166
182
  children = [{
167
183
  type: 'area',
168
- style: {
169
- fillOpacity: areaOpacity
170
- }
184
+ style: areaMark
171
185
  }, {
172
186
  type: 'line',
173
- style: {
174
- lineWidth: lineWidth,
175
- strokeOpacity: lineOpacity
176
- }
187
+ style: lineMark
177
188
  }];
178
189
  } else {
179
190
  // Single area chart
@@ -183,19 +194,17 @@ export var Area = function Area(options) {
183
194
  };
184
195
  children = [{
185
196
  type: 'area',
186
- style: {
187
- fillOpacity: areaOpacity,
197
+ style: _objectSpread(_objectSpread({}, areaMark), {}, {
188
198
  fill: fillColor
189
- }
199
+ })
190
200
  }, {
191
201
  type: 'line',
192
- style: {
193
- lineWidth: lineWidth,
194
- strokeOpacity: lineOpacity,
202
+ style: _objectSpread(_objectSpread({
195
203
  lineCap: 'round',
196
- lineJoin: 'round',
204
+ lineJoin: 'round'
205
+ }, lineMark), {}, {
197
206
  stroke: colors[0]
198
- }
207
+ })
199
208
  }];
200
209
  }
201
210
  children = children.map(function (child) {
@@ -213,21 +222,20 @@ export var Area = function Area(options) {
213
222
  });
214
223
  });
215
224
  if (!hasGroupField && data.length <= 24) {
225
+ var pointSize = pointStyle.size,
226
+ pointMark = _objectWithoutProperties(pointStyle, _excluded);
216
227
  children.push({
217
228
  type: 'point',
218
229
  encode: {
219
230
  x: 'time',
220
231
  y: 'value',
221
- shape: 'point',
222
- size: CHART_STYLE_DEFAULTS.pointSize
232
+ size: pointSize
223
233
  },
224
234
  animate: getChartAnimation(hasRendered, 'fadeIn'),
225
235
  tooltip: false,
226
- style: {
227
- lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
228
- fill: colors[0],
229
- stroke: backgroundColor
230
- }
236
+ style: _objectSpread(_objectSpread({}, pointMark), {}, {
237
+ fill: colors[0]
238
+ })
231
239
  });
232
240
  }
233
241
 
@@ -237,7 +245,10 @@ export var Area = function Area(options) {
237
245
  var chartOptions = _objectSpread(_objectSpread({
238
246
  type: 'view',
239
247
  data: data,
240
- title: title || '',
248
+ title: title ? {
249
+ title: title,
250
+ subtitle: subtitle
251
+ } : '',
241
252
  encode: encode,
242
253
  transform: transform,
243
254
  children: children,
@@ -250,13 +261,10 @@ export var Area = function Area(options) {
250
261
  crosshairs: true
251
262
  })
252
263
  }, hasGroupField ? getSeriesHighlightByColorInteraction() : {}),
253
- viewStyle: style.backgroundColor ? {
254
- viewFill: backgroundColor
255
- } : undefined,
256
- theme: getThemeObject(theme)
264
+ theme: rendererTheme
257
265
  });
258
266
  chart.options(chartOptions);
259
- cleanupCrosshairAxisLabels = bindCrosshairAxisLabels(chart, theme);
267
+ cleanupCrosshairAxisLabels = bindCrosshairAxisLabels(chart, baseTheme);
260
268
  chart.render();
261
269
  hasRendered = true;
262
270
  };
@@ -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.
@@ -5,7 +5,10 @@ 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 { CHART_STYLE_DEFAULTS, getCartesianAxis, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction, getChartAnimation, getColorLegend, getThemeObject, normalizePalette } from "../../util";
8
+ import { getThemeObject } from "../../theme/g2";
9
+ import { getCartesianAxis, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction } from "../../util";
10
+ import { getColorLegend, getDataLabels } from "../../util/components";
11
+ import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
9
12
 
10
13
  /**
11
14
  * BarDataItem is the type for each data item in the bar chart.
@@ -52,7 +55,6 @@ export var Bar = function Bar(options) {
52
55
  _options$theme = options.theme,
53
56
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
54
57
  var chart = null;
55
- var hasRendered = false;
56
58
 
57
59
  /**
58
60
  * Render the bar chart with the given configuration.
@@ -64,6 +66,8 @@ export var Bar = function Bar(options) {
64
66
  _config$theme = config.theme,
65
67
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
66
68
  title = config.title,
69
+ subtitle = config.subtitle,
70
+ label = config.label,
67
71
  axisXTitle = config.axisXTitle,
68
72
  axisYTitle = config.axisYTitle,
69
73
  _config$group = config.group,
@@ -71,14 +75,24 @@ export var Bar = function Bar(options) {
71
75
  _config$stack = config.stack,
72
76
  stack = _config$stack === void 0 ? false : _config$stack,
73
77
  _config$style = config.style,
74
- style = _config$style === void 0 ? {} : _config$style;
78
+ localStyle = _config$style === void 0 ? {} : _config$style;
75
79
 
76
80
  // Clean up previous chart if exists
77
81
  if (chart) {
78
82
  chart.destroy();
79
83
  }
80
84
  var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
81
- var colors = normalizePalette(style.palette, theme);
85
+ var appearance = getThemeObject('bar', theme, localStyle);
86
+ var rendererTheme = appearance.theme;
87
+ var intervalMark = _objectSpread(_objectSpread(_objectSpread({}, rendererTheme.type !== 'academy' ? {
88
+ radius: 4
89
+ } : {}), {}, {
90
+ columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
91
+ }, !hasGroupField ? {
92
+ fill: rendererTheme.category10[0]
93
+ } : {}), appearance.mark.interval);
94
+ var baseTheme = rendererTheme.type;
95
+ var colors = rendererTheme.category10;
82
96
 
83
97
  // Create chart
84
98
  chart = new Chart({
@@ -91,14 +105,6 @@ export var Bar = function Bar(options) {
91
105
  // Configure chart encode and transform based on group/stack
92
106
  var encode = {};
93
107
  var transform = [];
94
- var radiusStyle = {};
95
-
96
- // Academy uses square corners; other themes use a subtle radius on every corner.
97
- if (theme !== 'academy') {
98
- radiusStyle = {
99
- radius: 4
100
- };
101
- }
102
108
 
103
109
  // Configure transforms based on group/stack flags
104
110
  if (hasGroupField && group) {
@@ -136,15 +142,20 @@ export var Bar = function Bar(options) {
136
142
  range: colors
137
143
  }
138
144
  } : {});
139
-
140
145
  // Configure chart options
141
146
  // Note: Using 'any' type due to G2's complex type system with transformations
142
147
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
143
148
  var chartOptions = {
144
- animate: getChartAnimation(hasRendered, 'growInX'),
149
+ // G2 growInX currently computes interval label bounds from the animated
150
+ // clip path, which leaves inside labels at the axis baseline. Keep the
151
+ // interval and its labels in sync until the upstream runtime is fixed.
152
+ animate: false,
145
153
  type: 'interval',
146
154
  data: data,
147
- title: title || '',
155
+ title: title ? {
156
+ title: title,
157
+ subtitle: subtitle
158
+ } : '',
148
159
  encode: encode,
149
160
  transform: transform,
150
161
  coordinate: {
@@ -158,6 +169,15 @@ export var Bar = function Bar(options) {
158
169
  axisYTitle: axisYTitle
159
170
  }),
160
171
  legend: getColorLegend(hasGroupField),
172
+ labels: getDataLabels(rendererTheme, {
173
+ visible: label,
174
+ defaultVisible: true,
175
+ text: 'value',
176
+ position: 'right',
177
+ contrast: 'inside',
178
+ dx: -4,
179
+ dy: 0
180
+ }),
161
181
  tooltip: {
162
182
  items: [function (d) {
163
183
  return {
@@ -166,24 +186,16 @@ export var Bar = function Bar(options) {
166
186
  };
167
187
  }]
168
188
  },
169
- state: getCategoryBackgroundHighlightState(theme),
189
+ state: getCategoryBackgroundHighlightState(baseTheme),
170
190
  interaction: {
171
191
  tooltip: true,
172
192
  elementHighlight: getCategoryHighlightInteraction()
173
193
  },
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,
182
- theme: getThemeObject(theme)
194
+ style: intervalMark,
195
+ theme: rendererTheme
183
196
  };
184
197
  chart.options(chartOptions);
185
198
  chart.render();
186
- hasRendered = true;
187
199
  };
188
200
 
189
201
  /**
@@ -194,7 +206,6 @@ export var Bar = function Bar(options) {
194
206
  chart.destroy();
195
207
  chart = null;
196
208
  }
197
- hasRendered = false;
198
209
  };
199
210
  return {
200
211
  render: render,
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * BoxplotDataItem is the type for each data item in the boxplot chart.
4
4
  */
@@ -13,13 +13,12 @@ export type BoxplotDataItem = {
13
13
  export interface BoxplotConfig {
14
14
  type?: 'boxplot';
15
15
  data: BoxplotDataItem[];
16
- theme?: 'default' | 'academy' | 'dark';
16
+ theme?: VisualizationTheme;
17
17
  title?: string;
18
+ subtitle?: string;
18
19
  axisXTitle?: string;
19
20
  axisYTitle?: string;
20
- style?: {
21
- backgroundColor?: string;
22
- palette?: string[];
21
+ style?: ThemeStyle & {
23
22
  startAtZero?: boolean;
24
23
  };
25
24
  }
@@ -4,8 +4,15 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
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
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
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ 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."); }
9
+ 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); }
10
+ 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; }
11
+ 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; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
13
  import { Chart } from '@antv/g2';
8
- import { getThemeObject, normalizePalette } from "../../util/theme";
14
+ import { getThemeObject } from "../../theme/g2";
15
+ import { getCartesianAxis, getColorLegend } from "../../util/components";
9
16
 
10
17
  /**
11
18
  * BoxplotDataItem is the type for each data item in the boxplot chart.
@@ -19,6 +26,15 @@ import { getThemeObject, normalizePalette } from "../../util/theme";
19
26
  * BoxplotInstance represents a boxplot chart instance with render and destroy.
20
27
  */
21
28
 
29
+ var prefixMarkStyle = function prefixMarkStyle(prefix, style) {
30
+ return Object.fromEntries(Object.entries(style !== null && style !== void 0 ? style : {}).map(function (_ref) {
31
+ var _ref2 = _slicedToArray(_ref, 2),
32
+ key = _ref2[0],
33
+ value = _ref2[1];
34
+ return ["".concat(prefix).concat(key.charAt(0).toUpperCase()).concat(key.slice(1)), value];
35
+ }));
36
+ };
37
+
22
38
  /**
23
39
  * Boxplot chart component using G2 5.0.
24
40
  *
@@ -63,10 +79,11 @@ export var Boxplot = function Boxplot(options) {
63
79
  _config$theme = config.theme,
64
80
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
65
81
  title = config.title,
82
+ subtitle = config.subtitle,
66
83
  axisXTitle = config.axisXTitle,
67
84
  axisYTitle = config.axisYTitle,
68
85
  _config$style = config.style,
69
- style = _config$style === void 0 ? {} : _config$style;
86
+ localStyle = _config$style === void 0 ? {} : _config$style;
70
87
 
71
88
  // Clean up previous chart if exists
72
89
  if (chart) {
@@ -74,11 +91,11 @@ export var Boxplot = function Boxplot(options) {
74
91
  }
75
92
 
76
93
  // Get colors from style.palette or theme defaults
77
- var colors = normalizePalette(style.palette, theme);
78
- var startAtZero = style.startAtZero || false;
79
-
80
- // Determine if data has group field for grouped boxplot
81
94
  var hasGroupField = ((_ = (data || [])[0]) === null || _ === void 0 ? void 0 : _.group) !== undefined;
95
+ var appearance = getThemeObject('boxplot', theme, localStyle);
96
+ var rendererTheme = appearance.theme;
97
+ var colors = rendererTheme.category10;
98
+ var startAtZero = localStyle.startAtZero || false;
82
99
  var encode = {};
83
100
  if (hasGroupField) {
84
101
  encode = {
@@ -94,6 +111,13 @@ export var Boxplot = function Boxplot(options) {
94
111
  color: 'category'
95
112
  };
96
113
  }
114
+ var showPoints = !hasGroupField;
115
+ var boxStyle = appearance.mark.box;
116
+ var resolvedPointStyle = appearance.mark.point;
117
+ var markStyle = showPoints ? _objectSpread(_objectSpread({}, prefixMarkStyle('box', boxStyle)), prefixMarkStyle('point', resolvedPointStyle)) : _objectSpread(_objectSpread({}, boxStyle), {}, {
118
+ point: false
119
+ });
120
+ var legend = getColorLegend(hasGroupField);
97
121
 
98
122
  // Create chart
99
123
  chart = new Chart({
@@ -110,16 +134,15 @@ export var Boxplot = function Boxplot(options) {
110
134
  animate: false,
111
135
  type: 'boxplot',
112
136
  data: data,
113
- title: title !== null && title !== void 0 ? title : '',
137
+ title: title ? {
138
+ title: title,
139
+ subtitle: subtitle
140
+ } : '',
114
141
  encode: encode,
115
- axis: {
116
- x: {
117
- title: axisXTitle || false
118
- },
119
- y: {
120
- title: axisYTitle || false
121
- }
122
- },
142
+ axis: getCartesianAxis({
143
+ axisXTitle: axisXTitle,
144
+ axisYTitle: axisYTitle
145
+ }),
123
146
  scale: {
124
147
  x: {
125
148
  paddingInner: 0.6,
@@ -137,24 +160,19 @@ export var Boxplot = function Boxplot(options) {
137
160
  range: colors
138
161
  }
139
162
  },
140
- // When hasGroupField is true, set point to false to prevent G2's Boxplot composite mark
141
- // from splitting into box + point child marks. The point child mark does not inherit
142
- // the `scale` config, causing legendFilter interaction to throw
143
- // "Cannot read properties of undefined (reading 'color')" when clicking legend items.
163
+ // Grouped boxplots keep outliers disabled because G2's point child does
164
+ // not inherit the composite color scale used by legend filtering.
144
165
  style: _objectSpread({
145
166
  stroke: 'black'
146
- }, hasGroupField ? {
147
- point: false
148
- } : {}),
149
- legend: {
150
- color: hasGroupField ? {
167
+ }, markStyle),
168
+ legend: legend === false ? {
169
+ color: false
170
+ } : {
171
+ color: _objectSpread({
151
172
  position: 'top'
152
- } : false
173
+ }, legend.color)
153
174
  },
154
- viewStyle: style.backgroundColor ? {
155
- viewFill: style.backgroundColor
156
- } : undefined,
157
- theme: getThemeObject(theme)
175
+ theme: rendererTheme
158
176
  };
159
177
  chart.options(chartOptions);
160
178
  chart.render();
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * ColumnDataItem is the type for each data item in the column chart.
4
4
  */
@@ -16,13 +16,13 @@ export interface ColumnConfig {
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
  * ColumnInstance represents a column chart instance with render and destroy methods.