@antv/gpt-vis 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +66 -1
  2. package/README.zh-CN.md +66 -1
  3. package/dist/cjs/types/index.d.ts +2 -1
  4. package/dist/cjs/util/animation.d.ts +2 -0
  5. package/dist/cjs/util/animation.js +38 -0
  6. package/dist/cjs/util/components.d.ts +15 -0
  7. package/dist/cjs/util/components.js +94 -0
  8. package/dist/cjs/util/crosshair-axis-labels.d.ts +9 -0
  9. package/dist/cjs/util/crosshair-axis-labels.js +304 -0
  10. package/dist/cjs/util/index.d.ts +6 -0
  11. package/dist/cjs/util/index.js +33 -0
  12. package/dist/cjs/util/interaction.d.ts +14 -0
  13. package/dist/cjs/util/interaction.js +89 -0
  14. package/dist/cjs/util/theme.d.ts +18 -24
  15. package/dist/cjs/util/theme.js +303 -120
  16. package/dist/cjs/util/tokens.d.ts +31 -0
  17. package/dist/cjs/util/tokens.js +98 -0
  18. package/dist/cjs/vis/area/index.d.ts +2 -2
  19. package/dist/cjs/vis/area/index.js +76 -31
  20. package/dist/cjs/vis/bar/index.d.ts +2 -2
  21. package/dist/cjs/vis/bar/index.js +22 -19
  22. package/dist/cjs/vis/boxplot/index.js +1 -4
  23. package/dist/cjs/vis/column/index.d.ts +2 -2
  24. package/dist/cjs/vis/column/index.js +28 -18
  25. package/dist/cjs/vis/dual-axes/index.d.ts +2 -2
  26. package/dist/cjs/vis/dual-axes/index.js +89 -34
  27. package/dist/cjs/vis/funnel/index.d.ts +4 -2
  28. package/dist/cjs/vis/funnel/index.js +171 -92
  29. package/dist/cjs/vis/histogram/index.js +1 -4
  30. package/dist/cjs/vis/line/index.d.ts +2 -2
  31. package/dist/cjs/vis/line/index.js +71 -31
  32. package/dist/cjs/vis/liquid/index.d.ts +2 -2
  33. package/dist/cjs/vis/liquid/index.js +41 -16
  34. package/dist/cjs/vis/pie/index.d.ts +2 -2
  35. package/dist/cjs/vis/pie/index.js +26 -16
  36. package/dist/cjs/vis/radar/index.d.ts +2 -2
  37. package/dist/cjs/vis/radar/index.js +21 -29
  38. package/dist/cjs/vis/sankey/index.js +1 -4
  39. package/dist/cjs/vis/scatter/index.d.ts +2 -2
  40. package/dist/cjs/vis/scatter/index.js +40 -17
  41. package/dist/cjs/vis/treemap/index.js +1 -4
  42. package/dist/cjs/vis/venn/index.js +1 -4
  43. package/dist/cjs/vis/violin/index.js +1 -1
  44. package/dist/cjs/vis/waterfall/index.js +1 -1
  45. package/dist/cjs/vis/word-cloud/index.d.ts +3 -2
  46. package/dist/cjs/vis/word-cloud/index.js +125 -10
  47. package/dist/esm/types/index.d.ts +2 -1
  48. package/dist/esm/util/animation.d.ts +2 -0
  49. package/dist/esm/util/animation.js +17 -0
  50. package/dist/esm/util/components.d.ts +15 -0
  51. package/dist/esm/util/components.js +67 -0
  52. package/dist/esm/util/crosshair-axis-labels.d.ts +9 -0
  53. package/dist/esm/util/crosshair-axis-labels.js +328 -0
  54. package/dist/esm/util/index.d.ts +6 -0
  55. package/dist/esm/util/index.js +6 -0
  56. package/dist/esm/util/interaction.d.ts +14 -0
  57. package/dist/esm/util/interaction.js +73 -0
  58. package/dist/esm/util/theme.d.ts +18 -24
  59. package/dist/esm/util/theme.js +302 -126
  60. package/dist/esm/util/tokens.d.ts +31 -0
  61. package/dist/esm/util/tokens.js +64 -0
  62. package/dist/esm/vis/area/index.d.ts +2 -2
  63. package/dist/esm/vis/area/index.js +91 -41
  64. package/dist/esm/vis/bar/index.d.ts +2 -2
  65. package/dist/esm/vis/bar/index.js +28 -29
  66. package/dist/esm/vis/boxplot/index.js +4 -5
  67. package/dist/esm/vis/column/index.d.ts +2 -2
  68. package/dist/esm/vis/column/index.js +36 -29
  69. package/dist/esm/vis/dual-axes/index.d.ts +2 -2
  70. package/dist/esm/vis/dual-axes/index.js +115 -42
  71. package/dist/esm/vis/funnel/index.d.ts +4 -2
  72. package/dist/esm/vis/funnel/index.js +156 -83
  73. package/dist/esm/vis/histogram/index.js +4 -5
  74. package/dist/esm/vis/line/index.d.ts +2 -2
  75. package/dist/esm/vis/line/index.js +80 -37
  76. package/dist/esm/vis/liquid/index.d.ts +2 -2
  77. package/dist/esm/vis/liquid/index.js +41 -14
  78. package/dist/esm/vis/pie/index.d.ts +2 -2
  79. package/dist/esm/vis/pie/index.js +36 -16
  80. package/dist/esm/vis/radar/index.d.ts +2 -2
  81. package/dist/esm/vis/radar/index.js +21 -34
  82. package/dist/esm/vis/sankey/index.js +4 -5
  83. package/dist/esm/vis/scatter/index.d.ts +2 -2
  84. package/dist/esm/vis/scatter/index.js +41 -25
  85. package/dist/esm/vis/treemap/index.js +4 -5
  86. package/dist/esm/vis/venn/index.js +4 -5
  87. package/dist/esm/vis/violin/index.js +5 -13
  88. package/dist/esm/vis/waterfall/index.js +5 -7
  89. package/dist/esm/vis/word-cloud/index.d.ts +3 -2
  90. package/dist/esm/vis/word-cloud/index.js +158 -10
  91. package/dist/umd/index.min.js +1 -1
  92. package/package.json +18 -15
