@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
@@ -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.
@@ -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, getCartesianLayout, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction, getChartAnimation, getColorLegend, getThemeObject, normalizePalette } from "../../util";
8
+ import { getThemeObject } from "../../theme/g2";
9
+ import { getCartesianAxis, getCartesianLayout, 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
  * ColumnDataItem is the type for each data item in the column chart.
@@ -52,7 +55,6 @@ export var Column = function Column(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 column chart with the given configuration.
@@ -64,6 +66,8 @@ export var Column = function Column(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,34 @@ export var Column = function Column(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 cartesianAxisOptions = {
86
+ axisXTitle: axisXTitle,
87
+ axisYTitle: axisYTitle,
88
+ xLabels: data.map(function (_ref) {
89
+ var category = _ref.category;
90
+ return category;
91
+ }),
92
+ chartWidth: width
93
+ };
94
+ var appearance = getThemeObject('column', theme, localStyle);
95
+ var rendererTheme = appearance.theme;
96
+ var intervalMark = _objectSpread(_objectSpread(_objectSpread({}, rendererTheme.type !== 'academy' && appearance.mark.interval.radius === undefined ? {
97
+ radiusTopLeft: 4,
98
+ radiusTopRight: 4
99
+ } : {}), {}, {
100
+ columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
101
+ }, !hasGroupField ? {
102
+ fill: rendererTheme.category10[0]
103
+ } : {}), appearance.mark.interval);
104
+ var baseTheme = rendererTheme.type;
105
+ var colors = rendererTheme.category10;
82
106
 
83
107
  // Create chart
84
108
  chart = new Chart({
@@ -91,15 +115,6 @@ export var Column = function Column(options) {
91
115
  // Configure chart encode and transform based on group/stack
92
116
  var encode = {};
93
117
  var transform = [];
94
- var radiusStyle = {};
95
-
96
- // academy theme uses no rounded corners; other themes use rounded top corners
97
- if (theme !== 'academy') {
98
- radiusStyle = {
99
- radiusTopLeft: 4,
100
- radiusTopRight: 4
101
- };
102
- }
103
118
 
104
119
  // Configure transforms based on group/stack flags
105
120
  if (hasGroupField && group) {
@@ -137,30 +152,34 @@ export var Column = function Column(options) {
137
152
  range: colors
138
153
  }
139
154
  } : {});
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
- };
149
155
 
150
156
  // Configure chart options
151
157
  // Note: Using 'any' type due to G2's complex type system with transformations
152
158
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
153
159
  var chartOptions = _objectSpread(_objectSpread({
154
- animate: getChartAnimation(hasRendered, 'growInY'),
160
+ // G2 growInY currently computes interval label bounds from the animated
161
+ // clip path, which leaves inside labels at the axis baseline. Keep the
162
+ // interval and its labels in sync until the upstream runtime is fixed.
163
+ animate: false,
155
164
  type: 'interval',
156
165
  data: data,
157
- title: title || '',
166
+ title: title ? {
167
+ title: title,
168
+ subtitle: subtitle
169
+ } : '',
158
170
  encode: encode,
159
171
  transform: transform,
160
172
  scale: scaleConfig
161
173
  }, getCartesianLayout(cartesianAxisOptions)), {}, {
162
174
  axis: getCartesianAxis(cartesianAxisOptions),
163
175
  legend: getColorLegend(hasGroupField),
176
+ labels: getDataLabels(rendererTheme, {
177
+ visible: label,
178
+ defaultVisible: true,
179
+ text: 'value',
180
+ position: 'inside',
181
+ contrast: 'inside'
182
+ }),
164
183
  tooltip: {
165
184
  items: [function (d) {
166
185
  return {
@@ -169,24 +188,16 @@ export var Column = function Column(options) {
169
188
  };
170
189
  }]
171
190
  },
172
- state: getCategoryBackgroundHighlightState(theme),
191
+ state: getCategoryBackgroundHighlightState(baseTheme),
173
192
  interaction: {
174
193
  tooltip: true,
175
194
  elementHighlight: getCategoryHighlightInteraction()
176
195
  },
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,
185
- theme: getThemeObject(theme)
196
+ style: intervalMark,
197
+ theme: rendererTheme
186
198
  });
187
199
  chart.options(chartOptions);
188
200
  chart.render();
189
- hasRendered = true;
190
201
  };
191
202
 
192
203
  /**
@@ -197,7 +208,6 @@ export var Column = function Column(options) {
197
208
  chart.destroy();
198
209
  chart = null;
199
210
  }
200
- hasRendered = false;
201
211
  };
202
212
  return {
203
213
  render: render,
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * DualAxesSeriesItem defines a single series in the dual-axes chart.
4
4
  */
@@ -15,11 +15,10 @@ export interface DualAxesConfig {
15
15
  categories: string[];
16
16
  series: DualAxesSeriesItem[];
17
17
  title?: string;
18
+ subtitle?: string;
18
19
  axisXTitle?: string;
19
20
  theme?: VisualizationTheme;
20
- style?: {
21
- backgroundColor?: string;
22
- palette?: string[];
21
+ style?: ThemeStyle & {
23
22
  startAtZero?: boolean;
24
23
  };
25
24
  }
@@ -4,14 +4,11 @@ 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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
- 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; }
13
7
  import { Chart } from '@antv/g2';
14
- import { CHART_STYLE_DEFAULTS, bindCrosshairAxisLabels, getCartesianAxis, getCartesianLayout, getChartAnimation, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction, getThemeObject, normalizePalette } from "../../util";
8
+ import { getThemeObject } from "../../theme/g2";
9
+ import { bindCrosshairAxisLabels, getCartesianAxis, getCartesianLayout, getChartAnimation, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction } from "../../util";
10
+ import { getColorLegend } from "../../util/components";
11
+ import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
15
12
 
16
13
  /**
17
14
  * DualAxesSeriesItem defines a single series in the dual-axes chart.
@@ -94,9 +91,10 @@ export var DualAxes = function DualAxes(options) {
94
91
  _config$theme = config.theme,
95
92
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
96
93
  title = config.title,
94
+ subtitle = config.subtitle,
97
95
  axisXTitle = config.axisXTitle,
98
96
  _config$style = config.style,
99
- style = _config$style === void 0 ? {} : _config$style;
97
+ localStyle = _config$style === void 0 ? {} : _config$style;
100
98
 
101
99
  // Clean up previous chart if exists
102
100
  if (chart) {
@@ -105,13 +103,31 @@ export var DualAxes = function DualAxes(options) {
105
103
  cleanupCrosshairAxisLabels = null;
106
104
  chart.destroy();
107
105
  }
108
- var _style$startAtZero = style.startAtZero,
109
- startAtZero = _style$startAtZero === void 0 ? false : _style$startAtZero;
110
- var requestedColors = style.palette ? normalizePalette(style.palette, theme) : [];
111
- var defaultColors = normalizePalette(undefined, theme);
112
- var colors = [].concat(_toConsumableArray(requestedColors), _toConsumableArray(defaultColors.filter(function (color) {
113
- return !requestedColors.includes(color);
114
- })));
106
+ var cartesianAxisOptions = {
107
+ axisXTitle: axisXTitle,
108
+ xLabels: categories,
109
+ chartWidth: width
110
+ };
111
+ var cartesianAxis = getCartesianAxis(cartesianAxisOptions);
112
+ var appearance = getThemeObject('dual-axes', theme, localStyle);
113
+ var rendererTheme = appearance.theme;
114
+ var intervalMark = _objectSpread(_objectSpread({
115
+ fillOpacity: 0.86,
116
+ columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
117
+ }, rendererTheme.type !== 'academy' && appearance.mark.interval.radius === undefined ? {
118
+ radiusTopLeft: 4,
119
+ radiusTopRight: 4
120
+ } : {}), appearance.mark.interval);
121
+ var lineMark = _objectSpread({
122
+ shape: 'smooth',
123
+ lineWidth: CHART_STYLE_DEFAULTS.lineWidth,
124
+ lineCap: 'round',
125
+ lineJoin: 'round'
126
+ }, appearance.mark.line);
127
+ var baseTheme = rendererTheme.type;
128
+ var colors = rendererTheme.category10;
129
+ var _localStyle$startAtZe = localStyle.startAtZero,
130
+ startAtZero = _localStyle$startAtZe === void 0 ? false : _localStyle$startAtZe;
115
131
 
116
132
  // Transform data
117
133
  var data = transformData(series, categories);
@@ -153,12 +169,6 @@ export var DualAxes = function DualAxes(options) {
153
169
  displayName: displayName
154
170
  }];
155
171
  }));
156
- var cartesianAxisOptions = {
157
- axisXTitle: axisXTitle,
158
- xLabels: categories,
159
- chartWidth: width
160
- };
161
- var cartesianAxis = getCartesianAxis(cartesianAxisOptions);
162
172
 
163
173
  // Create children configurations for each series
164
174
  var children = seriesMeta.map(function (_ref3) {
@@ -175,6 +185,13 @@ export var DualAxes = function DualAxes(options) {
175
185
  }]
176
186
  };
177
187
  if (item.type === 'column') {
188
+ var axis = {
189
+ y: _objectSpread(_objectSpread({}, cartesianAxis.y), {}, {
190
+ title: item.axisYTitle || false,
191
+ titleFill: color,
192
+ titleFontWeight: 500
193
+ }, rendererTheme.axis)
194
+ };
178
195
  return {
179
196
  type: 'interval',
180
197
  encode: {
@@ -192,30 +209,30 @@ export var DualAxes = function DualAxes(options) {
192
209
  },
193
210
  tooltip: tooltip,
194
211
  axis: {
195
- y: _objectSpread(_objectSpread({}, cartesianAxis.y), {}, {
196
- title: item.axisYTitle || '',
197
- titleFill: color,
198
- titleFontWeight: 500
199
- })
212
+ y: axis.y
200
213
  },
201
214
  style: _objectSpread({
202
- fill: color,
203
- fillOpacity: 0.86,
204
- columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
205
- }, theme !== 'academy' ? {
206
- radiusTopLeft: 4,
207
- radiusTopRight: 4
208
- } : {}),
215
+ fill: color
216
+ }, intervalMark),
209
217
  animate: getChartAnimation(hasRendered, 'growInY')
210
218
  };
211
219
  } else {
220
+ var lineWidth = lineMark.lineWidth;
221
+ var _axis = {
222
+ y: _objectSpread(_objectSpread({}, cartesianAxis.y), {}, {
223
+ title: item.axisYTitle || false,
224
+ position: 'right',
225
+ titleFill: color,
226
+ titleFontWeight: 500,
227
+ grid: false
228
+ }, rendererTheme.axis)
229
+ };
212
230
  // line type
213
231
  return {
214
232
  type: 'line',
215
233
  encode: {
216
234
  x: 'category',
217
235
  y: yField,
218
- shape: 'smooth',
219
236
  color: function color() {
220
237
  return yField;
221
238
  }
@@ -228,25 +245,18 @@ export var DualAxes = function DualAxes(options) {
228
245
  },
229
246
  tooltip: tooltip,
230
247
  axis: {
231
- y: _objectSpread(_objectSpread({}, cartesianAxis.y), {}, {
232
- position: 'right',
233
- title: item.axisYTitle || '',
234
- titleFill: color,
235
- titleFontWeight: 500,
236
- grid: false
237
- })
238
- },
239
- style: {
240
- stroke: color,
241
- lineWidth: CHART_STYLE_DEFAULTS.lineWidth,
242
- lineCap: 'round',
243
- lineJoin: 'round'
248
+ y: _axis.y
244
249
  },
245
- state: getLineHighlightState(CHART_STYLE_DEFAULTS.lineWidth),
250
+ style: _objectSpread({
251
+ stroke: color
252
+ }, lineMark),
253
+ state: getLineHighlightState(lineWidth),
246
254
  animate: getChartAnimation(hasRendered, 'pathIn')
247
255
  };
248
256
  }
249
257
  });
258
+ var xAxis = cartesianAxis.x;
259
+ var legend = getColorLegend(series.length > 0);
250
260
 
251
261
  // Configure chart options
252
262
  // Note: Using 'any' type due to G2's complex type system with transformations
@@ -254,11 +264,14 @@ export var DualAxes = function DualAxes(options) {
254
264
  var chartOptions = _objectSpread(_objectSpread({
255
265
  type: 'view',
256
266
  data: data,
257
- title: title || '',
267
+ title: title ? {
268
+ title: title,
269
+ subtitle: subtitle
270
+ } : '',
258
271
  children: children
259
272
  }, getCartesianLayout(cartesianAxisOptions)), {}, {
260
273
  axis: {
261
- x: cartesianAxis.x
274
+ x: xAxis
262
275
  },
263
276
  scale: {
264
277
  y: {
@@ -275,8 +288,8 @@ export var DualAxes = function DualAxes(options) {
275
288
  })
276
289
  }
277
290
  },
278
- legend: {
279
- color: {
291
+ legend: legend === false ? false : {
292
+ color: _objectSpread(_objectSpread({}, legend.color), {}, {
280
293
  labelFormatter: function labelFormatter(value) {
281
294
  var _seriesByField$get;
282
295
  return ((_seriesByField$get = seriesByField.get(value)) === null || _seriesByField$get === void 0 ? void 0 : _seriesByField$get.displayName) || value;
@@ -285,17 +298,14 @@ export var DualAxes = function DualAxes(options) {
285
298
  var _seriesByField$get2;
286
299
  return ((_seriesByField$get2 = seriesByField.get(value)) === null || _seriesByField$get2 === void 0 ? void 0 : _seriesByField$get2.type) === 'line' ? 'smooth' : 'rect';
287
300
  }
288
- }
301
+ })
289
302
  },
290
303
  interaction: _objectSpread({
291
304
  tooltip: getSharedTooltipInteraction({
292
305
  crosshairs: true
293
306
  })
294
307
  }, getSeriesHighlightByColorInteraction()),
295
- viewStyle: style.backgroundColor ? {
296
- viewFill: style.backgroundColor
297
- } : undefined,
298
- theme: getThemeObject(theme)
308
+ theme: rendererTheme
299
309
  });
300
310
  chart.options(chartOptions);
301
311
  var lineYFields = seriesMeta.filter(function (_ref6) {
@@ -308,7 +318,7 @@ export var DualAxes = function DualAxes(options) {
308
318
  if (lineYFields.length) {
309
319
  var currentChart = chart;
310
320
  var cleanups = lineYFields.map(function (yField, index) {
311
- return bindCrosshairAxisLabels(currentChart, theme, {
321
+ return bindCrosshairAxisLabels(currentChart, baseTheme, {
312
322
  showXLabel: index === 0,
313
323
  useStandaloneYLabel: true,
314
324
  yAxisPosition: 'right',
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  export interface FishboneNode {
3
3
  name: string;
4
4
  children?: FishboneNode[];
@@ -9,16 +9,10 @@ export interface FishboneNode {
9
9
  export interface FishboneDiagramConfig {
10
10
  type?: 'fishbone-diagram';
11
11
  data: FishboneNode;
12
- theme?: 'default' | 'academy' | 'dark';
12
+ theme?: VisualizationTheme;
13
13
  title?: string;
14
- style?: {
15
- /** Custom color palette for branch nodes, overrides theme default */
16
- palette?: string[];
17
- /** Canvas background color, overrides theme default */
18
- backgroundColor?: string;
19
- /** Node rendering style: 'rough' for hand-drawn look, 'default' for smooth */
20
- texture?: 'rough' | 'default';
21
- };
14
+ subtitle?: string;
15
+ style?: ThemeStyle;
22
16
  }
23
17
  /**
24
18
  * FishboneDiagramInstance represents a fishbone diagram instance.