@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
@@ -1,4 +1,3 @@
1
- import type { VisualizationTheme } from '../types';
2
1
  export type SharedTooltipInteractionOptions = {
3
2
  crosshairs?: boolean;
4
3
  };
@@ -7,8 +6,10 @@ export type PointHighlightStateOptions = {
7
6
  inactiveOpacity?: number;
8
7
  };
9
8
  export declare const getSharedTooltipInteraction: ({ crosshairs, }?: SharedTooltipInteractionOptions) => Record<string, boolean>;
10
- export declare const getCategoryBackgroundHighlightState: (theme: VisualizationTheme) => Record<string, any>;
9
+ export declare const getCategoryBackgroundHighlightState: (theme: string) => Record<string, any>;
11
10
  export declare const getCategoryHighlightInteraction: () => Record<string, any>;
12
11
  export declare const getPointHighlightState: ({ activeLineWidth, inactiveOpacity, }?: PointHighlightStateOptions) => Record<string, any>;
13
- export declare const getSeriesHighlightByColorInteraction: () => Record<string, boolean>;
12
+ export declare const getSeriesHighlightByColorInteraction: () => Record<string, any>;
14
13
  export declare const getLineHighlightState: (lineWidth: number) => Record<string, any>;
14
+ /** Preserve GPT-Vis hover feedback independently of the visual theme. */
15
+ export declare const getElementHoverScaleInteraction: (theme: string) => Record<string, unknown>;
@@ -29,6 +29,7 @@ export var getCategoryBackgroundHighlightState = function getCategoryBackgroundH
29
29
  };
30
30
  export var getCategoryHighlightInteraction = function getCategoryHighlightInteraction() {
31
31
  return {
32
+ delay: CHART_STYLE_DEFAULTS.interactionDelay,
32
33
  background: true,
33
34
  region: true
34
35
  };
@@ -57,7 +58,9 @@ export var getPointHighlightState = function getPointHighlightState() {
57
58
  };
58
59
  export var getSeriesHighlightByColorInteraction = function getSeriesHighlightByColorInteraction() {
59
60
  return {
60
- elementHighlightByColor: true
61
+ elementHighlightByColor: {
62
+ delay: CHART_STYLE_DEFAULTS.interactionDelay
63
+ }
61
64
  };
62
65
  };
63
66
  export var getLineHighlightState = function getLineHighlightState(lineWidth) {
@@ -70,4 +73,18 @@ export var getLineHighlightState = function getLineHighlightState(lineWidth) {
70
73
  strokeOpacity: CHART_STYLE_DEFAULTS.inactiveOpacity
71
74
  }
72
75
  };
76
+ };
77
+
78
+ /** Preserve GPT-Vis hover feedback independently of the visual theme. */
79
+ export var getElementHoverScaleInteraction = function getElementHoverScaleInteraction(theme) {
80
+ return {
81
+ delay: CHART_STYLE_DEFAULTS.interactionDelay,
82
+ scale: 1.04,
83
+ shadow: true,
84
+ shadowBlur: theme === 'dark' ? 7 : theme === 'academy' ? 5 : 6,
85
+ shadowColor: theme === 'dark' ? 'rgba(226, 232, 240, 0.38)' : theme === 'academy' ? 'rgba(63, 49, 38, 0.44)' : 'rgba(15, 23, 42, 0.46)',
86
+ shadowOffsetX: 0,
87
+ shadowOffsetY: theme === 'dark' ? 0 : 3,
88
+ zIndex: 10
89
+ };
73
90
  };
@@ -1,4 +1,3 @@
1
- import type { VisualizationTheme } from '../types';
2
1
  export declare const CHART_FONT_FAMILY = "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif";
