@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,59 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/theme/resolve.ts
|
|
20
|
+
var resolve_exports = {};
|
|
21
|
+
__export(resolve_exports, {
|
|
22
|
+
resolveTheme: () => resolveTheme
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(resolve_exports);
|
|
25
|
+
var import_presets = require("./presets");
|
|
26
|
+
function resolveTheme(type, theme, localStyle) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const spec = typeof theme === "object" ? theme : import_presets.THEME_PRESETS.find((preset) => preset.id === theme);
|
|
29
|
+
const tokens = (spec == null ? void 0 : spec.tokens) ?? {};
|
|
30
|
+
const name = (spec == null ? void 0 : spec.baseTheme) ?? (typeof theme === "string" ? theme : "default");
|
|
31
|
+
const baseTheme = name === "dark" || name === "academy" ? name : "light";
|
|
32
|
+
return {
|
|
33
|
+
baseTheme,
|
|
34
|
+
tokens,
|
|
35
|
+
styles: [
|
|
36
|
+
{
|
|
37
|
+
backgroundColor: tokens.colorBackground,
|
|
38
|
+
palette: tokens.category10 ?? tokens.category20 ?? (tokens.colorDefault ? [tokens.colorDefault] : void 0),
|
|
39
|
+
title: {
|
|
40
|
+
titleFill: tokens.colorText,
|
|
41
|
+
subtitleFill: tokens.colorTextSecondary,
|
|
42
|
+
titleFontFamily: tokens.fontFamily,
|
|
43
|
+
subtitleFontFamily: tokens.fontFamily,
|
|
44
|
+
titleFontSize: tokens.fontSize === void 0 ? void 0 : tokens.fontSize + 4,
|
|
45
|
+
subtitleFontSize: tokens.fontSize,
|
|
46
|
+
titleFontWeight: tokens.fontWeight,
|
|
47
|
+
spacing: tokens.spacingMedium
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
spec == null ? void 0 : spec.style,
|
|
51
|
+
(_b = (_a = spec == null ? void 0 : spec.charts) == null ? void 0 : _a[type]) == null ? void 0 : _b.style,
|
|
52
|
+
localStyle
|
|
53
|
+
]
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
resolveTheme
|
|
59
|
+
});
|
|
@@ -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,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/theme/shared.ts
|
|
20
|
+
var shared_exports = {};
|
|
21
|
+
__export(shared_exports, {
|
|
22
|
+
ACADEMY_COLOR_PALETTE: () => ACADEMY_COLOR_PALETTE,
|
|
23
|
+
DEFAULT_COLOR_PALETTE: () => DEFAULT_COLOR_PALETTE,
|
|
24
|
+
normalizePalette: () => normalizePalette,
|
|
25
|
+
pickStyle: () => pickStyle
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(shared_exports);
|
|
28
|
+
var DEFAULT_COLOR_PALETTE = [
|
|
29
|
+
"#5B6CFF",
|
|
30
|
+
"#2DAF9E",
|
|
31
|
+
"#F2B84B",
|
|
32
|
+
"#EF6A6A",
|
|
33
|
+
"#55A6D9",
|
|
34
|
+
"#3AA76D",
|
|
35
|
+
"#F58A57",
|
|
36
|
+
"#8B6FD6",
|
|
37
|
+
"#D96C9B"
|
|
38
|
+
];
|
|
39
|
+
var ACADEMY_COLOR_PALETTE = [
|
|
40
|
+
"#4e79a7",
|
|
41
|
+
"#f28e2c",
|
|
42
|
+
"#e15759",
|
|
43
|
+
"#76b7b2",
|
|
44
|
+
"#59a14f",
|
|
45
|
+
"#edc949",
|
|
46
|
+
"#af7aa1",
|
|
47
|
+
"#ff9da7",
|
|
48
|
+
"#9c755f",
|
|
49
|
+
"#bab0ab"
|
|
50
|
+
];
|
|
51
|
+
var normalizePalette = (palette, theme) => palette && (!Array.isArray(palette) || palette.length) ? Array.isArray(palette) ? [...palette] : [palette] : [...theme === "academy" ? ACADEMY_COLOR_PALETTE : DEFAULT_COLOR_PALETTE];
|
|
52
|
+
var pickStyle = (style, keys = Object.keys(style ?? {})) => Object.fromEntries(
|
|
53
|
+
keys.filter((key) => (style == null ? void 0 : style[key]) !== void 0).map((key) => [key, style[key]])
|
|
54
|
+
);
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
ACADEMY_COLOR_PALETTE,
|
|
58
|
+
DEFAULT_COLOR_PALETTE,
|
|
59
|
+
normalizePalette,
|
|
60
|
+
pickStyle
|
|
61
|
+
});
|
|
@@ -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,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/theme/summary.ts
|
|
20
|
+
var summary_exports = {};
|
|
21
|
+
__export(summary_exports, {
|
|
22
|
+
getThemeObject: () => getThemeObject
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(summary_exports);
|
|
25
|
+
var import_tokens = require("../util/tokens");
|
|
26
|
+
var import_merge = require("./merge");
|
|
27
|
+
var import_resolve = require("./resolve");
|
|
28
|
+
var import_shared = require("./shared");
|
|
29
|
+
function getThemeObject(type, theme, localStyle) {
|
|
30
|
+
const { baseTheme, tokens: t, styles } = (0, import_resolve.resolveTheme)(type, theme, localStyle);
|
|
31
|
+
const summary = {
|
|
32
|
+
fontFamily: t.fontFamily,
|
|
33
|
+
fontSize: t.fontSize,
|
|
34
|
+
lineHeight: t.lineHeight,
|
|
35
|
+
borderColor: t.colorStroke,
|
|
36
|
+
colorBase: t.colorText,
|
|
37
|
+
colorEntityBase: t.colorText,
|
|
38
|
+
colorHeadingBase: t.colorText,
|
|
39
|
+
colorPositive: t.colorPositive,
|
|
40
|
+
colorNegative: t.colorNegative,
|
|
41
|
+
colorConclusion: t.colorText,
|
|
42
|
+
colorDimensionValue: t.colorText,
|
|
43
|
+
colorMetricName: t.colorText,
|
|
44
|
+
colorMetricValue: t.colorDefault,
|
|
45
|
+
colorOtherValue: t.colorNeutral,
|
|
46
|
+
colorLink: t.colorDefault
|
|
47
|
+
};
|
|
48
|
+
const style = (0, import_merge.mergeTheme)({ summary }, ...styles);
|
|
49
|
+
return {
|
|
50
|
+
theme: baseTheme === "dark" ? "dark" : "light",
|
|
51
|
+
backgrounds: {
|
|
52
|
+
light: style.backgroundColor ?? "",
|
|
53
|
+
dark: style.backgroundColor ?? (0, import_tokens.getChartVisualTokens)("dark").background
|
|
54
|
+
},
|
|
55
|
+
summary: (0, import_shared.pickStyle)(style.summary, Object.keys(summary))
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
getThemeObject
|
|
61
|
+
});
|
|
@@ -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,121 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/theme/table.ts
|
|
20
|
+
var table_exports = {};
|
|
21
|
+
__export(table_exports, {
|
|
22
|
+
getThemeObject: () => getThemeObject
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(table_exports);
|
|
25
|
+
var import_merge = require("./merge");
|
|
26
|
+
var import_resolve = require("./resolve");
|
|
27
|
+
function getThemeObject(type, theme, localStyle) {
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
29
|
+
const { baseTheme, tokens: t, styles } = (0, import_resolve.resolveTheme)(type, theme, localStyle);
|
|
30
|
+
const cell = {
|
|
31
|
+
fontFamily: t.fontFamily,
|
|
32
|
+
fontSize: t.fontSize,
|
|
33
|
+
fontWeight: t.fontWeight,
|
|
34
|
+
fill: t.colorText,
|
|
35
|
+
backgroundColor: t.colorSurface,
|
|
36
|
+
padding: t.spacingMedium
|
|
37
|
+
};
|
|
38
|
+
const style = (0, import_merge.mergeTheme)(
|
|
39
|
+
{
|
|
40
|
+
table: {
|
|
41
|
+
header: cell,
|
|
42
|
+
cell,
|
|
43
|
+
border: { color: t.colorStroke, width: t.lineWidth, radius: t.radius }
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
...styles
|
|
47
|
+
);
|
|
48
|
+
const title = style.title ?? {};
|
|
49
|
+
return {
|
|
50
|
+
theme: baseTheme === "dark" ? "dark" : "light",
|
|
51
|
+
backgroundColor: style.backgroundColor,
|
|
52
|
+
title: compactStyle({
|
|
53
|
+
color: title.titleFill,
|
|
54
|
+
opacity: (_a = title.titleFillOpacity) == null ? void 0 : _a.toString(),
|
|
55
|
+
fontFamily: title.titleFontFamily,
|
|
56
|
+
fontSize: toPixels(title.titleFontSize),
|
|
57
|
+
fontWeight: (_b = title.titleFontWeight) == null ? void 0 : _b.toString(),
|
|
58
|
+
textAlign: title.align
|
|
59
|
+
}),
|
|
60
|
+
subtitle: compactStyle({
|
|
61
|
+
color: title.subtitleFill,
|
|
62
|
+
opacity: (_c = title.subtitleFillOpacity) == null ? void 0 : _c.toString(),
|
|
63
|
+
fontFamily: title.subtitleFontFamily,
|
|
64
|
+
fontSize: toPixels(title.subtitleFontSize),
|
|
65
|
+
fontWeight: (_d = title.subtitleFontWeight) == null ? void 0 : _d.toString(),
|
|
66
|
+
marginTop: toPixels(title.spacing),
|
|
67
|
+
textAlign: title.align
|
|
68
|
+
}),
|
|
69
|
+
header: adaptTableCellStyle((_e = style.table) == null ? void 0 : _e.header),
|
|
70
|
+
cell: adaptTableCellStyle((_f = style.table) == null ? void 0 : _f.cell),
|
|
71
|
+
border: adaptTableBorderStyle((_g = style.table) == null ? void 0 : _g.border)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
var toPixels = (value) => value === void 0 ? void 0 : `${value}px`;
|
|
75
|
+
var toPadding = (value) => {
|
|
76
|
+
if (value === void 0)
|
|
77
|
+
return void 0;
|
|
78
|
+
if (typeof value === "number")
|
|
79
|
+
return toPixels(value);
|
|
80
|
+
return value.map(toPixels).join(" ");
|
|
81
|
+
};
|
|
82
|
+
var compactStyle = (style) => Object.fromEntries(
|
|
83
|
+
Object.entries(style).filter((entry) => !!entry[1])
|
|
84
|
+
);
|
|
85
|
+
var adaptTableCellStyle = (style) => {
|
|
86
|
+
var _a;
|
|
87
|
+
return compactStyle({
|
|
88
|
+
color: style == null ? void 0 : style.fill,
|
|
89
|
+
backgroundColor: style == null ? void 0 : style.backgroundColor,
|
|
90
|
+
padding: toPadding(style == null ? void 0 : style.padding),
|
|
91
|
+
fontFamily: style == null ? void 0 : style.fontFamily,
|
|
92
|
+
fontSize: toPixels(style == null ? void 0 : style.fontSize),
|
|
93
|
+
fontWeight: (_a = style == null ? void 0 : style.fontWeight) == null ? void 0 : _a.toString(),
|
|
94
|
+
fontStyle: style == null ? void 0 : style.fontStyle,
|
|
95
|
+
lineHeight: toPixels(style == null ? void 0 : style.lineHeight)
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
var adaptTableBorderStyle = (style) => {
|
|
99
|
+
if (!style || Object.keys(style).length === 0)
|
|
100
|
+
return { table: {}, cell: {} };
|
|
101
|
+
const width = toPixels(style.width ?? 1);
|
|
102
|
+
const lineStyle = style.style ?? "solid";
|
|
103
|
+
const color = style.color ?? "currentColor";
|
|
104
|
+
return {
|
|
105
|
+
table: compactStyle({
|
|
106
|
+
borderColor: color,
|
|
107
|
+
borderWidth: width,
|
|
108
|
+
borderStyle: lineStyle,
|
|
109
|
+
borderRadius: toPixels(style.radius)
|
|
110
|
+
}),
|
|
111
|
+
cell: compactStyle({
|
|
112
|
+
borderBottomColor: color,
|
|
113
|
+
borderBottomWidth: width,
|
|
114
|
+
borderBottomStyle: lineStyle
|
|
115
|
+
})
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
getThemeObject
|
|
121
|
+
});
|
|
@@ -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,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/types/theme.ts
|
|
16
|
+
var theme_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(theme_exports);
|
|
@@ -22,12 +22,17 @@ __export(animation_exports, {
|
|
|
22
22
|
getChartAnimation: () => getChartAnimation
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(animation_exports);
|
|
25
|
+
var import_tokens = require("./tokens");
|
|
25
26
|
var prefersReducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
26
27
|
var getChartAnimation = (hasRendered, enterType) => {
|
|
27
28
|
if (hasRendered || prefersReducedMotion())
|
|
28
29
|
return false;
|
|
29
30
|
return {
|
|
30
|
-
enter:
|
|
31
|
+
enter: {
|
|
32
|
+
...enterType ? { type: enterType } : {},
|
|
33
|
+
duration: import_tokens.CHART_STYLE_DEFAULTS.animationDuration,
|
|
34
|
+
easing: "ease-out"
|
|
35
|
+
},
|
|
31
36
|
update: { type: null },
|
|
32
37
|
exit: { type: null }
|
|
33
38
|
};
|
|
@@ -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
|
+
};
|
|
@@ -22,6 +22,8 @@ __export(components_exports, {
|
|
|
22
22
|
getCartesianAxis: () => getCartesianAxis,
|
|
23
23
|
getCartesianLayout: () => getCartesianLayout,
|
|
24
24
|
getColorLegend: () => getColorLegend,
|
|
25
|
+
getDataLabels: () => getDataLabels,
|
|
26
|
+
getGraphTitle: () => getGraphTitle,
|
|
25
27
|
resolveChartLocale: () => resolveChartLocale
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(components_exports);
|
|
@@ -85,10 +87,48 @@ var getCartesianAxis = ({
|
|
|
85
87
|
};
|
|
86
88
|
};
|
|
87
89
|
var getColorLegend = (visible) => visible ? { color: {} } : false;
|
|
90
|
+
function getDataLabels(theme, {
|
|
91
|
+
visible,
|
|
92
|
+
defaultVisible = false,
|
|
93
|
+
contrast,
|
|
94
|
+
style,
|
|
95
|
+
transform,
|
|
96
|
+
...content
|
|
97
|
+
}) {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
if (visible === false)
|
|
100
|
+
return [];
|
|
101
|
+
if (visible !== true && !defaultVisible)
|
|
102
|
+
return void 0;
|
|
103
|
+
const paint = contrast === "inside" ? theme.innerLabel : theme.label;
|
|
104
|
+
const textColor = (_a = theme.label) == null ? void 0 : _a.fill;
|
|
105
|
+
const inverseColor = (_b = theme.innerLabel) == null ? void 0 : _b.fill;
|
|
106
|
+
const contrastTransform = contrast === "inside" && textColor !== inverseColor ? [{ type: "contrastReverse", palette: [textColor, inverseColor] }] : [];
|
|
107
|
+
const transforms = [...contrastTransform, ...transform ?? []];
|
|
108
|
+
return [
|
|
109
|
+
{ ...content, ...transforms.length ? { transform: transforms } : {}, ...style, ...paint }
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
function getGraphTitle(title, subtitle, style = {}) {
|
|
113
|
+
if (!title)
|
|
114
|
+
return {
|
|
115
|
+
plugins: [],
|
|
116
|
+
padding: 20
|
|
117
|
+
};
|
|
118
|
+
const contentHeight = Math.ceil((style.titleFontSize ?? 16) * 1.2) + (subtitle ? (style.spacing ?? 8) + Math.ceil((style.subtitleFontSize ?? 12) * 1.2) : 0);
|
|
119
|
+
return {
|
|
120
|
+
plugins: [
|
|
121
|
+
{ key: "title", type: "title", title, subtitle, ...style, size: Math.max(44, contentHeight) }
|
|
122
|
+
],
|
|
123
|
+
padding: [Math.max(46, Math.ceil(contentHeight + 24)), 20, 20, 20]
|
|
124
|
+
};
|
|
125
|
+
}
|
|
88
126
|
// Annotate the CommonJS export names for ESM import in node:
|
|
89
127
|
0 && (module.exports = {
|
|
90
128
|
getCartesianAxis,
|
|
91
129
|
getCartesianLayout,
|
|
92
130
|
getColorLegend,
|
|
131
|
+
getDataLabels,
|
|
132
|
+
getGraphTitle,
|
|
93
133
|
resolveChartLocale
|
|
94
134
|
});
|
|
@@ -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);
|
|
@@ -26,6 +26,7 @@ var import_component = require("@antv/component");
|
|
|
26
26
|
var import_g2 = require("@antv/g2");
|
|
27
27
|
var import_tokens = require("./tokens");
|
|
28
28
|
var MAX_CROSSHAIR_DECIMAL_PLACES = 6;
|
|
29
|
+
var CROSSHAIR_LABEL_MARGIN = 4;
|
|
29
30
|
var formatCrosshairAxisValue = (value, formatter, precision) => {
|
|
30
31
|
if (value === void 0 || value === null || value === "")
|
|
31
32
|
return "";
|
|
@@ -120,6 +121,19 @@ var getStandaloneTagStyle = (theme, tokens) => ({
|
|
|
120
121
|
pointerEvents: "none"
|
|
121
122
|
});
|
|
122
123
|
var clamp = (value, min, max) => Math.min(Math.max(value, Math.min(min, max)), Math.max(min, max));
|
|
124
|
+
var keepTagInCanvas = (tag, canvas) => {
|
|
125
|
+
if (!tag || !canvas)
|
|
126
|
+
return;
|
|
127
|
+
const { width, height } = canvas.getConfig();
|
|
128
|
+
if (width === void 0 || height === void 0)
|
|
129
|
+
return;
|
|
130
|
+
const { min, max } = tag.getBounds();
|
|
131
|
+
const margin = CROSSHAIR_LABEL_MARGIN;
|
|
132
|
+
const dx = Math.max(margin - min[0], Math.min(0, width - margin - max[0]));
|
|
133
|
+
const dy = Math.max(margin - min[1], Math.min(0, height - margin - max[1]));
|
|
134
|
+
if (dx || dy)
|
|
135
|
+
tag.translate(dx, dy);
|
|
136
|
+
};
|
|
123
137
|
var invertCrosshairValue = (scale, value) => {
|
|
124
138
|
var _a, _b, _c;
|
|
125
139
|
if (!scale || typeof scale.invert !== "function" || value === void 0)
|
|
@@ -346,6 +360,7 @@ var bindCrosshairAxisLabels = (chart, theme, {
|
|
|
346
360
|
xCrosshair.setText(xText);
|
|
347
361
|
xCrosshair.setPointer([x + plotX, verticalRule.y2 + plotY]);
|
|
348
362
|
xCrosshair.style.visibility = "visible";
|
|
363
|
+
keepTagInCanvas(xCrosshair.querySelector(".crosshair-tag"), context.canvas);
|
|
349
364
|
}
|
|
350
365
|
if (yCrosshair) {
|
|
351
366
|
yCrosshair.setText(yText);
|
|
@@ -354,6 +369,7 @@ var bindCrosshairAxisLabels = (chart, theme, {
|
|
|
354
369
|
y + plotY
|
|
355
370
|
]);
|
|
356
371
|
yCrosshair.style.visibility = "visible";
|
|
372
|
+
keepTagInCanvas(yCrosshair.querySelector(".crosshair-tag"), context.canvas);
|
|
357
373
|
}
|
|
358
374
|
if (standaloneYTag) {
|
|
359
375
|
const yAxisX = getYAxisLinePosition(
|
|
@@ -366,6 +382,7 @@ var bindCrosshairAxisLabels = (chart, theme, {
|
|
|
366
382
|
standaloneYTag.update({ text: yText });
|
|
367
383
|
standaloneYTag.setLocalPosition([yAxisX + plotX, y + plotY]);
|
|
368
384
|
standaloneYTag.style.visibility = "visible";
|
|
385
|
+
keepTagInCanvas(standaloneYTag, context.canvas);
|
|
369
386
|
}
|
|
370
387
|
};
|
|
371
388
|
const onPointerMove = (event) => {
|