@@ -0,0 +1,14 @@
1
+ import type { VisualizationTheme } from '../types';
2
+ export type SharedTooltipInteractionOptions = {
3
+ crosshairs?: boolean;
4
+ };
5
+ export type PointHighlightStateOptions = {
6
+ activeLineWidth?: number;
7
+ inactiveOpacity?: number;
8
+ };
9
+ export declare const getSharedTooltipInteraction: ({ crosshairs, }?: SharedTooltipInteractionOptions) => Record<string, boolean>;
10
+ export declare const getCategoryBackgroundHighlightState: (theme: VisualizationTheme) => Record<string, any>;
11
+ export declare const getCategoryHighlightInteraction: () => Record<string, any>;
12
+ export declare const getPointHighlightState: ({ activeLineWidth, inactiveOpacity, }?: PointHighlightStateOptions) => Record<string, any>;
13
+ export declare const getSeriesHighlightByColorInteraction: () => Record<string, boolean>;
14
+ export declare const getLineHighlightState: (lineWidth: number) => Record<string, any>;
@@ -0,0 +1,73 @@
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); }
7
+ import { CHART_STYLE_DEFAULTS, getChartVisualTokens } from "./tokens";
8
+ export var getSharedTooltipInteraction = function getSharedTooltipInteraction() {
9
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
10
+ _ref$crosshairs = _ref.crosshairs,
11
+ crosshairs = _ref$crosshairs === void 0 ? false : _ref$crosshairs;
12
+ return {
13
+ shared: true,
14
+ series: true,
15
+ crosshairs: crosshairs
16
+ };
17
+ };
18
+ export var getCategoryBackgroundHighlightState = function getCategoryBackgroundHighlightState(theme) {
19
+ var tokens = getChartVisualTokens(theme);
20
+ return {
21
+ active: {
22
+ backgroundFill: tokens.grid,
23
+ backgroundFillOpacity: theme === 'dark' ? 0.56 : 0.58,
24
+ backgroundLineWidth: 0,
25
+ backgroundPadding: 0.08,
26
+ backgroundRadius: 4
27
+ }
28
+ };
29
+ };
30
+ export var getCategoryHighlightInteraction = function getCategoryHighlightInteraction() {
31
+ return {
32
+ background: true,
33
+ region: true
34
+ };
35
+ };
36
+ export var getPointHighlightState = function getPointHighlightState() {
37
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
38
+ _ref2$activeLineWidth = _ref2.activeLineWidth,
39
+ activeLineWidth = _ref2$activeLineWidth === void 0 ? CHART_STYLE_DEFAULTS.pointActiveLineWidth : _ref2$activeLineWidth,
40
+ inactiveOpacity = _ref2.inactiveOpacity;
41
+ return _objectSpread({
42
+ active: {
43
+ lineWidth: activeLineWidth,
44
+ stroke: function stroke(_datum, _index, _data, element) {
45
+ var _element$style, _element$style2;
46
+ return (element === null || element === void 0 || (_element$style = element.style) === null || _element$style === void 0 ? void 0 : _element$style.fill) || (element === null || element === void 0 || (_element$style2 = element.style) === null || _element$style2 === void 0 ? void 0 : _element$style2.stroke);
47
+ },
48
+ fillOpacity: 1,
49
+ zIndex: 10
50
+ }
51
+ }, inactiveOpacity === undefined ? {} : {
52
+ inactive: {
53
+ fillOpacity: inactiveOpacity,
54
+ strokeOpacity: inactiveOpacity
55
+ }
56
+ });
57
+ };
58
+ export var getSeriesHighlightByColorInteraction = function getSeriesHighlightByColorInteraction() {
59
+ return {
60
+ elementHighlightByColor: true
61
+ };
62
+ };
63
+ export var getLineHighlightState = function getLineHighlightState(lineWidth) {
64
+ return {
65
+ active: {
66
+ lineWidth: lineWidth + 1,
67
+ strokeOpacity: 1
68
+ },
69
+ inactive: {
70
+ strokeOpacity: CHART_STYLE_DEFAULTS.inactiveOpacity
71
+ }
72
+ };
73
+ };
@@ -1,26 +1,20 @@
1
+ import type { Theme } from '@antv/g2';
2
+ import type { VisualizationTheme } from '../types';
1
3
  export declare const DEFAULT_COLOR_PALETTE: string[];