3
2
  export declare const CHART_STYLE_DEFAULTS: {
4
3
  readonly animationDuration: 260;
@@ -13,9 +12,10 @@ export declare const CHART_STYLE_DEFAULTS: {
13
12
  readonly pointActiveLineWidth: 5;
14
13
  readonly intervalWidthRatio: 0.64;
15
14
  };
16
- export type ChartVisualTokens = {
15
+ type BuiltInThemeValues = {
17
16
  background: string;
18
17
  textPrimary: string;
18
+ textInverse: string;
19
19
  textSecondary: string;
20
20
  grid: string;
21
21
  axisGrid: string;
@@ -28,4 +28,5 @@ export type ChartVisualTokens = {
28
28
  tooltipMarkerShadow: string;
29
29
  tooltipShadow: string;
30
30
  };
31
- export declare const getChartVisualTokens: (theme: VisualizationTheme) => ChartVisualTokens;
31
+ export declare const getChartVisualTokens: (theme: string) => BuiltInThemeValues;
32
+ export {};
@@ -12,9 +12,10 @@ export var CHART_STYLE_DEFAULTS = {
12
12
  pointActiveLineWidth: 5,
13
13
  intervalWidthRatio: 0.64
14
14
  };
15
- var LIGHT_TOKENS = {
15
+ var LIGHT_THEME_VALUES = {
16
16
  background: '#FFFFFF',
17
17
  textPrimary: '#1F2937',
18
+ textInverse: '#FFFFFF',
18
19
  textSecondary: '#667085',
19
20
  grid: '#E7EAF0',
20
21
  axisGrid: '#D0D5DD',
@@ -27,9 +28,10 @@ var LIGHT_TOKENS = {
27
28
  tooltipMarkerShadow: '0 0 0 2px #FFFFFF, 0 1px 3px rgba(15, 23, 42, 0.20)',
28
29
  tooltipShadow: '0 12px 32px rgba(15, 23, 42, 0.12), 0 3px 8px rgba(15, 23, 42, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.82)'
29
30
  };
30
- var DARK_TOKENS = {
31
+ var DARK_THEME_VALUES = {
31
32
  background: '#141414',
32
33
  textPrimary: '#F3F4F6',
34
+ textInverse: '#111827',
33
35
  textSecondary: '#A7AFBE',
34
36
  grid: '#343841',
35
37
  axisGrid: '#475467',
@@ -42,9 +44,10 @@ var DARK_TOKENS = {
42
44
  tooltipMarkerShadow: '0 0 0 2px #1A1B1F, 0 1px 3px rgba(0, 0, 0, 0.42)',
43
45
  tooltipShadow: '0 14px 36px rgba(0, 0, 0, 0.34), 0 3px 10px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08)'
44
46
  };
45
- var ACADEMY_TOKENS = {
47
+ var ACADEMY_THEME_VALUES = {
46
48
  background: '#FFFFFF',
47
49
  textPrimary: '#23262D',
50
+ textInverse: '#FFFFFF',
48
51
  textSecondary: '#626975',
49
52
  grid: '#DDDDDD',
50
53
  axisGrid: '#DDDDDD',
@@ -58,7 +61,7 @@ var ACADEMY_TOKENS = {
58
61
  tooltipShadow: '0 12px 30px rgba(63, 49, 38, 0.11), 0 3px 8px rgba(63, 49, 38, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.88)'
59
62
  };
60
63
  export var getChartVisualTokens = function getChartVisualTokens(theme) {
61
- if (theme === 'dark') return DARK_TOKENS;
62
- if (theme === 'academy') return ACADEMY_TOKENS;
63
- return LIGHT_TOKENS;
64
+ if (theme === 'dark') return DARK_THEME_VALUES;
65
+ if (theme === 'academy') return ACADEMY_THEME_VALUES;
66
+ return LIGHT_THEME_VALUES;
64
67
  };
@@ -1,4 +1,4 @@
1
- import type { VisualizationOptions, VisualizationTheme } from '../../types';
1
+ import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
2
2
  /**
3
3
  * AreaDataItem is the type for each data item in the area chart.
4
4
  */
@@ -15,14 +15,11 @@ export interface AreaConfig {
15
15
  data: AreaDataItem[];
16
16
  stack?: boolean;
17
17
  title?: string;
18
+ subtitle?: string;
18
19
  axisXTitle?: string;
19
20
  axisYTitle?: string;
20
21
  theme?: VisualizationTheme;
21
- style?: {
22
- backgroundColor?: string;
23
- palette?: string[];
24
- lineWidth?: number;
25
- };
22
+ style?: ThemeStyle;
26
23
  }
27
24
  /**
28
25
  * AreaInstance represents an area chart instance with render and destroy methods.
@@ -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
  }