@antv/gpt-vis 1.0.2 → 1.3.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.
- package/README.md +53 -7
- package/README.zh-CN.md +32 -9
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/theme/g2.d.ts +9 -0
- package/dist/cjs/theme/g2.js +605 -0
- package/dist/cjs/theme/g6.d.ts +28 -0
- package/dist/cjs/theme/g6.js +124 -0
- package/dist/cjs/theme/merge.d.ts +2 -0
- package/dist/cjs/theme/merge.js +49 -0
- package/dist/cjs/theme/presets.d.ts +5 -0
- package/dist/cjs/theme/presets.js +663 -0
- package/dist/cjs/theme/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +59 -0
- package/dist/cjs/theme/shared.d.ts +7 -0
- package/dist/cjs/theme/shared.js +61 -0
- package/dist/cjs/theme/summary.d.ts +11 -0
- package/dist/cjs/theme/summary.js +61 -0
- package/dist/cjs/theme/table.d.ts +13 -0
- package/dist/cjs/theme/table.js +121 -0
- package/dist/cjs/types/index.d.ts +8 -5
- package/dist/cjs/types/theme.d.ts +109 -0
- package/dist/cjs/types/theme.js +17 -0
- package/dist/cjs/util/animation.js +6 -1
- package/dist/cjs/util/components.d.ts +20 -0
- package/dist/cjs/util/components.js +40 -0
- package/dist/cjs/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/cjs/util/crosshair-axis-labels.js +17 -0
- package/dist/cjs/util/index.d.ts +0 -2
- package/dist/cjs/util/index.js +1 -5
- package/dist/cjs/util/interaction.d.ts +4 -3
- package/dist/cjs/util/interaction.js +14 -1
- package/dist/cjs/util/tokens.d.ts +4 -3
- package/dist/cjs/util/tokens.js +9 -6
- package/dist/cjs/vis/area/index.d.ts +3 -6
- package/dist/cjs/vis/area/index.js +43 -30
- package/dist/cjs/vis/bar/index.d.ts +5 -5
- package/dist/cjs/vis/bar/index.js +34 -20
- package/dist/cjs/vis/boxplot/index.d.ts +4 -5
- package/dist/cjs/vis/boxplot/index.js +36 -23
- package/dist/cjs/vis/column/index.d.ts +5 -5
- package/dist/cjs/vis/column/index.js +38 -26
- package/dist/cjs/vis/dual-axes/index.d.ts +3 -4
- package/dist/cjs/vis/dual-axes/index.js +70 -52
- package/dist/cjs/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/cjs/vis/fishbone-diagram/index.js +43 -28
- package/dist/cjs/vis/flow-diagram/index.d.ts +4 -6
- package/dist/cjs/vis/flow-diagram/index.js +21 -22
- package/dist/cjs/vis/funnel/index.d.ts +3 -5
- package/dist/cjs/vis/funnel/index.js +63 -42
- package/dist/cjs/vis/histogram/index.d.ts +4 -6
- package/dist/cjs/vis/histogram/index.js +17 -19
- package/dist/cjs/vis/indented-tree/index.d.ts +4 -6
- package/dist/cjs/vis/indented-tree/index.js +58 -34
- package/dist/cjs/vis/line/index.d.ts +3 -6
- package/dist/cjs/vis/line/index.js +43 -22
- package/dist/cjs/vis/liquid/index.d.ts +4 -6
- package/dist/cjs/vis/liquid/index.js +22 -17
- package/dist/cjs/vis/mindmap/index.d.ts +4 -6
- package/dist/cjs/vis/mindmap/index.js +43 -25
- package/dist/cjs/vis/network-graph/index.d.ts +4 -6
- package/dist/cjs/vis/network-graph/index.js +26 -20
- package/dist/cjs/vis/organization-chart/index.d.ts +4 -6
- package/dist/cjs/vis/organization-chart/index.js +39 -33
- package/dist/cjs/vis/pie/index.d.ts +3 -5
- package/dist/cjs/vis/pie/index.js +45 -26
- package/dist/cjs/vis/radar/index.d.ts +3 -6
- package/dist/cjs/vis/radar/index.js +32 -24
- package/dist/cjs/vis/sankey/index.d.ts +4 -6
- package/dist/cjs/vis/sankey/index.js +17 -7
- package/dist/cjs/vis/scatter/index.d.ts +3 -5
- package/dist/cjs/vis/scatter/index.js +32 -19
- package/dist/cjs/vis/summary/index.js +5 -6
- package/dist/cjs/vis/table/index.d.ts +4 -2
- package/dist/cjs/vis/table/index.js +46 -4
- package/dist/cjs/vis/treemap/index.d.ts +4 -6
- package/dist/cjs/vis/treemap/index.js +11 -7
- package/dist/cjs/vis/venn/index.d.ts +4 -6
- package/dist/cjs/vis/venn/index.js +18 -16
- package/dist/cjs/vis/violin/index.d.ts +4 -5
- package/dist/cjs/vis/violin/index.js +35 -27
- package/dist/cjs/vis/waterfall/index.d.ts +4 -4
- package/dist/cjs/vis/waterfall/index.js +48 -39
- package/dist/cjs/vis/word-cloud/index.d.ts +3 -5
- package/dist/cjs/vis/word-cloud/index.js +18 -12
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/theme/g2.d.ts +9 -0
- package/dist/esm/theme/g2.js +504 -0
- package/dist/esm/theme/g6.d.ts +28 -0
- package/dist/esm/theme/g6.js +84 -0
- package/dist/esm/theme/merge.d.ts +2 -0
- package/dist/esm/theme/merge.js +36 -0
- package/dist/esm/theme/presets.d.ts +5 -0
- package/dist/esm/theme/presets.js +1070 -0
- package/dist/esm/theme/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +31 -0
- package/dist/esm/theme/shared.d.ts +7 -0
- package/dist/esm/theme/shared.js +21 -0
- package/dist/esm/theme/summary.d.ts +11 -0
- package/dist/esm/theme/summary.js +45 -0
- package/dist/esm/theme/table.d.ts +13 -0
- package/dist/esm/theme/table.js +112 -0
- package/dist/esm/types/index.d.ts +8 -5
- package/dist/esm/types/theme.d.ts +109 -0
- package/dist/esm/types/theme.js +1 -0
- package/dist/esm/util/animation.js +12 -2
- package/dist/esm/util/components.d.ts +20 -0
- package/dist/esm/util/components.js +57 -1
- package/dist/esm/util/crosshair-axis-labels.d.ts +1 -2
- package/dist/esm/util/crosshair-axis-labels.js +18 -0
- package/dist/esm/util/index.d.ts +0 -2
- package/dist/esm/util/index.js +1 -3
- package/dist/esm/util/interaction.d.ts +4 -3
- package/dist/esm/util/interaction.js +18 -1
- package/dist/esm/util/tokens.d.ts +4 -3
- package/dist/esm/util/tokens.js +9 -6
- package/dist/esm/vis/area/index.d.ts +3 -6
- package/dist/esm/vis/area/index.js +53 -45
- package/dist/esm/vis/bar/index.d.ts +5 -5
- package/dist/esm/vis/bar/index.js +38 -27
- package/dist/esm/vis/boxplot/index.d.ts +4 -5
- package/dist/esm/vis/boxplot/index.js +47 -29
- package/dist/esm/vis/column/index.d.ts +5 -5
- package/dist/esm/vis/column/index.js +46 -36
- package/dist/esm/vis/dual-axes/index.d.ts +3 -4
- package/dist/esm/vis/dual-axes/index.js +68 -58
- package/dist/esm/vis/fishbone-diagram/index.d.ts +4 -10
- package/dist/esm/vis/fishbone-diagram/index.js +52 -27
- package/dist/esm/vis/flow-diagram/index.d.ts +4 -6
- package/dist/esm/vis/flow-diagram/index.js +28 -23
- package/dist/esm/vis/funnel/index.d.ts +3 -5
- package/dist/esm/vis/funnel/index.js +63 -54
- package/dist/esm/vis/histogram/index.d.ts +4 -6
- package/dist/esm/vis/histogram/index.js +28 -21
- package/dist/esm/vis/indented-tree/index.d.ts +4 -6
- package/dist/esm/vis/indented-tree/index.js +59 -52
- package/dist/esm/vis/line/index.d.ts +3 -6
- package/dist/esm/vis/line/index.js +44 -32
- package/dist/esm/vis/liquid/index.d.ts +4 -6
- package/dist/esm/vis/liquid/index.js +28 -21
- package/dist/esm/vis/mindmap/index.d.ts +4 -6
- package/dist/esm/vis/mindmap/index.js +32 -28
- package/dist/esm/vis/network-graph/index.d.ts +4 -6
- package/dist/esm/vis/network-graph/index.js +37 -22
- package/dist/esm/vis/organization-chart/index.d.ts +4 -6
- package/dist/esm/vis/organization-chart/index.js +47 -36
- package/dist/esm/vis/pie/index.d.ts +3 -5
- package/dist/esm/vis/pie/index.js +42 -26
- package/dist/esm/vis/radar/index.d.ts +3 -6
- package/dist/esm/vis/radar/index.js +28 -20
- package/dist/esm/vis/sankey/index.d.ts +4 -6
- package/dist/esm/vis/sankey/index.js +20 -10
- package/dist/esm/vis/scatter/index.d.ts +3 -5
- package/dist/esm/vis/scatter/index.js +32 -21
- package/dist/esm/vis/summary/index.js +5 -7
- package/dist/esm/vis/table/index.d.ts +4 -2
- package/dist/esm/vis/table/index.js +41 -4
- package/dist/esm/vis/treemap/index.d.ts +4 -6
- package/dist/esm/vis/treemap/index.js +16 -11
- package/dist/esm/vis/venn/index.d.ts +4 -6
- package/dist/esm/vis/venn/index.js +24 -16
- package/dist/esm/vis/violin/index.d.ts +4 -5
- package/dist/esm/vis/violin/index.js +45 -37
- package/dist/esm/vis/waterfall/index.d.ts +4 -4
- package/dist/esm/vis/waterfall/index.js +46 -36
- package/dist/esm/vis/word-cloud/index.d.ts +3 -5
- package/dist/esm/vis/word-cloud/index.js +24 -17
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/util/theme.d.ts +0 -20
- package/dist/cjs/util/theme.js +0 -372
- package/dist/esm/util/theme.d.ts +0 -20
- package/dist/esm/util/theme.js +0 -326
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChartType, ThemeStyle, VisualizationTheme } from '../types';
|
|
2
|
+
/** Keep the override layers in order; each renderer expands only its own tokens. */
|
|
3
|
+
export declare function resolveTheme(type: ChartType, theme?: VisualizationTheme, localStyle?: ThemeStyle): {
|
|
4
|
+
baseTheme: "light" | "dark" | "academy";
|
|
5
|
+
tokens: import("../types").ThemeTokens;
|
|
6
|
+
styles: (ThemeStyle | undefined)[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
import { THEME_PRESETS } from "./presets";
|
|
3
|
+
|
|
4
|
+
/** Keep the override layers in order; each renderer expands only its own tokens. */
|
|
5
|
+
export function resolveTheme(type, theme, localStyle) {
|
|
6
|
+
var _spec$tokens, _spec$baseTheme, _ref, _tokens$category, _spec$charts;
|
|
7
|
+
var spec = _typeof(theme) === 'object' ? theme : THEME_PRESETS.find(function (preset) {
|
|
8
|
+
return preset.id === theme;
|
|
9
|
+
});
|
|
10
|
+
var tokens = (_spec$tokens = spec === null || spec === void 0 ? void 0 : spec.tokens) !== null && _spec$tokens !== void 0 ? _spec$tokens : {};
|
|
11
|
+
var name = (_spec$baseTheme = spec === null || spec === void 0 ? void 0 : spec.baseTheme) !== null && _spec$baseTheme !== void 0 ? _spec$baseTheme : typeof theme === 'string' ? theme : 'default';
|
|
12
|
+
var baseTheme = name === 'dark' || name === 'academy' ? name : 'light';
|
|
13
|
+
return {
|
|
14
|
+
baseTheme: baseTheme,
|
|
15
|
+
tokens: tokens,
|
|
16
|
+
styles: [{
|
|
17
|
+
backgroundColor: tokens.colorBackground,
|
|
18
|
+
palette: (_ref = (_tokens$category = tokens.category10) !== null && _tokens$category !== void 0 ? _tokens$category : tokens.category20) !== null && _ref !== void 0 ? _ref : tokens.colorDefault ? [tokens.colorDefault] : undefined,
|
|
19
|
+
title: {
|
|
20
|
+
titleFill: tokens.colorText,
|
|
21
|
+
subtitleFill: tokens.colorTextSecondary,
|
|
22
|
+
titleFontFamily: tokens.fontFamily,
|
|
23
|
+
subtitleFontFamily: tokens.fontFamily,
|
|
24
|
+
titleFontSize: tokens.fontSize === undefined ? undefined : tokens.fontSize + 4,
|
|
25
|
+
subtitleFontSize: tokens.fontSize,
|
|
26
|
+
titleFontWeight: tokens.fontWeight,
|
|
27
|
+
spacing: tokens.spacingMedium
|
|
28
|
+
}
|
|
29
|
+
}, spec === null || spec === void 0 ? void 0 : spec.style, spec === null || spec === void 0 || (_spec$charts = spec.charts) === null || _spec$charts === void 0 || (_spec$charts = _spec$charts[type]) === null || _spec$charts === void 0 ? void 0 : _spec$charts.style, localStyle]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const DEFAULT_COLOR_PALETTE: string[];
|
|
2
|
+
export declare const ACADEMY_COLOR_PALETTE: string[];
|
|
3
|
+
export declare const normalizePalette: (palette: string | string[] | undefined, theme: string) => string[];
|
|
4
|
+
/** Renderer field whitelists consume appearance fields only. */
|
|
5
|
+
export declare const pickStyle: (style: Record<string, any> | undefined, keys?: readonly string[]) => {
|
|
6
|
+
[k: string]: any;
|
|
7
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
|
+
export var DEFAULT_COLOR_PALETTE = ['#5B6CFF', '#2DAF9E', '#F2B84B', '#EF6A6A', '#55A6D9', '#3AA76D', '#F58A57', '#8B6FD6', '#D96C9B'];
|
|
8
|
+
export var ACADEMY_COLOR_PALETTE = ['#4e79a7', '#f28e2c', '#e15759', '#76b7b2', '#59a14f', '#edc949', '#af7aa1', '#ff9da7', '#9c755f', '#bab0ab'];
|
|
9
|
+
export var normalizePalette = function normalizePalette(palette, theme) {
|
|
10
|
+
return palette && (!Array.isArray(palette) || palette.length) ? Array.isArray(palette) ? _toConsumableArray(palette) : [palette] : _toConsumableArray(theme === 'academy' ? ACADEMY_COLOR_PALETTE : DEFAULT_COLOR_PALETTE);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Renderer field whitelists consume appearance fields only. */
|
|
14
|
+
export var pickStyle = function pickStyle(style) {
|
|
15
|
+
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Object.keys(style !== null && style !== void 0 ? style : {});
|
|
16
|
+
return Object.fromEntries(keys.filter(function (key) {
|
|
17
|
+
return (style === null || style === void 0 ? void 0 : style[key]) !== undefined;
|
|
18
|
+
}).map(function (key) {
|
|
19
|
+
return [key, style[key]];
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ThemeStyle, VisualizationTheme } from '../types';
|
|
2
|
+
export declare function getThemeObject(type: 'summary', theme?: VisualizationTheme, localStyle?: ThemeStyle): {
|
|
3
|
+
theme: "light" | "dark";
|
|
4
|
+
backgrounds: {
|
|
5
|
+
light: string;
|
|
6
|
+
dark: string;
|
|
7
|
+
};
|
|
8
|
+
summary: {
|
|
9
|
+
[k: string]: any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
|
+
import { getChartVisualTokens } from "../util/tokens";
|
|
8
|
+
import { mergeTheme } from "./merge";
|
|
9
|
+
import { resolveTheme } from "./resolve";
|
|
10
|
+
import { pickStyle } from "./shared";
|
|
11
|
+
export function getThemeObject(type, theme, localStyle) {
|
|
12
|
+
var _style$backgroundColo, _style$backgroundColo2;
|
|
13
|
+
var _resolveTheme = resolveTheme(type, theme, localStyle),
|
|
14
|
+
baseTheme = _resolveTheme.baseTheme,
|
|
15
|
+
t = _resolveTheme.tokens,
|
|
16
|
+
styles = _resolveTheme.styles;
|
|
17
|
+
var summary = {
|
|
18
|
+
fontFamily: t.fontFamily,
|
|
19
|
+
fontSize: t.fontSize,
|
|
20
|
+
lineHeight: t.lineHeight,
|
|
21
|
+
borderColor: t.colorStroke,
|
|
22
|
+
colorBase: t.colorText,
|
|
23
|
+
colorEntityBase: t.colorText,
|
|
24
|
+
colorHeadingBase: t.colorText,
|
|
25
|
+
colorPositive: t.colorPositive,
|
|
26
|
+
colorNegative: t.colorNegative,
|
|
27
|
+
colorConclusion: t.colorText,
|
|
28
|
+
colorDimensionValue: t.colorText,
|
|
29
|
+
colorMetricName: t.colorText,
|
|
30
|
+
colorMetricValue: t.colorDefault,
|
|
31
|
+
colorOtherValue: t.colorNeutral,
|
|
32
|
+
colorLink: t.colorDefault
|
|
33
|
+
};
|
|
34
|
+
var style = mergeTheme.apply(void 0, [{
|
|
35
|
+
summary: summary
|
|
36
|
+
}].concat(_toConsumableArray(styles)));
|
|
37
|
+
return {
|
|
38
|
+
theme: baseTheme === 'dark' ? 'dark' : 'light',
|
|
39
|
+
backgrounds: {
|
|
40
|
+
light: (_style$backgroundColo = style.backgroundColor) !== null && _style$backgroundColo !== void 0 ? _style$backgroundColo : '',
|
|
41
|
+
dark: (_style$backgroundColo2 = style.backgroundColor) !== null && _style$backgroundColo2 !== void 0 ? _style$backgroundColo2 : getChartVisualTokens('dark').background
|
|
42
|
+
},
|
|
43
|
+
summary: pickStyle(style.summary, Object.keys(summary))
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ThemeStyle, VisualizationTheme } from '../types';
|
|
2
|
+
export declare function getThemeObject(type: 'table', theme?: VisualizationTheme, localStyle?: ThemeStyle): {
|
|
3
|
+
theme: "light" | "dark";
|
|
4
|
+
backgroundColor: string | undefined;
|
|
5
|
+
title: Record<string, string>;
|
|
6
|
+
subtitle: Record<string, string>;
|
|
7
|
+
header: Record<string, string>;
|
|
8
|
+
cell: Record<string, string>;
|
|
9
|
+
border: {
|
|
10
|
+
table: Record<string, string>;
|
|
11
|
+
cell: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
|
+
import { mergeTheme } from "./merge";
|
|
8
|
+
import { resolveTheme } from "./resolve";
|
|
9
|
+
export function getThemeObject(type, theme, localStyle) {
|
|
10
|
+
var _style$title, _title$titleFillOpaci, _title$titleFontWeigh, _title$subtitleFillOp, _title$subtitleFontWe, _style$table, _style$table2, _style$table3;
|
|
11
|
+
var _resolveTheme = resolveTheme(type, theme, localStyle),
|
|
12
|
+
baseTheme = _resolveTheme.baseTheme,
|
|
13
|
+
t = _resolveTheme.tokens,
|
|
14
|
+
styles = _resolveTheme.styles;
|
|
15
|
+
var cell = {
|
|
16
|
+
fontFamily: t.fontFamily,
|
|
17
|
+
fontSize: t.fontSize,
|
|
18
|
+
fontWeight: t.fontWeight,
|
|
19
|
+
fill: t.colorText,
|
|
20
|
+
backgroundColor: t.colorSurface,
|
|
21
|
+
padding: t.spacingMedium
|
|
22
|
+
};
|
|
23
|
+
var style = mergeTheme.apply(void 0, [{
|
|
24
|
+
table: {
|
|
25
|
+
header: cell,
|
|
26
|
+
cell: cell,
|
|
27
|
+
border: {
|
|
28
|
+
color: t.colorStroke,
|
|
29
|
+
width: t.lineWidth,
|
|
30
|
+
radius: t.radius
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}].concat(_toConsumableArray(styles)));
|
|
34
|
+
var title = (_style$title = style.title) !== null && _style$title !== void 0 ? _style$title : {};
|
|
35
|
+
return {
|
|
36
|
+
theme: baseTheme === 'dark' ? 'dark' : 'light',
|
|
37
|
+
backgroundColor: style.backgroundColor,
|
|
38
|
+
title: compactStyle({
|
|
39
|
+
color: title.titleFill,
|
|
40
|
+
opacity: (_title$titleFillOpaci = title.titleFillOpacity) === null || _title$titleFillOpaci === void 0 ? void 0 : _title$titleFillOpaci.toString(),
|
|
41
|
+
fontFamily: title.titleFontFamily,
|
|
42
|
+
fontSize: toPixels(title.titleFontSize),
|
|
43
|
+
fontWeight: (_title$titleFontWeigh = title.titleFontWeight) === null || _title$titleFontWeigh === void 0 ? void 0 : _title$titleFontWeigh.toString(),
|
|
44
|
+
textAlign: title.align
|
|
45
|
+
}),
|
|
46
|
+
subtitle: compactStyle({
|
|
47
|
+
color: title.subtitleFill,
|
|
48
|
+
opacity: (_title$subtitleFillOp = title.subtitleFillOpacity) === null || _title$subtitleFillOp === void 0 ? void 0 : _title$subtitleFillOp.toString(),
|
|
49
|
+
fontFamily: title.subtitleFontFamily,
|
|
50
|
+
fontSize: toPixels(title.subtitleFontSize),
|
|
51
|
+
fontWeight: (_title$subtitleFontWe = title.subtitleFontWeight) === null || _title$subtitleFontWe === void 0 ? void 0 : _title$subtitleFontWe.toString(),
|
|
52
|
+
marginTop: toPixels(title.spacing),
|
|
53
|
+
textAlign: title.align
|
|
54
|
+
}),
|
|
55
|
+
header: adaptTableCellStyle((_style$table = style.table) === null || _style$table === void 0 ? void 0 : _style$table.header),
|
|
56
|
+
cell: adaptTableCellStyle((_style$table2 = style.table) === null || _style$table2 === void 0 ? void 0 : _style$table2.cell),
|
|
57
|
+
border: adaptTableBorderStyle((_style$table3 = style.table) === null || _style$table3 === void 0 ? void 0 : _style$table3.border)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
var toPixels = function toPixels(value) {
|
|
61
|
+
return value === undefined ? undefined : "".concat(value, "px");
|
|
62
|
+
};
|
|
63
|
+
var toPadding = function toPadding(value) {
|
|
64
|
+
if (value === undefined) return undefined;
|
|
65
|
+
if (typeof value === 'number') return toPixels(value);
|
|
66
|
+
return value.map(toPixels).join(' ');
|
|
67
|
+
};
|
|
68
|
+
var compactStyle = function compactStyle(style) {
|
|
69
|
+
return Object.fromEntries(Object.entries(style).filter(function (entry) {
|
|
70
|
+
return !!entry[1];
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Translate table header/cell text and box styles to safe DOM declarations. */
|
|
75
|
+
var adaptTableCellStyle = function adaptTableCellStyle(style) {
|
|
76
|
+
var _style$fontWeight;
|
|
77
|
+
return compactStyle({
|
|
78
|
+
color: style === null || style === void 0 ? void 0 : style.fill,
|
|
79
|
+
backgroundColor: style === null || style === void 0 ? void 0 : style.backgroundColor,
|
|
80
|
+
padding: toPadding(style === null || style === void 0 ? void 0 : style.padding),
|
|
81
|
+
fontFamily: style === null || style === void 0 ? void 0 : style.fontFamily,
|
|
82
|
+
fontSize: toPixels(style === null || style === void 0 ? void 0 : style.fontSize),
|
|
83
|
+
fontWeight: style === null || style === void 0 || (_style$fontWeight = style.fontWeight) === null || _style$fontWeight === void 0 ? void 0 : _style$fontWeight.toString(),
|
|
84
|
+
fontStyle: style === null || style === void 0 ? void 0 : style.fontStyle,
|
|
85
|
+
lineHeight: toPixels(style === null || style === void 0 ? void 0 : style.lineHeight)
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Translate one table border contract to outer and row-separator DOM styles. */
|
|
90
|
+
var adaptTableBorderStyle = function adaptTableBorderStyle(style) {
|
|
91
|
+
var _style$width, _style$style, _style$color;
|
|
92
|
+
if (!style || Object.keys(style).length === 0) return {
|
|
93
|
+
table: {},
|
|
94
|
+
cell: {}
|
|
95
|
+
};
|
|
96
|
+
var width = toPixels((_style$width = style.width) !== null && _style$width !== void 0 ? _style$width : 1);
|
|
97
|
+
var lineStyle = (_style$style = style.style) !== null && _style$style !== void 0 ? _style$style : 'solid';
|
|
98
|
+
var color = (_style$color = style.color) !== null && _style$color !== void 0 ? _style$color : 'currentColor';
|
|
99
|
+
return {
|
|
100
|
+
table: compactStyle({
|
|
101
|
+
borderColor: color,
|
|
102
|
+
borderWidth: width,
|
|
103
|
+
borderStyle: lineStyle,
|
|
104
|
+
borderRadius: toPixels(style.radius)
|
|
105
|
+
}),
|
|
106
|
+
cell: compactStyle({
|
|
107
|
+
borderBottomColor: color,
|
|
108
|
+
borderBottomWidth: width,
|
|
109
|
+
borderBottomStyle: lineStyle
|
|
110
|
+
})
|
|
111
|
+
};
|
|
112
|
+
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { BuiltinThemeName, ThemeSpec } from './theme';
|
|
2
|
+
export type { BuiltinThemeName, ChartType, ThemeSpec, ThemeStyle, ThemeTokens } from './theme';
|
|
3
|
+
/** Built-in visualization themes supported by GPT-Vis. */
|
|
4
|
+
export type VisualizationTheme = BuiltinThemeName | ThemeSpec;
|
|
5
|
+
/** Common construction options shared by every visualization. */
|
|
6
6
|
export interface VisualizationOptions {
|
|
7
7
|
container: string | HTMLElement;
|
|
8
8
|
width?: number;
|
|
9
9
|
height?: number;
|
|
10
|
+
/** A built-in theme name or reusable ThemeSpec. Defaults to `default`. */
|
|
10
11
|
theme?: VisualizationTheme;
|
|
12
|
+
/** Whether to render the outer wrapper. Defaults to `false`. */
|
|
11
13
|
wrapper?: boolean;
|
|
14
|
+
/** Locale used by user-facing labels and number formatting. */
|
|
12
15
|
locale?: string;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export type ChartType = 'area' | 'bar' | 'boxplot' | 'column' | 'dual-axes' | 'fishbone-diagram' | 'flow-diagram' | 'funnel' | 'histogram' | 'indented-tree' | 'line' | 'liquid' | 'mindmap' | 'network-graph' | 'organization-chart' | 'pie' | 'radar' | 'sankey' | 'scatter' | 'summary' | 'table' | 'treemap' | 'venn' | 'violin' | 'waterfall' | 'word-cloud';
|
|
2
|
+
/** Stable names accepted by the constructor, chart JSON, and visualization Syntax. */
|
|
3
|
+
export type BuiltinThemeName = 'default' | 'light' | 'dark' | 'academy' | 'gpt-vis' | 'midnight' | 'paper' | 'product' | 'neon-circuit' | 'terra-print' | 'mono-signal' | 'candy-pop' | 'pop' | 'bauhaus';
|
|
4
|
+
/** Reusable visual theme. Local chart config takes precedence over this spec. */
|
|
5
|
+
export interface ThemeSpec {
|
|
6
|
+
/** Stable identifier; does not register a theme name. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Human-readable theme name. */
|
|
9
|
+
label: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
baseTheme?: string;
|
|
12
|
+
tokens?: ThemeTokens;
|
|
13
|
+
/** Shared visual overrides, applied after token expansion. */
|
|
14
|
+
style?: ThemeStyle;
|
|
15
|
+
/** Additional visual overrides for individual chart types. */
|
|
16
|
+
charts?: Partial<Record<ChartType, {
|
|
17
|
+
style?: ThemeStyle;
|
|
18
|
+
}>>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Visual style namespaces. Each adapter consumes the supported appearance fields;
|
|
22
|
+
* data, layout and behavior remain part of the chart configuration.
|
|
23
|
+
*/
|
|
24
|
+
export interface ThemeStyle {
|
|
25
|
+
backgroundColor?: string;
|
|
26
|
+
palette?: string[];
|
|
27
|
+
title?: Record<string, unknown>;
|
|
28
|
+
axis?: Record<string, unknown>;
|
|
29
|
+
legend?: Record<string, unknown>;
|
|
30
|
+
label?: Record<string, unknown>;
|
|
31
|
+
mark?: {
|
|
32
|
+
line?: Record<string, unknown>;
|
|
33
|
+
area?: Record<string, unknown>;
|
|
34
|
+
point?: Record<string, unknown>;
|
|
35
|
+
interval?: Record<string, unknown>;
|
|
36
|
+
box?: Record<string, unknown>;
|
|
37
|
+
connector?: Record<string, unknown>;
|
|
38
|
+
path?: Record<string, unknown>;
|
|
39
|
+
density?: Record<string, unknown>;
|
|
40
|
+
link?: Record<string, unknown>;
|
|
41
|
+
liquid?: Record<string, unknown>;
|
|
42
|
+
treemap?: Record<string, unknown>;
|
|
43
|
+
sankey?: Record<string, unknown>;
|
|
44
|
+
wordCloud?: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
node?: Record<string, unknown>;
|
|
47
|
+
edge?: Record<string, unknown>;
|
|
48
|
+
table?: {
|
|
49
|
+
header?: Record<string, unknown>;
|
|
50
|
+
cell?: Record<string, unknown>;
|
|
51
|
+
border?: Record<string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
summary?: Record<string, unknown>;
|
|
54
|
+
/** Fishbone drawing texture. */
|
|
55
|
+
texture?: 'rough' | 'default';
|
|
56
|
+
/** @deprecated Line, Area and Radar: use `mark.line.lineWidth`. */
|
|
57
|
+
lineWidth?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* High-frequency seed tokens for authoring a GPT-Vis theme.
|
|
61
|
+
*
|
|
62
|
+
* Names reuse G2, G6 and T8 terminology where it is stable and semantic.
|
|
63
|
+
* Renderer adapters expand these seeds into concrete component and mark styles.
|
|
64
|
+
*/
|
|
65
|
+
export interface ThemeTokens {
|
|
66
|
+
/** Primary series or emphasis color. Matches G2's seed token name. */
|
|
67
|
+
colorDefault?: string;
|
|
68
|
+
/** Canvas background. Matches G2's seed token name. */
|
|
69
|
+
colorBackground?: string;
|
|
70
|
+
/** Table/Liquid surfaces and existing tooltip backgrounds. */
|
|
71
|
+
colorSurface?: string;
|
|
72
|
+
/** Primary text color across G2 components, G6 labels, Table and T8. */
|
|
73
|
+
colorText?: string;
|
|
74
|
+
/** Secondary text used by subtitles, axes and supporting copy. */
|
|
75
|
+
colorTextSecondary?: string;
|
|
76
|
+
/** Text displayed on a contrasting filled surface. */
|
|
77
|
+
colorTextInverse?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Base structural stroke color. The resolver derives axes, grids, borders,
|
|
80
|
+
* nodes and edges from this value. The name matches G2's seed token.
|
|
81
|
+
*/
|
|
82
|
+
colorStroke?: string;
|
|
83
|
+
/** Positive semantic color. Matches T8's seed token name. */
|
|
84
|
+
colorPositive?: string;
|
|
85
|
+
/** Negative semantic color. Matches T8's seed token name. */
|
|
86
|
+
colorNegative?: string;
|
|
87
|
+
/** Neutral semantic color for unchanged or unknown status. */
|
|
88
|
+
colorNeutral?: string;
|
|
89
|
+
/** Primary categorical palette. Matches G2's theme field and seed token name. */
|
|
90
|
+
category10?: string[];
|
|
91
|
+
/** Extended categorical palette. Matches G2's theme field and seed token name. */
|
|
92
|
+
category20?: string[];
|
|
93
|
+
/** Base font family. Matches T8 and renderer text style names. */
|
|
94
|
+
fontFamily?: string;
|
|
95
|
+
/** Base font size in pixels. Matches T8 and renderer text style names. */
|
|
96
|
+
fontSize?: number;
|
|
97
|
+
/** Base font weight. Matches renderer text style names. */
|
|
98
|
+
fontWeight?: number | 'normal' | 'bold';
|
|
99
|
+
/** Line height in pixels for G2 labels/legend text, Summary and existing tooltips. */
|
|
100
|
+
lineHeight?: number;
|
|
101
|
+
/** Compact gap in pixels: axis labels, legend spacing and tooltip vertical padding. */
|
|
102
|
+
spacingSmall?: number;
|
|
103
|
+
/** Roomier gap in pixels: title/subtitle, axes, legends, table cells and tooltip horizontal padding. */
|
|
104
|
+
spacingMedium?: number;
|
|
105
|
+
/** Default mark and structural line width. */
|
|
106
|
+
lineWidth?: number;
|
|
107
|
+
/** Default corner radius for intervals, nodes and surfaces. */
|
|
108
|
+
radius?: number;
|
|
109
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,22 @@
|
|
|
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 } from "./tokens";
|
|
1
8
|
var prefersReducedMotion = function prefersReducedMotion() {
|
|
2
9
|
return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
3
10
|
};
|
|
4
11
|
export var getChartAnimation = function getChartAnimation(hasRendered, enterType) {
|
|
5
12
|
if (hasRendered || prefersReducedMotion()) return false;
|
|
6
13
|
return {
|
|
7
|
-
enter: enterType ? {
|
|
14
|
+
enter: _objectSpread(_objectSpread({}, enterType ? {
|
|
8
15
|
type: enterType
|
|
9
|
-
} : {},
|
|
16
|
+
} : {}), {}, {
|
|
17
|
+
duration: CHART_STYLE_DEFAULTS.animationDuration,
|
|
18
|
+
easing: 'ease-out'
|
|
19
|
+
}),
|
|
10
20
|
update: {
|
|
11
21
|
type: null
|
|
12
22
|
},
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Theme } from '@antv/g2';
|
|
2
|
+
import type { PluginOptions } from '@antv/g6';
|
|
1
3
|
export type ChartLocale = 'en-US' | 'zh-CN';
|
|
2
4
|
export type CartesianXAxisOptions = {
|
|
3
5
|
xLabels?: unknown[];
|
|
@@ -13,3 +15,21 @@ export declare const getCartesianAxis: ({ axisXTitle, axisYTitle, xLabels, chart
|
|
|
13
15
|
export declare const getColorLegend: (visible: boolean) => false | {
|
|
14
16
|
color: Record<string, never>;
|
|
15
17
|
};
|
|
18
|
+
/** Label content and placement belong to the chart; paint comes from the native theme. */
|
|
19
|
+
export declare function getDataLabels(theme: Theme, { visible, defaultVisible, contrast, style, transform, ...content }: {
|
|
20
|
+
visible?: boolean;
|
|
21
|
+
defaultVisible?: boolean;
|
|
22
|
+
contrast?: 'inside' | 'outside';
|
|
23
|
+
style?: Record<string, unknown>;
|
|
24
|
+
transform?: Record<string, unknown>[];
|
|
25
|
+
text: unknown;
|
|
26
|
+
position?: string;
|
|
27
|
+
dx?: number;
|
|
28
|
+
dy?: number;
|
|
29
|
+
formatter?: string;
|
|
30
|
+
}): Record<string, unknown>[] | undefined;
|
|
31
|
+
/** Keep the title plugin's canvas and graph padding in step with its typography. */
|
|
32
|
+
export declare function getGraphTitle(title?: string, subtitle?: string, style?: Record<string, any>): {
|
|
33
|
+
plugins: PluginOptions;
|
|
34
|
+
padding: number | [number, number, number, number];
|
|
35
|
+
};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
var _excluded = ["visible", "defaultVisible", "contrast", "style", "transform"];
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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
11
|
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
12
|
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
13
|
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; }
|
|
@@ -64,4 +73,51 @@ export var getColorLegend = function getColorLegend(visible) {
|
|
|
64
73
|
return visible ? {
|
|
65
74
|
color: {}
|
|
66
75
|
} : false;
|
|
67
|
-
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** Label content and placement belong to the chart; paint comes from the native theme. */
|
|
79
|
+
export function getDataLabels(theme, _ref3) {
|
|
80
|
+
var _theme$label, _theme$innerLabel;
|
|
81
|
+
var visible = _ref3.visible,
|
|
82
|
+
_ref3$defaultVisible = _ref3.defaultVisible,
|
|
83
|
+
defaultVisible = _ref3$defaultVisible === void 0 ? false : _ref3$defaultVisible,
|
|
84
|
+
contrast = _ref3.contrast,
|
|
85
|
+
style = _ref3.style,
|
|
86
|
+
transform = _ref3.transform,
|
|
87
|
+
content = _objectWithoutProperties(_ref3, _excluded);
|
|
88
|
+
if (visible === false) return [];
|
|
89
|
+
if (visible !== true && !defaultVisible) return undefined;
|
|
90
|
+
var paint = contrast === 'inside' ? theme.innerLabel : theme.label;
|
|
91
|
+
var textColor = (_theme$label = theme.label) === null || _theme$label === void 0 ? void 0 : _theme$label.fill;
|
|
92
|
+
var inverseColor = (_theme$innerLabel = theme.innerLabel) === null || _theme$innerLabel === void 0 ? void 0 : _theme$innerLabel.fill;
|
|
93
|
+
var contrastTransform = contrast === 'inside' && textColor !== inverseColor ? [{
|
|
94
|
+
type: 'contrastReverse',
|
|
95
|
+
palette: [textColor, inverseColor]
|
|
96
|
+
}] : [];
|
|
97
|
+
var transforms = [].concat(contrastTransform, _toConsumableArray(transform !== null && transform !== void 0 ? transform : []));
|
|
98
|
+
return [_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, content), transforms.length ? {
|
|
99
|
+
transform: transforms
|
|
100
|
+
} : {}), style), paint)];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Keep the title plugin's canvas and graph padding in step with its typography. */
|
|
104
|
+
export function getGraphTitle(title, subtitle) {
|
|
105
|
+
var _style$titleFontSize, _style$spacing, _style$subtitleFontSi;
|
|
106
|
+
var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
107
|
+
if (!title) return {
|
|
108
|
+
plugins: [],
|
|
109
|
+
padding: 20
|
|
110
|
+
};
|
|
111
|
+
var contentHeight = Math.ceil(((_style$titleFontSize = style.titleFontSize) !== null && _style$titleFontSize !== void 0 ? _style$titleFontSize : 16) * 1.2) + (subtitle ? ((_style$spacing = style.spacing) !== null && _style$spacing !== void 0 ? _style$spacing : 8) + Math.ceil(((_style$subtitleFontSi = style.subtitleFontSize) !== null && _style$subtitleFontSi !== void 0 ? _style$subtitleFontSi : 12) * 1.2) : 0);
|
|
112
|
+
return {
|
|
113
|
+
plugins: [_objectSpread(_objectSpread({
|
|
114
|
+
key: 'title',
|
|
115
|
+
type: 'title',
|
|
116
|
+
title: title,
|
|
117
|
+
subtitle: subtitle
|
|
118
|
+
}, style), {}, {
|
|
119
|
+
size: Math.max(44, contentHeight)
|
|
120
|
+
})],
|
|
121
|
+
padding: [Math.max(46, Math.ceil(contentHeight + 24)), 20, 20, 20]
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Chart } from '@antv/g2';
|
|
2
|
-
import type { VisualizationTheme } from '../types';
|
|
3
2
|
export type CrosshairAxisLabelsOptions = {
|
|
4
3
|
showXLabel?: boolean;
|
|
5
4
|
useStandaloneYLabel?: boolean;
|
|
@@ -12,4 +11,4 @@ export type CrosshairAxisLabelsOptions = {
|
|
|
12
11
|
* G2 does not currently expose axis tags for tooltip crosshairs, so this adapter
|
|
13
12
|
* reads the rule geometry created by G2 5.4 and renders labels with LineCrosshair.
|
|
14
13
|
*/
|
|
15
|
-
export declare const bindCrosshairAxisLabels: (chart: Chart, theme:
|
|
14
|
+
export declare const bindCrosshairAxisLabels: (chart: Chart, theme: string, { showXLabel, useStandaloneYLabel, yAxisPosition, yField, }?: CrosshairAxisLabelsOptions) => (() => void);
|
|
@@ -15,6 +15,7 @@ import { LineCrosshair, Tag } from '@antv/component';
|
|
|
15
15
|
import { selectPlotArea } from '@antv/g2';
|
|
16
16
|
import { CHART_FONT_FAMILY, getChartVisualTokens } from "./tokens";
|
|
17
17
|
var MAX_CROSSHAIR_DECIMAL_PLACES = 6;
|
|
18
|
+
var CROSSHAIR_LABEL_MARGIN = 4;
|
|
18
19
|
var formatCrosshairAxisValue = function formatCrosshairAxisValue(value, formatter, precision) {
|
|
19
20
|
if (value === undefined || value === null || value === '') return '';
|
|
20
21
|
var displayValue = value;
|
|
@@ -110,6 +111,20 @@ var getStandaloneTagStyle = function getStandaloneTagStyle(theme, tokens) {
|
|
|
110
111
|
var clamp = function clamp(value, min, max) {
|
|
111
112
|
return Math.min(Math.max(value, Math.min(min, max)), Math.max(min, max));
|
|
112
113
|
};
|
|
114
|
+
var keepTagInCanvas = function keepTagInCanvas(tag, canvas) {
|
|
115
|
+
if (!tag || !canvas) return;
|
|
116
|
+
var _canvas$getConfig = canvas.getConfig(),
|
|
117
|
+
width = _canvas$getConfig.width,
|
|
118
|
+
height = _canvas$getConfig.height;
|
|
119
|
+
if (width === undefined || height === undefined) return;
|
|
120
|
+
var _tag$getBounds = tag.getBounds(),
|
|
121
|
+
min = _tag$getBounds.min,
|
|
122
|
+
max = _tag$getBounds.max;
|
|
123
|
+
var margin = CROSSHAIR_LABEL_MARGIN;
|
|
124
|
+
var dx = Math.max(margin - min[0], Math.min(0, width - margin - max[0]));
|
|
125
|
+
var dy = Math.max(margin - min[1], Math.min(0, height - margin - max[1]));
|
|
126
|
+
if (dx || dy) tag.translate(dx, dy);
|
|
127
|
+
};
|
|
113
128
|
var invertCrosshairValue = function invertCrosshairValue(scale, value) {
|
|
114
129
|
if (!scale || typeof scale.invert !== 'function' || value === undefined) return undefined;
|
|
115
130
|
if (typeof scale.getBandWidth === 'function') {
|
|
@@ -389,11 +404,13 @@ export var bindCrosshairAxisLabels = function bindCrosshairAxisLabels(chart, the
|
|
|
389
404
|
xCrosshair.setText(xText);
|
|
390
405
|
xCrosshair.setPointer([x + plotX, verticalRule.y2 + plotY]);
|
|
391
406
|
xCrosshair.style.visibility = 'visible';
|
|
407
|
+
keepTagInCanvas(xCrosshair.querySelector('.crosshair-tag'), context.canvas);
|
|
392
408
|
}
|
|
393
409
|
if (yCrosshair) {
|
|
394
410
|
yCrosshair.setText(yText);
|
|
395
411
|
yCrosshair.setPointer([(yAxisPosition === 'right' ? horizontalRule.x2 : horizontalRule.x1) + plotX, y + plotY]);
|
|
396
412
|
yCrosshair.style.visibility = 'visible';
|
|
413
|
+
keepTagInCanvas(yCrosshair.querySelector('.crosshair-tag'), context.canvas);
|
|
397
414
|
}
|
|
398
415
|
if (standaloneYTag) {
|
|
399
416
|
var yAxisX = getYAxisLinePosition(view, yField, yAxisPosition, yAxisPosition === 'right' ? horizontalRule.x2 : horizontalRule.x1, plotX);
|
|
@@ -402,6 +419,7 @@ export var bindCrosshairAxisLabels = function bindCrosshairAxisLabels(chart, the
|
|
|
402
419
|
});
|
|
403
420
|
standaloneYTag.setLocalPosition([yAxisX + plotX, y + plotY]);
|
|
404
421
|
standaloneYTag.style.visibility = 'visible';
|
|
422
|
+
keepTagInCanvas(standaloneYTag, context.canvas);
|
|
405
423
|
}
|
|
406
424
|
};
|
|
407
425
|
var onPointerMove = function onPointerMove(event) {
|
package/dist/esm/util/index.d.ts
CHANGED
package/dist/esm/util/index.js
CHANGED
|
@@ -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:
|
|
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,
|
|
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>;
|