2
4
  export declare const ACADEMY_COLOR_PALETTE: string[];
3
- export declare const THEME_MAP: Record<string, any>;
4
- /**
5
- * Get normalized theme name for G2.
6
- * Converts 'default' to 'light' for G2 compatibility.
7
- */
8
- export declare const getTheme: (theme: string) => string;
9
- /**
10
- * Get theme object from THEME_MAP.
11
- * This should be used for visualization components to properly support dark theme with multiple marks.
12
- */
13
- export declare const getThemeObject: (theme: string) => any;
14
- /**
15
- * Get theme color palette based on theme name.
16
- */
17
- export declare const getThemeColors: (theme: string) => string[];
18
- /**
19
- * Get background color based on theme.
20
- */
21
- export declare const getBackgroundColor: (theme: string) => string;
22
- /**
23
- * Normalize palette to always return an array.
24
- * Handles the case where a single color is parsed as a string instead of an array.
25
- */
26
- export declare const normalizePalette: (palette: string | string[] | undefined, theme: string) => string[];
5
+ type G2ThemeType = 'light' | 'dark' | 'academy';
6
+ type ChartTheme = Theme & {
7
+ enter?: {
8
+ duration?: number;
9
+ easing?: string;
10
+ };
11
+ elementHighlightByColor?: Record<string, unknown>;
12
+ elementHoverScale?: Record<string, unknown>;
13
+ };
14
+ export declare const THEME_MAP: Record<VisualizationTheme, ChartTheme>;
15
+ export declare const getTheme: (theme: VisualizationTheme) => G2ThemeType;
16
+ export declare const getThemeObject: (theme: VisualizationTheme) => ChartTheme;
17
+ export declare const getThemeColors: (theme: VisualizationTheme) => string[];
18
+ export declare const getBackgroundColor: (theme: VisualizationTheme) => string;
19
+ export declare const normalizePalette: (palette: string | string[] | undefined, theme: VisualizationTheme) => string[];
20
+ export {};
@@ -1,150 +1,326 @@
1
- // Color palettes
2
- export var DEFAULT_COLOR_PALETTE = ['#1783FF', '#F08F56', '#D580FF', '#00C9C9', '#7863FF', '#DB9D0D', '#60C42D', '#FF80CA', '#2491B3', '#17C76F'];
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); }
7
+ import { CHART_FONT_FAMILY, CHART_STYLE_DEFAULTS, getChartVisualTokens } from "./tokens";
8
+ export var DEFAULT_COLOR_PALETTE = ['#5B6CFF', '#2DAF9E', '#F2B84B', '#EF6A6A', '#55A6D9', '#3AA76D', '#F58A57', '#8B6FD6', '#D96C9B'];
3
9
  export var ACADEMY_COLOR_PALETTE = ['#4e79a7', '#f28e2c', '#e15759', '#76b7b2', '#59a14f', '#edc949', '#af7aa1', '#ff9da7', '#9c755f', '#bab0ab'];
