@antv/gpt-vis 1.0.0-beta.2 → 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 (106) hide show
  1. package/README.md +282 -43
  2. package/README.zh-CN.md +286 -47
  3. package/dist/cjs/gpt-vis/index.js +1 -1
  4. package/dist/cjs/types/index.d.ts +2 -1
  5. package/dist/cjs/util/animation.d.ts +2 -0
  6. package/dist/cjs/util/animation.js +38 -0
  7. package/dist/cjs/util/components.d.ts +15 -0
  8. package/dist/cjs/util/components.js +94 -0
  9. package/dist/cjs/util/crosshair-axis-labels.d.ts +9 -0
  10. package/dist/cjs/util/crosshair-axis-labels.js +304 -0
  11. package/dist/cjs/util/index.d.ts +6 -0
  12. package/dist/cjs/util/index.js +33 -0
  13. package/dist/cjs/util/interaction.d.ts +14 -0
  14. package/dist/cjs/util/interaction.js +89 -0
  15. package/dist/cjs/util/theme.d.ts +18 -24
  16. package/dist/cjs/util/theme.js +303 -120
  17. package/dist/cjs/util/tokens.d.ts +31 -0
  18. package/dist/cjs/util/tokens.js +98 -0
  19. package/dist/cjs/vis/area/index.d.ts +2 -2
  20. package/dist/cjs/vis/area/index.js +76 -31
  21. package/dist/cjs/vis/bar/index.d.ts +2 -2
  22. package/dist/cjs/vis/bar/index.js +22 -19
  23. package/dist/cjs/vis/boxplot/index.js +1 -4
  24. package/dist/cjs/vis/column/index.d.ts +2 -2
  25. package/dist/cjs/vis/column/index.js +28 -18
  26. package/dist/cjs/vis/dual-axes/index.d.ts +2 -2
  27. package/dist/cjs/vis/dual-axes/index.js +90 -36
  28. package/dist/cjs/vis/fishbone-diagram/index.js +12 -4
  29. package/dist/cjs/vis/flow-diagram/index.js +27 -11
  30. package/dist/cjs/vis/funnel/index.d.ts +4 -2
  31. package/dist/cjs/vis/funnel/index.js +171 -92
  32. package/dist/cjs/vis/histogram/index.js +1 -4
  33. package/dist/cjs/vis/indented-tree/index.js +13 -3
  34. package/dist/cjs/vis/line/index.d.ts +2 -2
  35. package/dist/cjs/vis/line/index.js +71 -31
  36. package/dist/cjs/vis/liquid/index.d.ts +2 -2
  37. package/dist/cjs/vis/liquid/index.js +41 -16
  38. package/dist/cjs/vis/mindmap/index.js +12 -4
  39. package/dist/cjs/vis/network-graph/index.js +11 -2
  40. package/dist/cjs/vis/organization-chart/index.js +12 -3
  41. package/dist/cjs/vis/pie/index.d.ts +2 -2
  42. package/dist/cjs/vis/pie/index.js +26 -16
  43. package/dist/cjs/vis/radar/index.d.ts +2 -2
  44. package/dist/cjs/vis/radar/index.js +21 -29
  45. package/dist/cjs/vis/sankey/index.js +1 -4
  46. package/dist/cjs/vis/scatter/index.d.ts +4 -2
  47. package/dist/cjs/vis/scatter/index.js +43 -16
  48. package/dist/cjs/vis/treemap/index.js +1 -4
  49. package/dist/cjs/vis/venn/index.js +1 -4
  50. package/dist/cjs/vis/violin/index.js +1 -1
  51. package/dist/cjs/vis/waterfall/index.js +2 -2
  52. package/dist/cjs/vis/word-cloud/index.d.ts +3 -2
  53. package/dist/cjs/vis/word-cloud/index.js +125 -10
  54. package/dist/esm/gpt-vis/index.js +1 -1
  55. package/dist/esm/types/index.d.ts +2 -1
  56. package/dist/esm/util/animation.d.ts +2 -0
  57. package/dist/esm/util/animation.js +17 -0
  58. package/dist/esm/util/components.d.ts +15 -0
  59. package/dist/esm/util/components.js +67 -0
  60. package/dist/esm/util/crosshair-axis-labels.d.ts +9 -0
  61. package/dist/esm/util/crosshair-axis-labels.js +328 -0
  62. package/dist/esm/util/index.d.ts +6 -0
  63. package/dist/esm/util/index.js +6 -0
  64. package/dist/esm/util/interaction.d.ts +14 -0
  65. package/dist/esm/util/interaction.js +73 -0
  66. package/dist/esm/util/theme.d.ts +18 -24
  67. package/dist/esm/util/theme.js +302 -126
  68. package/dist/esm/util/tokens.d.ts +31 -0
  69. package/dist/esm/util/tokens.js +64 -0
  70. package/dist/esm/vis/area/index.d.ts +2 -2
  71. package/dist/esm/vis/area/index.js +91 -41
  72. package/dist/esm/vis/bar/index.d.ts +2 -2
  73. package/dist/esm/vis/bar/index.js +28 -29
  74. package/dist/esm/vis/boxplot/index.js +4 -5
  75. package/dist/esm/vis/column/index.d.ts +2 -2
  76. package/dist/esm/vis/column/index.js +36 -29
  77. package/dist/esm/vis/dual-axes/index.d.ts +2 -2
  78. package/dist/esm/vis/dual-axes/index.js +123 -43
  79. package/dist/esm/vis/fishbone-diagram/index.js +6 -5
  80. package/dist/esm/vis/flow-diagram/index.js +17 -10
  81. package/dist/esm/vis/funnel/index.d.ts +4 -2
  82. package/dist/esm/vis/funnel/index.js +156 -83
  83. package/dist/esm/vis/histogram/index.js +4 -5
  84. package/dist/esm/vis/indented-tree/index.js +9 -4
  85. package/dist/esm/vis/line/index.d.ts +2 -2
  86. package/dist/esm/vis/line/index.js +80 -37
  87. package/dist/esm/vis/liquid/index.d.ts +2 -2
  88. package/dist/esm/vis/liquid/index.js +41 -14
  89. package/dist/esm/vis/mindmap/index.js +6 -5
  90. package/dist/esm/vis/network-graph/index.js +5 -3
  91. package/dist/esm/vis/organization-chart/index.js +6 -4
  92. package/dist/esm/vis/pie/index.d.ts +2 -2
  93. package/dist/esm/vis/pie/index.js +36 -16
  94. package/dist/esm/vis/radar/index.d.ts +2 -2
  95. package/dist/esm/vis/radar/index.js +21 -34
  96. package/dist/esm/vis/sankey/index.js +4 -5
  97. package/dist/esm/vis/scatter/index.d.ts +4 -2
  98. package/dist/esm/vis/scatter/index.js +45 -19
  99. package/dist/esm/vis/treemap/index.js +4 -5
  100. package/dist/esm/vis/venn/index.js +4 -5
  101. package/dist/esm/vis/violin/index.js +5 -13
  102. package/dist/esm/vis/waterfall/index.js +11 -11
  103. package/dist/esm/vis/word-cloud/index.d.ts +3 -2
  104. package/dist/esm/vis/word-cloud/index.js +158 -10
  105. package/dist/umd/index.min.js +1 -1
  106. package/package.json +18 -19