4
-
5
- // Theme definitions
6
- var DEFAULT_THEME = {
7
- type: 'light',
8
- view: {
9
- viewFill: '#FFF',
10
- plotFill: 'transparent',
11
- mainFill: 'transparent',
12
- contentFill: 'transparent'
13
- },
14
- interval: {
15
- rect: {
16
- fillOpacity: 0.8
17
- }
18
- },
19
- line: {
20
- line: {
21
- lineWidth: 2
22
- }
23
- },
24
- area: {
25
- area: {
26
- fillOpacity: 0.6
27
- }
28
- },
29
- point: {
30
- point: {
31
- lineWidth: 1
32
- }
33
- }
34
- };
35
- var DARK_THEME = {
36
- type: 'dark',
37
- view: {
38
- viewFill: '#000',
39
- plotFill: 'transparent',
40
- mainFill: 'transparent',
41
- contentFill: 'transparent'
42
- },
43
- interval: {
44
- rect: {
45
- fillOpacity: 0.8
46
- }
47
- },
48
- line: {
49
- line: {
50
- lineWidth: 2
51
- }
52
- },
53
- area: {
54
- area: {
55
- fillOpacity: 0.6
56
- }
57
- },
58
- point: {
59
- point: {
60
- lineWidth: 1
61
- }
62
- }
10
+ var filterBaselineGrid = function filterBaselineGrid(_, index) {
11
+ return index !== 0;
63
12
  };
64
- var ACADEMY_THEME = {
65
- type: 'academy',
66
- view: {
67
- viewFill: '#FFF',
68
- plotFill: 'transparent',
69
- mainFill: 'transparent',
70
- contentFill: 'transparent'
71
- },
72
- interval: {
73
- rect: {
74
- fillOpacity: 0.8
75
- }
76
- },
77
- line: {
13
+ var createTheme = function createTheme(type) {
14
+ var tokens = getChartVisualTokens(type);
15
+ var isDark = type === 'dark';
16
+ var isAcademy = type === 'academy';
17
+ var colors = isAcademy ? ACADEMY_COLOR_PALETTE : DEFAULT_COLOR_PALETTE;
18
+ return {
19
+ type: type,
20
+ color: colors[0],
21
+ category10: colors,
22
+ category20: colors,
23
+ view: {
24
+ viewFill: tokens.background,
25
+ plotFill: 'transparent',
26
+ mainFill: 'transparent',
27
+ contentFill: 'transparent'
28
+ },
29
+ interval: {
30
+ rect: {
31
+ fillOpacity: 0.96
32
+ }
33
+ },
78
34
  line: {
79
- lineWidth: 2
80
- }
81
- },
82
- area: {
35
+ line: {
36
+ lineWidth: CHART_STYLE_DEFAULTS.lineWidth
37
+ }
38
+ },
83
39
  area: {
84
- fillOpacity: 0.6
85
- }
86
- },
87
- point: {
40
+ area: {
41
+ fillOpacity: CHART_STYLE_DEFAULTS.areaOpacity
42
+ }
43
+ },
88
44
  point: {
89
- lineWidth: 1
45
+ point: {
46
+ lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
47
+ fillOpacity: 0.82
48
+ },
49
+ hollow: {
50
+ lineWidth: 2,
51
+ strokeOpacity: 1
52
+ }
53
+ },
54
+ enter: {
55
+ duration: CHART_STYLE_DEFAULTS.animationDuration,
56
+ easing: 'ease-out'
57
+ },
58
+ axis: _objectSpread({
59
+ labelAutoHide: {
60
+ keepHeader: true,
61
+ keepTail: true
62
+ },
63
+ titleOpacity: 1,
64
+ titleFillOpacity: 1,
65
+ labelOpacity: 1,
66
+ labelFillOpacity: 1,
67
+ line: true,
68
+ lineLineWidth: 1,
69
+ lineStroke: tokens.axisLine,
70
+ lineStrokeOpacity: 1,
71
+ tick: true,
72
+ tickLineWidth: 1,
73
+ tickStroke: tokens.axisTick,
74
+ tickStrokeOpacity: 1
75
+ }, isAcademy ? {
76
+ titleFill: '#000000',
77
+ titleStrokeOpacity: 1,
78
+ titleFontSize: 11,
79
+ titleFontWeight: 'bold',
80
+ titleSpacing: 12,
81
+ labelFill: '#000000',
82
+ labelStrokeOpacity: 1,
83
+ labelFontSize: 10,
84
+ labelFontWeight: 'normal',
85
+ labelSpacing: 4,
86
+ tickLength: 5
87
+ } : {
88
+ titleFill: tokens.textSecondary,
89
+ titleFontFamily: CHART_FONT_FAMILY,
90
+ titleFontSize: 12,
91
+ titleFontWeight: 500,
92
+ titleLineWidth: 0,
93
+ titleSpacing: 16,
94
+ labelFill: tokens.textSecondary,
95
+ labelFontFamily: CHART_FONT_FAMILY,
96
+ labelFontSize: 12,
97
+ labelFontWeight: 400,
98
+ labelLineWidth: 0,
99
+ labelSpacing: 6,
100
+ tickLength: 3,
101
+ tickOpacity: 1
102
+ }),
103
+ axisX: _objectSpread({
104
+ grid: isAcademy,
105
+ labelAutoRotate: {
106
+ optionalAngles: [0, 45, 90],
107
+ recoverWhenFailed: true
108
+ }
109
+ }, isAcademy ? {
110
+ gridStroke: tokens.axisGrid,
111
+ gridStrokeOpacity: 1,
112
+ gridLineWidth: 1,
113
+ gridLineDash: [0, 0]
114
+ } : {}),
115
+ axisY: {
116
+ lineLineWidth: isAcademy ? 1 : 0.75,
117
+ grid: true,
118
+ gridStroke: tokens.axisGrid,
119
+ gridStrokeOpacity: 1,
120
+ gridLineWidth: isAcademy ? 1 : 0.5,
121
+ gridLineDash: isAcademy ? [0, 0] : [2, 4],
122
+ gridFilter: filterBaselineGrid
123
+ },
124
+ axisRadar: {
125
+ zIndex: 1,
126
+ titleFill: isAcademy ? tokens.textPrimary : tokens.textSecondary,
127
+ titleFontFamily: CHART_FONT_FAMILY,
128
+ titleFontSize: isAcademy ? 10 : 12,
129
+ titleFontWeight: isAcademy ? 600 : 500,
130
+ titleSpacing: 10,
131
+ labelFill: tokens.textSecondary,
132
+ labelOpacity: 1,
133
+ labelFontFamily: CHART_FONT_FAMILY,
134
+ labelFontSize: isAcademy ? 10 : 11,
135
+ line: true,
136
+ lineStroke: tokens.axisLine,
137
+ lineStrokeOpacity: isAcademy ? 1 : 0.64,
138
+ lineLineWidth: isAcademy ? 1 : 0.75,
139
+ tick: true,
140
+ tickLength: isAcademy ? 4 : 2,
141
+ tickStroke: tokens.axisTick,
142
+ tickStrokeOpacity: isAcademy ? 1 : 0.68,
143
+ tickCount: 4,
144
+ gridStroke: tokens.axisGrid,
145
+ gridStrokeOpacity: isAcademy ? 1 : 0.9,
146
+ gridLineWidth: isAcademy ? 1 : 0.75,
147
+ gridLineDash: [0, 0]
148
+ },
149
+ title: {
150
+ spacing: 6,
151
+ titleFill: tokens.textPrimary,
152
+ titleFontSize: 16,
153
+ titleFontWeight: 600,
154
+ subtitleFill: tokens.textSecondary,
155
+ subtitleFontSize: 12,
156
+ subtitleFontWeight: 400
157
+ },
158
+ legendCategory: {
159
+ backgroundFill: 'transparent',
160
+ padding: [5, 0, 10, 0],
161
+ itemMarkerSize: 10,
162
+ itemMarkerFillOpacity: 0.92,
163
+ itemMarkerStrokeOpacity: 0.92,
164
+ itemLabelFill: tokens.textPrimary,
165
+ itemLabelFillOpacity: 0.78,
166
+ itemLabelFontFamily: CHART_FONT_FAMILY,
167
+ itemLabelFontSize: 12,
168
+ itemLabelFontWeight: 400,
169
+ itemLabelLineHeight: 16,
170
+ itemLabelLetterSpacing: 0.1,
171
+ itemLabelTextBaseline: 'middle',
172
+ itemSpacing: [8, 0, 0],
173
+ itemCursor: 'pointer',
174
+ rowPadding: 8,
175
+ colPadding: 22,
176
+ navButtonFill: tokens.textSecondary,
177
+ navButtonFillOpacity: 0.72,
178
+ navButtonSize: 9,
179
+ navPageNumFill: tokens.textSecondary,
180
+ navPageNumFillOpacity: 0.72,
181
+ navPageNumFontFamily: CHART_FONT_FAMILY,
182
+ navPageNumFontSize: 11,
183
+ navPageNumFontWeight: 400,
184
+ navControllerPadding: 4,
185
+ navControllerSpacing: 14
186
+ },
187
+ tooltip: {
188
+ shared: false,
189
+ series: false,
190
+ crosshairs: false,
191
+ marker: true,
192
+ markerR: 4,
193
+ markerLineWidth: 2,
194
+ markerStroke: tokens.background,
195
+ crosshairsStroke: tokens.textSecondary,
196
+ crosshairsStrokeOpacity: 0.18,
197
+ crosshairsLineWidth: 1,
198
+ crosshairsLineDash: [0, 0],
199
+ css: {
200
+ '.g2-tooltip': {
201
+ 'background-color': tokens.tooltipBackground,
202
+ border: "1px solid ".concat(tokens.tooltipBorder),
203
+ 'border-radius': '10px',
204
+ 'box-shadow': tokens.tooltipShadow,
205
+ color: tokens.textSecondary,
206
+ padding: '10px 12px',
207
+ 'min-width': '164px',
208
+ 'max-width': '300px',
209
+ overflow: 'hidden',
210
+ 'box-sizing': 'border-box',
211
+ 'backdrop-filter': 'blur(10px) saturate(1.08)',
212
+ '-webkit-backdrop-filter': 'blur(10px) saturate(1.08)',
213
+ 'font-family': CHART_FONT_FAMILY,
214
+ 'font-size': '12px',
215
+ 'line-height': '18px',
216
+ 'font-variant-numeric': 'tabular-nums',
217
+ 'font-feature-settings': '"tnum" 1, "zero" 1',
218
+ '-webkit-font-smoothing': 'antialiased',
219
+ contain: 'layout paint style'
220
+ },
221
+ '.g2-tooltip-title': {
222
+ color: tokens.textSecondary,
223
+ 'font-size': '11px',
224
+ 'font-weight': '500',
225
+ 'line-height': '16px',
226
+ 'letter-spacing': '0.01em',
227
+ 'margin-bottom': '6px',
228
+ 'padding-bottom': '7px',
229
+ 'border-bottom': "1px solid ".concat(tokens.tooltipDivider),
230
+ 'max-width': '276px'
231
+ },
232
+ '.g2-tooltip-list': {
233
+ display: 'grid',
234
+ gap: '4px'
235
+ },
236
+ '.g2-tooltip-list-item': {
237
+ display: 'grid',
238
+ 'grid-template-columns': 'minmax(0, 1fr) auto',
239
+ 'align-items': 'center',
240
+ 'column-gap': '18px',
241
+ 'min-height': '22px',
242
+ 'line-height': '22px'
243
+ },
244
+ '.g2-tooltip-list-item-name': {
245
+ gap: '8px',
246
+ 'min-width': '0',
247
+ 'max-width': '208px',
248
+ overflow: 'hidden',
249
+ color: tokens.textSecondary
250
+ },
251
+ '.g2-tooltip-list-item-name-label': {
252
+ color: tokens.textSecondary,
253
+ 'font-weight': '400'
254
+ },
255
+ '.g2-tooltip-list-item-value': {
256
+ color: tokens.textPrimary,
257
+ 'font-weight': '600',
258
+ flex: '0 0 auto',
259
+ 'min-width': '40px',
260
+ 'margin-left': '0',
261
+ 'text-align': 'right',
262
+ 'letter-spacing': '-0.01em',
263
+ 'font-variant-numeric': 'tabular-nums',
264
+ 'font-feature-settings': '"tnum" 1, "zero" 1'
265
+ },
266
+ '.g2-tooltip-list-item-marker': {
267
+ width: '7px',
268
+ height: '7px',
269
+ flex: '0 0 auto',
270
+ 'margin-right': '0',
271
+ 'border-radius': '999px',
272
+ 'box-shadow': tokens.tooltipMarkerShadow
273
+ },
274
+ '.g2-tooltip-crosshair-x': {
275
+ 'background-color': isDark ? 'rgba(255, 255, 255, 0.16)' : 'rgba(71, 84, 103, 0.16)'
276
+ },
277
+ '.g2-tooltip-crosshair-y': {
278
+ 'background-color': isDark ? 'rgba(255, 255, 255, 0.16)' : 'rgba(71, 84, 103, 0.16)'
279
+ }
280
+ }
281
+ },
282
+ elementHighlight: {
283
+ delay: CHART_STYLE_DEFAULTS.interactionDelay
284
+ },
285
+ elementHighlightByColor: {
286
+ delay: CHART_STYLE_DEFAULTS.interactionDelay
287
+ },
288
+ elementHoverScale: {
289
+ delay: CHART_STYLE_DEFAULTS.interactionDelay,
290
+ scale: 1.04,
291
+ shadow: true,
292
+ shadowBlur: isDark ? 7 : isAcademy ? 5 : 6,
293
+ shadowColor: isDark ? 'rgba(226, 232, 240, 0.38)' : isAcademy ? 'rgba(63, 49, 38, 0.44)' : 'rgba(15, 23, 42, 0.46)',
294
+ shadowOffsetX: 0,
295
+ shadowOffsetY: isDark ? 0 : 3,
296
+ zIndex: 10
90
297
  }
91
- }
298
+ };
92
299
  };
300
+ var LIGHT_THEME = createTheme('light');
301
+ var ACADEMY_THEME = createTheme('academy');
302
+ var DARK_THEME = createTheme('dark');
93
303
  export var THEME_MAP = {
94
- default: DEFAULT_THEME,
304
+ default: LIGHT_THEME,
305
+ light: LIGHT_THEME,
95
306
  academy: ACADEMY_THEME,
96
307
  dark: DARK_THEME
97
308
  };
98
-
99
- /**
100
- * Get normalized theme name for G2.
101
- * Converts 'default' to 'light' for G2 compatibility.
102
- */
103
309
  export var getTheme = function getTheme(theme) {
104
310
  return theme === 'default' ? 'light' : theme;
105
311
  };
106
-
107
- /**
108
- * Get theme object from THEME_MAP.
109
- * This should be used for visualization components to properly support dark theme with multiple marks.
110
- */
111
312
  export var getThemeObject = function getThemeObject(theme) {
112
313
  return THEME_MAP[theme] || THEME_MAP.default;
113
314
  };
114
-
115
- /**
116
- * Get theme color palette based on theme name.
117
- */
118
315
  export var getThemeColors = function getThemeColors(theme) {
119
- switch (theme) {
120
- case 'academy':
121
- return ACADEMY_COLOR_PALETTE;
122
- case 'dark':
123
- case 'default':
124
- default:
125
- return DEFAULT_COLOR_PALETTE;
126
- }
316
+ return theme === 'academy' ? ACADEMY_COLOR_PALETTE : DEFAULT_COLOR_PALETTE;
127
317
  };