@@ -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_FONT_FAMILY, getBackgroundColor, getChartVisualTokens, getThemeObject, normalizePalette } from "../../util";
9
9
 
10
10
  // Default dimensions used for font size calculation when not explicitly provided
11
11
  var DEFAULT_WIDTH = 640;
@@ -69,11 +69,19 @@ export var Liquid = function Liquid(options) {
69
69
  // Get colors from style.palette or theme defaults
70
70
  var colors = normalizePalette(style.palette, theme);
71
71
  var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
72
+ var tokens = getChartVisualTokens(theme);
73
+ var normalizedPercent = Number.isFinite(percent) ? Math.max(0, Math.min(1, percent)) : 0;
72
74
 
73
75
  // Calculate dynamic font size based on chart dimensions
74
76
  // Use default dimensions for font size calculation when not provided
75
77
  var inferFontSize = Math.min(width !== null && width !== void 0 ? width : DEFAULT_WIDTH, height !== null && height !== void 0 ? height : DEFAULT_HEIGHT) / 10;
76
78
  var fontSize = Math.min(Math.max(inferFontSize, 24), 64);
79
+ var chartSize = Math.min(width !== null && width !== void 0 ? width : DEFAULT_WIDTH, height !== null && height !== void 0 ? height : DEFAULT_HEIGHT);
80
+ var waveLength = Math.min(Math.max(chartSize * 0.4, 96), 192);
81
+ var formattedPercent = "".concat(Number((normalizedPercent * 100).toFixed(1)), "%");
82
+ var liquidColor = colors[0];
83
+ var isAcademy = theme === 'academy';
84
+ var outlineShadowColor = theme === 'dark' ? 'rgba(0, 0, 0, 0.32)' : 'rgba(15, 23, 42, 0.10)';
77
85
 
78
86
  // Create chart
79
87
  chart = new Chart({
@@ -89,25 +97,44 @@ export var Liquid = function Liquid(options) {
89
97
  var chartOptions = {
90
98
  animate: false,
91
99
  type: 'liquid',
92
- data: percent,
93
- title: title !== null && title !== void 0 ? title : '',
100
+ data: normalizedPercent,
101
+ title: title || '',
102
+ inset: 20,
94
103
  style: _objectSpread({
95
104
  shape: shape,
105
+ contentText: formattedPercent,
96
106
  contentFontSize: fontSize,
97
- contentFill: '#000',
98
- contentStroke: '#fff',
99
- contentLineWidth: 2,
100
- outlineBorder: 4,
101
- outlineDistance: 4,
102
- waveLength: 128,
107
+ contentFill: tokens.textPrimary,
108
+ contentStroke: backgroundColor,
109
+ contentStrokeOpacity: 0.92,
110
+ contentLineWidth: theme === 'dark' ? 3 : 2.5,
111
+ contentFontFamily: CHART_FONT_FAMILY,
112
+ contentFontWeight: 600,
113
+ contentLetterSpacing: -0.8,
114
+ contentFontVariantNumeric: 'tabular-nums',
115
+ contentPaintOrder: 'stroke',
116
+ backgroundFill: liquidColor,
117
+ backgroundFillOpacity: theme === 'dark' ? 0.14 : isAcademy ? 0.06 : 0.08,
118
+ backgroundStroke: liquidColor,
119
+ backgroundStrokeOpacity: theme === 'dark' ? 0.3 : 0.22,
120
+ backgroundLineWidth: 1,
121
+ outlineBorder: isAcademy ? 1.5 : 2,
122
+ outlineDistance: 0,
123
+ outlineStrokeOpacity: isAcademy ? 0.9 : 0.72,
124
+ outlineShadowColor: isAcademy ? 'transparent' : outlineShadowColor,
125
+ outlineShadowBlur: isAcademy ? 0 : 6,
126
+ outlineShadowOffsetY: isAcademy ? 0 : 2,
127
+ waveLength: waveLength,
128
+ waveCount: 2,
129
+ fillOpacity: isAcademy ? 0.9 : 0.88,
103
130
  contentPointerEvents: 'none'
104
- }, colors[0] ? {
105
- fill: colors[0],
106
- outlineStroke: colors[0]
131
+ }, liquidColor ? {
132
+ fill: liquidColor,
133
+ outlineStroke: liquidColor
107
134
  } : {}),
108
- viewStyle: {
135
+ viewStyle: style.backgroundColor ? {
109
136
  viewFill: backgroundColor
110
- },
137
+ } : undefined,
111
138
  theme: getThemeObject(theme),
112
139
  tooltip: false
113
140
  };
@@ -15,7 +15,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
15
15
  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; }
16
16
  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; }
17
17
  import { Graph, idOf, positionOf, treeToGraphData } from '@antv/g6';
18
- import { getBackgroundColor, normalizePalette } from "../../util/theme";
18
+ import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
19
19
 
20
20
  /**
21
21
  * MindmapConfig defines the configuration for rendering the mindmap.
@@ -179,16 +179,17 @@ export var Mindmap = function Mindmap(options) {
179
179
  height: height,
180
180
  autoFit: 'view',
181
181
  autoResize: true,
182
- padding: 20,
182
+ padding: title ? [46, 20, 20, 20] : 20,
183
183
  zoomRange: [0.1, 5],
184
184
  zoom: 1,
185
- theme: chartTheme,
185
+ theme: getTheme(theme),
186
186
  data: graphData,
187
187
  plugins: title ? [{
188
188
  key: 'title',
189
189
  type: 'title',
190
190
  title: title,
191
- titleFill: isDark ? '#e0e6ed' : '#1a1a2e'
191
+ titleFill: isDark ? '#e0e6ed' : '#000',
192
+ titleFontFamily: 'sans-serif'
192
193
  }] : [],
193
194
  node: {
194
195
  type: 'rect',
@@ -219,7 +220,7 @@ export var Mindmap = function Mindmap(options) {
219
220
  var base = {
220
221
  size: [nodeWidth, nodeHeight],
221
222
  dx: dx,
222
- radius: 8,
223
+ radius: theme === 'academy' ? 0 : 8,
223
224
  labelText: label,
224
225
  labelPlacement: 'center',
225
226
  labelFontSize: fontSize,
@@ -1,5 +1,5 @@
1
1
  import { Graph } from '@antv/g6';
2
- import { getBackgroundColor, normalizePalette } from "../../util/theme";
2
+ import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
3
3
 
4
4
  /**
5
5
  * NetworkGraphConfig defines the configuration for rendering the network graph.
@@ -180,7 +180,8 @@ export var NetworkGraph = function NetworkGraph(options) {
180
180
  height: height,
181
181
  autoFit: 'view',
182
182
  autoResize: true,
183
- padding: 24,
183
+ theme: getTheme(theme),
184
+ padding: title ? [46, 20, 20, 20] : 20,
184
185
  data: {
185
186
  nodes: nodeData,
186
187
  edges: edgeData
@@ -197,7 +198,8 @@ export var NetworkGraph = function NetworkGraph(options) {
197
198
  key: 'title',
198
199
  type: 'title',
199
200
  title: title,
200
- titleFill: isDark ? '#e0e6ed' : '#1a1a2e'
201
+ titleFill: isDark ? '#e0e6ed' : '#000',
202
+ titleFontFamily: 'sans-serif'
201
203
  }] : []
202
204
  });
203
205
  graph.render();
@@ -5,7 +5,7 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
5
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
6
  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; }
7
7
  import { Graph } from '@antv/g6';
8
- import { getBackgroundColor, normalizePalette } from "../../util/theme";
8
+ import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme";
9
9
 
10
10
  /**
11
11
  * OrganizationChartConfig defines the configuration for rendering the organization chart.
@@ -153,7 +153,8 @@ export var OrganizationChart = function OrganizationChart(options) {
153
153
  height: height,
154
154
  autoFit: 'view',
155
155
  autoResize: true,
156
- padding: 24,
156
+ theme: getTheme(theme),
157
+ padding: title ? [46, 20, 20, 20] : 20,
157
158
  data: {
158
159
  nodes: nodeData,
159
160
  edges: edgeData
@@ -189,7 +190,8 @@ export var OrganizationChart = function OrganizationChart(options) {
189
190
  key: 'title',
190
191
  type: 'title',
191
192
  title: title,
192
- titleFill: isDark ? '#e0e6ed' : '#1a1a2e'
193
+ titleFill: isDark ? '#e0e6ed' : '#000',
194
+ titleFontFamily: 'sans-serif'
193
195
  }] : [])),
194
196
  node: {
195
197
  type: 'rect',
@@ -203,7 +205,7 @@ export var OrganizationChart = function OrganizationChart(options) {
203
205
  },
204
206
  stroke: isDark ? '#555' : '#e8ebf0',
205
207
  lineWidth: 1,
206
- radius: 8,
208
+ radius: theme === 'academy' ? 0 : 8,
207
209
  // Use official label wrapping/ellipsis for BOTH name & description.
208
210
  // 1 line name + up to 2 lines description => total maxLines = 3.
209
211
  labelText: function labelText(d) {
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * PieDataItem is the type for each data item in the pie chart.
4
4
  */
@@ -13,7 +13,7 @@ export interface PieConfig {
13
13
  type?: 'pie';
14
14
  data: PieDataItem[];
15
15
  innerRadius?: number;
16
- theme?: 'default' | 'academy' | 'dark';
16
+ theme?: VisualizationTheme;
17
17
  title?: string;
18
18
  style?: {
19
19
  backgroundColor?: string;
@@ -1,5 +1,5 @@
1
1
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
2
+ import { getChartAnimation, getChartVisualTokens, getColorLegend, getThemeObject, normalizePalette } from "../../util";
3
3
 
4
4
  /**
5
5
  * PieDataItem is the type for each data item in the pie chart.
@@ -44,6 +44,7 @@ export var Pie = function Pie(options) {
44
44
  _options$theme = options.theme,
45
45
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
46
46
  var chart = null;
47
+ var hasRendered = false;
47
48
 
48
49
  // Precision multiplier for rounding percentages to 4 decimal places
49
50
  var PERCENTAGE_PRECISION_MULTIPLIER = 10000;
@@ -69,7 +70,7 @@ export var Pie = function Pie(options) {
69
70
 
70
71
  // Get colors from style.palette or theme defaults
71
72
  var colors = normalizePalette(style.palette, theme);
72
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
73
+ var tokens = getChartVisualTokens(theme);
73
74
 
74
75
  // Calculate sum for percentage labels
75
76
  var sumValue = data.reduce(function (sum, item) {
@@ -88,10 +89,10 @@ export var Pie = function Pie(options) {
88
89
  // Note: Using 'any' type due to G2's complex type system with transformations
89
90
  // This is consistent with how G2 5.0 is used elsewhere in the codebase (e.g., Radar component)
90
91
  var chartOptions = {
91
- animate: false,
92
+ animate: getChartAnimation(hasRendered, 'waveIn'),
92
93
  type: 'interval',
93
94
  data: data,
94
- title: title !== null && title !== void 0 ? title : '',
95
+ title: title || '',
95
96
  encode: {
96
97
  y: 'value',
97
98
  color: 'category'
@@ -108,15 +109,12 @@ export var Pie = function Pie(options) {
108
109
  range: colors
109
110
  }
110
111
  },
111
- legend: {
112
- color: {
113
- position: 'top'
114
- }
115
- },
116
- labels: [{
112
+ legend: getColorLegend(true),
113
+ labels: data.length > 8 ? [] : [{
117
114
  text: function text(d) {
118
- var percentage = Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER;
119
- return "".concat(d.category, ": ").concat(percentage, "%");
115
+ var percentage = sumValue ? Math.round(d.value / sumValue * 100 * PERCENTAGE_PRECISION_MULTIPLIER) / PERCENTAGE_PRECISION_MULTIPLIER : 0;
116
+ var formattedPercentage = Number(percentage.toFixed(1)).toString();
117
+ return "".concat(d.category, ": ").concat(formattedPercentage, "%");
120
118
  },
121
119
  position: 'outside',
122
120
  transform: [{
@@ -132,20 +130,41 @@ export var Pie = function Pie(options) {
132
130
  }]
133
131
  },
134
132
  interaction: {
133
+ tooltip: true,
134
+ elementHighlight: true,
135
+ elementHoverScale: {
136
+ shadow: false
137
+ },
135
138
  elementSelect: {
136
139
  single: true
137
140
  }
138
141
  },
139
- style: {
140
- fillOpacity: 0.8
142
+ state: {
143
+ active: {
144
+ fillOpacity: 1,
145
+ lineWidth: 3
146
+ },
147
+ inactive: {
148
+ fillOpacity: 0.3
149
+ },
150
+ selected: {
151
+ fillOpacity: 1,
152
+ lineWidth: 3
153
+ }
141
154
  },
142
- viewStyle: {
143
- viewFill: backgroundColor
155
+ style: {
156
+ fillOpacity: 1,
157
+ stroke: tokens.separator,
158
+ lineWidth: 2
144
159
  },
160
+ viewStyle: style.backgroundColor ? {
161
+ viewFill: style.backgroundColor
162
+ } : undefined,
145
163
  theme: getThemeObject(theme)
146
164
  };
147
165
  chart.options(chartOptions);
148
166
  chart.render();
167
+ hasRendered = true;
149
168
  };
150
169
 
151
170
  /**
@@ -156,6 +175,7 @@ export var Pie = function Pie(options) {
156
175
  chart.destroy();
157
176
  chart = null;
158
177
  }
178
+ hasRendered = false;
159
179
  };
160
180
  return {
161
181
  render: render,
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * RadarDataItem is the type for each data item in the radar chart.
4
4
  */
@@ -15,7 +15,7 @@ export interface RadarConfig {
15
15
  data: RadarDataItem[];
16
16
  title?: string;
17
17
  align?: boolean;
18
- theme?: 'default' | 'academy' | 'dark';
18
+ theme?: VisualizationTheme;
19
19
  style?: {
20
20
  backgroundColor?: string;
21
21
  palette?: string[];
@@ -15,7 +15,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
15
15
  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; } }
16
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  import { Chart } from '@antv/g2';
18
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
18
+ import { CHART_STYLE_DEFAULTS, getColorLegend, getLineHighlightState, getSeriesHighlightByColorInteraction, getThemeObject, normalizePalette } from "../../util";
19
19
 
20
20
  /**
21
21
  * RadarDataItem is the type for each data item in the radar chart.
@@ -118,15 +118,16 @@ export var Radar = function Radar(options) {
118
118
  chart.destroy();
119
119
  }
120
120
  var _style$lineWidth = style.lineWidth,
121
- lineWidth = _style$lineWidth === void 0 ? 2 : _style$lineWidth;
121
+ lineWidth = _style$lineWidth === void 0 ? CHART_STYLE_DEFAULTS.lineWidth : _style$lineWidth;
122
122
  var colors = normalizePalette(style.palette, theme);
123
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
124
123
 
125
124
  // Transform data to parallel format
126
125
  var parallelData = transformRadarToParallel(data);
127
126
  var position = Object.keys(parallelData[0] || {}).filter(function (key) {
128
127
  return key !== 'group';
129
128
  });
129
+ var hasMultipleSeries = parallelData.length > 1;
130
+ var legend = getColorLegend(hasMultipleSeries);
130
131
 
131
132
  // Create chart
132
133
  chart = new Chart({
@@ -143,11 +144,11 @@ export var Radar = function Radar(options) {
143
144
  animate: false,
144
145
  type: 'line',
145
146
  data: parallelData,
146
- title: title !== null && title !== void 0 ? title : '',
147
+ title: title || '',
147
148
  coordinate: {
148
149
  type: 'radar'
149
150
  },
150
- inset: 18,
151
+ inset: 24,
151
152
  encode: {
152
153
  position: position,
153
154
  color: 'group'
@@ -177,45 +178,31 @@ export var Radar = function Radar(options) {
177
178
  length: position.length
178
179
  }, function (_, i) {
179
180
  return ["position".concat(i === 0 ? '' : i), {
180
- zIndex: 1,
181
- titleFontSize: 10,
182
- titleSpacing: 8,
183
- label: true,
184
- labelFill: theme === 'dark' ? '#fff' : '#000',
185
- labelOpacity: 0.45,
186
- labelFontSize: 10,
187
- line: true,
188
- lineFill: '#000',
189
- lineStrokeOpacity: 0.25,
181
+ label: align ? i === 0 : true,
190
182
  tickFilter: function tickFilter(_, idx) {
191
183
  return !(i !== 0 && idx === 0);
192
184
  },
193
- tickCount: 4,
194
- gridStrokeOpacity: 0.45,
195
- gridStroke: theme === 'dark' ? '#fff' : '#000',
196
- gridLineWidth: 1,
197
- gridLineDash: [4, 4]
185
+ grid: i === 0
198
186
  }];
199
187
  })),
200
188
  style: {
201
189
  lineWidth: lineWidth,
202
190
  lineCap: 'round',
203
- lineJoin: 'round'
191
+ lineJoin: 'round',
192
+ strokeOpacity: CHART_STYLE_DEFAULTS.lineOpacity
204
193
  },
205
- legend: parallelData.length > 1 ? {
206
- color: {
207
- position: 'top',
208
- itemMarker: 'point'
209
- }
210
- } : false,
211
- interaction: {
212
- tooltip: {
213
- series: false
214
- }
215
- },
216
- viewStyle: {
217
- viewFill: backgroundColor
194
+ state: hasMultipleSeries ? getLineHighlightState(lineWidth) : undefined,
195
+ legend: legend === false ? false : {
196
+ color: _objectSpread(_objectSpread({}, legend.color), {}, {
197
+ itemMarker: 'smooth'
198
+ })
218
199
  },
200
+ interaction: _objectSpread({
201
+ tooltip: true
202
+ }, hasMultipleSeries ? getSeriesHighlightByColorInteraction() : {}),
203
+ viewStyle: style.backgroundColor ? {
204
+ viewFill: style.backgroundColor
205
+ } : undefined,
219
206
  theme: getThemeObject(theme)
220
207
  };
221
208
  chart.options(chartOptions);
@@ -1,5 +1,5 @@
1
1
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
2
+ import { getThemeObject, normalizePalette } from "../../util/theme";
3
3
 
4
4
  /**
5
5
  * SankeyDataItem is the type for each data item in the sankey chart.
@@ -67,7 +67,6 @@ export var Sankey = function Sankey(options) {
67
67
 
68
68
  // Get colors from style.palette or theme defaults
69
69
  var colors = normalizePalette(style.palette, theme);
70
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
71
70
 
72
71
  // Create chart
73
72
  chart = new Chart({
@@ -109,9 +108,9 @@ export var Sankey = function Sankey(options) {
109
108
  nodeLineWidth: 1,
110
109
  linkFillOpacity: 0.3
111
110
  },
112
- viewStyle: {
113
- viewFill: backgroundColor
114
- },
111
+ viewStyle: style.backgroundColor ? {
112
+ viewFill: style.backgroundColor
113
+ } : undefined,
115
114
  theme: getThemeObject(theme),
116
115
  legend: false,
117
116
  tooltip: false
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions } from '../../types';
1
+ import type { VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * ScatterDataItem is the type for each data item in the scatter chart.
4
4
  */
@@ -14,7 +14,9 @@ export interface ScatterConfig {
14
14
  type?: 'scatter';
15
15
  data: ScatterDataItem[];
16
16
  title?: string;
17
- theme?: 'default' | 'academy' | 'dark';
17
+ axisXTitle?: string;
18
+ axisYTitle?: string;
19
+ theme?: VisualizationTheme;
18
20
  style?: {
19
21
  backgroundColor?: string;
20
22
  palette?: string[];
@@ -1,5 +1,11 @@
1
+ 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); }
2
+ 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
+ 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
+ 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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
1
7
  import { Chart } from '@antv/g2';
2
- import { getBackgroundColor, getThemeObject, normalizePalette } from "../../util/theme";
8
+ import { CHART_STYLE_DEFAULTS, getBackgroundColor, getCartesianAxis, getChartAnimation, getColorLegend, getPointHighlightState, getThemeObject, normalizePalette } from "../../util";
3
9
 
4
10
  /**
5
11
  * ScatterDataItem is the type for each data item in the scatter chart.
@@ -44,6 +50,7 @@ export var Scatter = function Scatter(options) {
44
50
  _options$theme = options.theme,
45
51
  chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
46
52
  var chart = null;
53
+ var hasRendered = false;
47
54
 
48
55
  /**
49
56
  * Render the scatter chart with the given configuration.
@@ -55,6 +62,8 @@ export var Scatter = function Scatter(options) {
55
62
  _config$theme = config.theme,
56
63
  theme = _config$theme === void 0 ? chartTheme : _config$theme,
57
64
  title = config.title,
65
+ axisXTitle = config.axisXTitle,
66
+ axisYTitle = config.axisYTitle,
58
67
  _config$style = config.style,
59
68
  style = _config$style === void 0 ? {} : _config$style;
60
69
 
@@ -83,13 +92,18 @@ export var Scatter = function Scatter(options) {
83
92
  var scaleConfig = {
84
93
  y: {
85
94
  nice: true
95
+ },
96
+ x: {
97
+ nice: true
86
98
  }
87
99
  };
88
100
  if (hasGroupField) {
89
101
  encode = {
90
102
  x: 'x',
91
103
  y: 'y',
92
- color: 'group'
104
+ color: 'group',
105
+ shape: 'point',
106
+ size: CHART_STYLE_DEFAULTS.scatterPointSize
93
107
  };
94
108
  scaleConfig.color = {
95
109
  range: colors
@@ -98,9 +112,8 @@ export var Scatter = function Scatter(options) {
98
112
  encode = {
99
113
  x: 'x',
100
114
  y: 'y',
101
- color: function color() {
102
- return 'all';
103
- }
115
+ shape: 'point',
116
+ size: CHART_STYLE_DEFAULTS.scatterPointSize
104
117
  };
105
118
  }
106
119
 
@@ -108,39 +121,51 @@ export var Scatter = function Scatter(options) {
108
121
  // Note: Using 'any' type due to G2's complex type system with transformations
109
122
  // This is consistent with how G2 5.0 is used elsewhere in the codebase
110
123
  var chartOptions = {
111
- animate: false,
124
+ animate: getChartAnimation(hasRendered, 'fadeIn'),
112
125
  type: 'point',
113
126
  data: data,
114
- title: title !== null && title !== void 0 ? title : '',
127
+ title: title || '',
115
128
  encode: encode,
116
- legend: hasGroupField ? {
117
- color: {
118
- position: 'top'
119
- }
120
- } : false,
129
+ legend: getColorLegend(hasGroupField),
121
130
  scale: scaleConfig,
122
- style: {
123
- lineWidth: 1
124
- },
131
+ axis: getCartesianAxis({
132
+ axisXTitle: axisXTitle,
133
+ axisYTitle: axisYTitle
134
+ }),
135
+ style: _objectSpread({
136
+ lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
137
+ fillOpacity: 0.88,
138
+ stroke: backgroundColor
139
+ }, !hasGroupField ? {
140
+ fill: colors[0]
141
+ } : {}),
142
+ // A same-color stroke enlarges the rendered path without changing its transform or
143
+ // hit area, so repeated pointer events cannot accumulate scale.
144
+ state: getPointHighlightState(),
125
145
  tooltip: {
126
146
  title: function title(d) {
127
147
  return d !== null && d !== void 0 && d.group ? d.group : false;
128
148
  },
129
149
  items: [{
130
150
  channel: 'x',
131
- name: 'x'
151
+ name: axisXTitle !== null && axisXTitle !== void 0 ? axisXTitle : 'x'
132
152
  }, {
133
153
  channel: 'y',
134
- name: 'y'
154
+ name: axisYTitle !== null && axisYTitle !== void 0 ? axisYTitle : 'y'
135
155
  }]
136
156
  },
137
- viewStyle: {
138
- viewFill: backgroundColor
157
+ interaction: {
158
+ tooltip: true,
159
+ elementHighlight: true
139
160
  },
161
+ viewStyle: style.backgroundColor ? {
162
+ viewFill: backgroundColor
163
+ } : undefined,
140
164
  theme: getThemeObject(theme)
141
165
  };
142
166
  chart.options(chartOptions);
143
167
  chart.render();
168
+ hasRendered = true;
144
169
  };
145
170
 
146
171
  /**
@@ -151,6 +176,7 @@ export var Scatter = function Scatter(options) {
151
176
  chart.destroy();
152
177
  chart = null;
153
178
  }
179
+ hasRendered = false;
154
180
  };
155
181
  return {
156
182
  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
  * TreemapDataItem is the type for each data item in the treemap chart.
@@ -84,7 +84,6 @@ export var Treemap = function Treemap(options) {
84
84
 
85
85
  // Get colors from style.palette or theme defaults
86
86
  var colors = normalizePalette(style.palette, theme);
87
- var backgroundColor = style.backgroundColor || getBackgroundColor(theme);
88
87
 
89
88
  // Create chart
90
89
  chart = new Chart({
@@ -129,9 +128,9 @@ export var Treemap = function Treemap(options) {
129
128
  };
130
129
  }]
131
130
  },
132
- viewStyle: {
133
- viewFill: backgroundColor
134
- },
131
+ viewStyle: style.backgroundColor ? {
132
+ viewFill: style.backgroundColor
133
+ } : undefined,
135
134
  theme: getThemeObject(theme),
136
135
  scale: _objectSpread({}, colors.length > 0 ? {
137
136
  color: {