128
-
129
- /**
130
- * Get background color based on theme.
131
- */
132
318
  export var getBackgroundColor = function getBackgroundColor(theme) {
133
- switch (theme) {
134
- case 'dark':
135
- return '#000';
136
- case 'academy':
137
- case 'default':
138
- default:
139
- return '#FFF';
140
- }
319
+ return getChartVisualTokens(theme).background;
141
320
  };
142
-
143
- /**
144
- * Normalize palette to always return an array.
145
- * Handles the case where a single color is parsed as a string instead of an array.
146
- */
147
321
  export var normalizePalette = function normalizePalette(palette, theme) {
148
- if (!palette || Array.isArray(palette) && palette.length === 0) return getThemeColors(theme);
322
+ if (!palette || Array.isArray(palette) && palette.length === 0) {
323
+ return getThemeColors(theme);
324
+ }
149
325
  return Array.isArray(palette) ? palette : [palette];
150
326
  };
@@ -0,0 +1,31 @@
1
+ import type { VisualizationTheme } from '../types';
2
+ export declare const CHART_FONT_FAMILY = "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif";
3
+ export declare const CHART_STYLE_DEFAULTS: {
4
+ readonly animationDuration: 260;
5
+ readonly interactionDelay: 40;
6
+ readonly lineWidth: 2.5;
7
+ readonly areaOpacity: 0.24;
8
+ readonly lineOpacity: 0.92;
9
+ readonly inactiveOpacity: 0.24;
10
+ readonly pointSize: 3.5;
11
+ readonly scatterPointSize: 5;
12
+ readonly pointLineWidth: 1.5;
13
+ readonly pointActiveLineWidth: 5;
14
+ readonly intervalWidthRatio: 0.64;
15
+ };
16
+ export type ChartVisualTokens = {
17
+ background: string;
18
+ textPrimary: string;
19
+ textSecondary: string;
20
+ grid: string;
21
+ axisGrid: string;
22
+ axisLine: string;
23
+ axisTick: string;
24
+ separator: string;
25
+ tooltipBackground: string;
26
+ tooltipBorder: string;
27
+ tooltipDivider: string;
28
+ tooltipMarkerShadow: string;
29
+ tooltipShadow: string;
30
+ };
31
+ export declare const getChartVisualTokens: (theme: VisualizationTheme) => ChartVisualTokens;
@@ -0,0 +1,64 @@
1
+ export var CHART_FONT_FAMILY = 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';
2
+ export var CHART_STYLE_DEFAULTS = {
3
+ animationDuration: 260,
4
+ interactionDelay: 40,
5
+ lineWidth: 2.5,
6
+ areaOpacity: 0.24,
7
+ lineOpacity: 0.92,
8
+ inactiveOpacity: 0.24,
9
+ pointSize: 3.5,
10
+ scatterPointSize: 5,
11
+ pointLineWidth: 1.5,
12
+ pointActiveLineWidth: 5,
13
+ intervalWidthRatio: 0.64
14
+ };
15
+ var LIGHT_TOKENS = {
16
+ background: '#FFFFFF',
17
+ textPrimary: '#1F2937',
18
+ textSecondary: '#667085',
19
+ grid: '#E7EAF0',
20
+ axisGrid: '#EAECF0',
21
+ axisLine: '#D0D5DD',
22
+ axisTick: '#98A2B3',
23
+ separator: '#FFFFFF',
24
+ tooltipBackground: 'rgba(255, 255, 255, 0.96)',
25
+ tooltipBorder: 'rgba(15, 23, 42, 0.09)',
26
+ tooltipDivider: 'rgba(15, 23, 42, 0.08)',
27
+ tooltipMarkerShadow: '0 0 0 2px #FFFFFF, 0 1px 3px rgba(15, 23, 42, 0.20)',
28
+ 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
+ var DARK_TOKENS = {
31
+ background: '#141414',
32
+ textPrimary: '#F3F4F6',
33
+ textSecondary: '#A7AFBE',
34
+ grid: '#343841',
35
+ axisGrid: '#2B2F36',
36
+ axisLine: '#454B56',
37
+ axisTick: '#596170',
38
+ separator: '#141414',
39
+ tooltipBackground: 'rgba(26, 27, 31, 0.96)',
40
+ tooltipBorder: 'rgba(255, 255, 255, 0.12)',
41
+ tooltipDivider: 'rgba(255, 255, 255, 0.10)',
42
+ tooltipMarkerShadow: '0 0 0 2px #1A1B1F, 0 1px 3px rgba(0, 0, 0, 0.42)',
43
+ 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
+ };
45
+ var ACADEMY_TOKENS = {
46
+ background: '#FFFFFF',
47
+ textPrimary: '#23262D',
48
+ textSecondary: '#626975',
49
+ grid: '#DDDDDD',
50
+ axisGrid: '#DDDDDD',
51
+ axisLine: '#888888',
52
+ axisTick: '#000000',
53
+ separator: '#FFFFFF',
54
+ tooltipBackground: 'rgba(255, 253, 249, 0.98)',
55
+ tooltipBorder: 'rgba(83, 72, 60, 0.14)',
56
+ tooltipDivider: 'rgba(83, 72, 60, 0.12)',
57
+ tooltipMarkerShadow: '0 0 0 2px #FFFDF9, 0 1px 3px rgba(63, 49, 38, 0.20)',
58
+ 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
+ };
60
+ 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
+ };