@antv/gpt-vis 1.0.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -36
- package/README.zh-CN.md +113 -36
- 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/resolve.d.ts +7 -0
- package/dist/cjs/theme/resolve.js +58 -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 +107 -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 +7 -2
- package/dist/cjs/util/crosshair-axis-labels.js +144 -30
- package/dist/cjs/util/html.d.ts +1 -0
- package/dist/cjs/util/html.js +29 -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 +13 -10
- 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 +87 -51
- 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 -6
- package/dist/cjs/vis/funnel/index.js +77 -58
- 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 +56 -8
- 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/resolve.d.ts +7 -0
- package/dist/esm/theme/resolve.js +27 -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 +107 -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 +7 -2
- package/dist/esm/util/crosshair-axis-labels.js +156 -35
- package/dist/esm/util/html.d.ts +1 -0
- package/dist/esm/util/html.js +3 -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 +13 -10
- 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 +97 -57
- 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 -6
- package/dist/esm/vis/funnel/index.js +78 -68
- 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 +48 -11
- 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,84 @@
|
|
|
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
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
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; }
|
|
13
|
+
import { getChartVisualTokens } from "../util/tokens";
|
|
14
|
+
import { mergeTheme } from "./merge";
|
|
15
|
+
import { resolveTheme } from "./resolve";
|
|
16
|
+
import { normalizePalette, pickStyle } from "./shared";
|
|
17
|
+
var ELEMENT_KEYS = ['stroke', 'strokeOpacity', 'lineWidth', 'lineDash', 'opacity', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'radius', 'labelFill', 'labelFontFamily', 'labelFontSize', 'labelFontWeight'];
|
|
18
|
+
var TITLE_KEYS = ['align', 'spacing', 'titleFill', 'titleFillOpacity', 'titleFontFamily', 'titleFontSize', 'titleFontWeight', 'subtitleFill', 'subtitleFillOpacity', 'subtitleFontFamily', 'subtitleFontSize', 'subtitleFontWeight'];
|
|
19
|
+
export function getThemeObject(type, theme, localStyle) {
|
|
20
|
+
var _style$node, _style$edge, _t$spacingSmall, _t$spacingMedium;
|
|
21
|
+
var _resolveTheme = resolveTheme(type, theme, localStyle),
|
|
22
|
+
baseTheme = _resolveTheme.baseTheme,
|
|
23
|
+
t = _resolveTheme.tokens,
|
|
24
|
+
styles = _resolveTheme.styles;
|
|
25
|
+
var text = {
|
|
26
|
+
labelFontFamily: t.fontFamily,
|
|
27
|
+
labelFontSize: t.fontSize,
|
|
28
|
+
labelFontWeight: t.fontWeight
|
|
29
|
+
};
|
|
30
|
+
var paint = {
|
|
31
|
+
stroke: t.colorStroke,
|
|
32
|
+
lineWidth: t.lineWidth,
|
|
33
|
+
radius: t.radius
|
|
34
|
+
};
|
|
35
|
+
var style = mergeTheme.apply(void 0, [{
|
|
36
|
+
node: _objectSpread(_objectSpread(_objectSpread({}, paint), text), {}, {
|
|
37
|
+
labelFill: t.colorText
|
|
38
|
+
}),
|
|
39
|
+
edge: _objectSpread(_objectSpread({
|
|
40
|
+
stroke: t.colorStroke,
|
|
41
|
+
lineWidth: t.lineWidth
|
|
42
|
+
}, text), {}, {
|
|
43
|
+
labelFill: t.colorTextSecondary
|
|
44
|
+
})
|
|
45
|
+
}].concat(_toConsumableArray(styles)));
|
|
46
|
+
// Keep branch/category fills and hierarchy contrast unless explicitly overridden.
|
|
47
|
+
var nodeStyle = pickStyle(style.node, [].concat(ELEMENT_KEYS, ['fill', 'fillOpacity']));
|
|
48
|
+
var edgeStyle = pickStyle(style.edge, ELEMENT_KEYS);
|
|
49
|
+
var nodeType = (_style$node = style.node) === null || _style$node === void 0 ? void 0 : _style$node.type;
|
|
50
|
+
var edgeType = (_style$edge = style.edge) === null || _style$edge === void 0 ? void 0 : _style$edge.type;
|
|
51
|
+
var values = getChartVisualTokens(baseTheme);
|
|
52
|
+
return {
|
|
53
|
+
baseTheme: baseTheme,
|
|
54
|
+
theme: baseTheme === 'dark' ? 'dark' : 'light',
|
|
55
|
+
colors: normalizePalette(style.palette, baseTheme),
|
|
56
|
+
backgroundColor: style.backgroundColor || values.background,
|
|
57
|
+
node: {
|
|
58
|
+
type: type === 'network-graph' && ['circle', 'diamond', 'ellipse', 'hexagon', 'rect', 'star', 'triangle'].includes(String(nodeType)) ? String(nodeType) : undefined,
|
|
59
|
+
style: nodeStyle
|
|
60
|
+
},
|
|
61
|
+
edge: {
|
|
62
|
+
type: type === 'network-graph' && ['line', 'polyline', 'quadratic', 'cubic'].includes(String(edgeType)) ? String(edgeType) : undefined,
|
|
63
|
+
style: edgeStyle
|
|
64
|
+
},
|
|
65
|
+
titleStyle: _objectSpread({
|
|
66
|
+
titleFill: baseTheme === 'dark' ? '#e0e6ed' : '#000',
|
|
67
|
+
titleFontFamily: 'sans-serif',
|
|
68
|
+
subtitleFill: values.textSecondary
|
|
69
|
+
}, pickStyle(style.title, TITLE_KEYS)),
|
|
70
|
+
tooltipStyle: pickStyle({
|
|
71
|
+
background: t.colorSurface,
|
|
72
|
+
color: t.colorText,
|
|
73
|
+
borderColor: t.colorStroke,
|
|
74
|
+
borderWidth: t.lineWidth === undefined ? undefined : "".concat(t.lineWidth, "px"),
|
|
75
|
+
borderRadius: t.radius === undefined ? undefined : "".concat(t.radius, "px"),
|
|
76
|
+
fontFamily: t.fontFamily,
|
|
77
|
+
fontSize: t.fontSize === undefined ? undefined : "".concat(t.fontSize, "px"),
|
|
78
|
+
fontWeight: t.fontWeight,
|
|
79
|
+
lineHeight: t.lineHeight === undefined ? undefined : "".concat(t.lineHeight, "px"),
|
|
80
|
+
padding: t.spacingSmall === undefined && t.spacingMedium === undefined ? undefined : "".concat((_t$spacingSmall = t.spacingSmall) !== null && _t$spacingSmall !== void 0 ? _t$spacingSmall : 8, "px ").concat((_t$spacingMedium = t.spacingMedium) !== null && _t$spacingMedium !== void 0 ? _t$spacingMedium : 10, "px")
|
|
81
|
+
}),
|
|
82
|
+
texture: style.texture
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
/** Theme objects merge recursively; arrays replace and undefined keeps the previous value. */
|
|
13
|
+
export function mergeTheme() {
|
|
14
|
+
var result = {};
|
|
15
|
+
for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
sources[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
for (var _i = 0, _sources = sources; _i < _sources.length; _i++) {
|
|
19
|
+
var source = _sources[_i];
|
|
20
|
+
for (var _i2 = 0, _Object$entries = Object.entries(source !== null && source !== void 0 ? source : {}); _i2 < _Object$entries.length; _i2++) {
|
|
21
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
|
|
22
|
+
key = _Object$entries$_i[0],
|
|
23
|
+
value = _Object$entries$_i[1];
|
|
24
|
+
if (value === undefined || key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
result[key] = _toConsumableArray(value);
|
|
27
|
+
} else if (value && _typeof(value) === 'object') {
|
|
28
|
+
var previous = result[key];
|
|
29
|
+
result[key] = mergeTheme(previous && _typeof(previous) === 'object' && !Array.isArray(previous) ? previous : undefined, value);
|
|
30
|
+
} else {
|
|
31
|
+
result[key] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
@@ -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,27 @@
|
|
|
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
|
+
/** Keep the override layers in order; each renderer expands only its own tokens. */
|
|
3
|
+
export function resolveTheme(type, theme, localStyle) {
|
|
4
|
+
var _spec$tokens, _spec$baseTheme, _ref, _tokens$category, _spec$charts;
|
|
5
|
+
var spec = _typeof(theme) === 'object' ? theme : undefined;
|
|
6
|
+
var tokens = (_spec$tokens = spec === null || spec === void 0 ? void 0 : spec.tokens) !== null && _spec$tokens !== void 0 ? _spec$tokens : {};
|
|
7
|
+
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';
|
|
8
|
+
var baseTheme = name === 'dark' || name === 'academy' ? name : 'light';
|
|
9
|
+
return {
|
|
10
|
+
baseTheme: baseTheme,
|
|
11
|
+
tokens: tokens,
|
|
12
|
+
styles: [{
|
|
13
|
+
backgroundColor: tokens.colorBackground,
|
|
14
|
+
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,
|
|
15
|
+
title: {
|
|
16
|
+
titleFill: tokens.colorText,
|
|
17
|
+
subtitleFill: tokens.colorTextSecondary,
|
|
18
|
+
titleFontFamily: tokens.fontFamily,
|
|
19
|
+
subtitleFontFamily: tokens.fontFamily,
|
|
20
|
+
titleFontSize: tokens.fontSize === undefined ? undefined : tokens.fontSize + 4,
|
|
21
|
+
subtitleFontSize: tokens.fontSize,
|
|
22
|
+
titleFontWeight: tokens.fontWeight,
|
|
23
|
+
spacing: tokens.spacingMedium
|
|
24
|
+
}
|
|
25
|
+
}, 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]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -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) 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 { ThemeSpec } from './theme';
|
|
2
|
+
export type { ChartType, ThemeSpec, ThemeStyle, ThemeTokens } from './theme';
|
|
3
|
+
/** Built-in visualization themes supported by GPT-Vis. */
|
|
4
|
+
export type VisualizationTheme = 'default' | 'light' | 'dark' | 'academy' | 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,107 @@
|
|
|
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
|
+
/** Reusable visual theme. Local chart config takes precedence over this spec. */
|
|
3
|
+
export interface ThemeSpec {
|
|
4
|
+
/** Stable identifier; does not register a theme name. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Human-readable theme name. */
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
baseTheme?: string;
|
|
10
|
+
tokens?: ThemeTokens;
|
|
11
|
+
/** Shared visual overrides, applied after token expansion. */
|
|
12
|
+
style?: ThemeStyle;
|
|
13
|
+
/** Additional visual overrides for individual chart types. */
|
|
14
|
+
charts?: Partial<Record<ChartType, {
|
|
15
|
+
style?: ThemeStyle;
|
|
16
|
+
}>>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Visual style namespaces. Each adapter consumes the supported appearance fields;
|
|
20
|
+
* data, layout and behavior remain part of the chart configuration.
|
|
21
|
+
*/
|
|
22
|
+
export interface ThemeStyle {
|
|
23
|
+
backgroundColor?: string;
|
|
24
|
+
palette?: string[];
|
|
25
|
+
title?: Record<string, unknown>;
|
|
26
|
+
axis?: Record<string, unknown>;
|
|
27
|
+
legend?: Record<string, unknown>;
|
|
28
|
+
label?: Record<string, unknown>;
|
|
29
|
+
mark?: {
|
|
30
|
+
line?: Record<string, unknown>;
|
|
31
|
+
area?: Record<string, unknown>;
|
|
32
|
+
point?: Record<string, unknown>;
|
|
33
|
+
interval?: Record<string, unknown>;
|
|
34
|
+
box?: Record<string, unknown>;
|
|
35
|
+
connector?: Record<string, unknown>;
|
|
36
|
+
path?: Record<string, unknown>;
|
|
37
|
+
density?: Record<string, unknown>;
|
|
38
|
+
link?: Record<string, unknown>;
|
|
39
|
+
liquid?: Record<string, unknown>;
|
|
40
|
+
treemap?: Record<string, unknown>;
|
|
41
|
+
sankey?: Record<string, unknown>;
|
|
42
|
+
wordCloud?: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
node?: Record<string, unknown>;
|
|
45
|
+
edge?: Record<string, unknown>;
|
|
46
|
+
table?: {
|
|
47
|
+
header?: Record<string, unknown>;
|
|
48
|
+
cell?: Record<string, unknown>;
|
|
49
|
+
border?: Record<string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
summary?: Record<string, unknown>;
|
|
52
|
+
/** Fishbone drawing texture. */
|
|
53
|
+
texture?: 'rough' | 'default';
|
|
54
|
+
/** @deprecated Line, Area and Radar: use `mark.line.lineWidth`. */
|
|
55
|
+
lineWidth?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* High-frequency seed tokens for authoring a GPT-Vis theme.
|
|
59
|
+
*
|
|
60
|
+
* Names reuse G2, G6 and T8 terminology where it is stable and semantic.
|
|
61
|
+
* Renderer adapters expand these seeds into concrete component and mark styles.
|
|
62
|
+
*/
|
|
63
|
+
export interface ThemeTokens {
|
|
64
|
+
/** Primary series or emphasis color. Matches G2's seed token name. */
|
|
65
|
+
colorDefault?: string;
|
|
66
|
+
/** Canvas background. Matches G2's seed token name. */
|
|
67
|
+
colorBackground?: string;
|
|
68
|
+
/** Table/Liquid surfaces and existing tooltip backgrounds. */
|
|
69
|
+
colorSurface?: string;
|
|
70
|
+
/** Primary text color across G2 components, G6 labels, Table and T8. */
|
|
71
|
+
colorText?: string;
|
|
72
|
+
/** Secondary text used by subtitles, axes and supporting copy. */
|
|
73
|
+
colorTextSecondary?: string;
|
|
74
|
+
/** Text displayed on a contrasting filled surface. */
|
|
75
|
+
colorTextInverse?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Base structural stroke color. The resolver derives axes, grids, borders,
|
|
78
|
+
* nodes and edges from this value. The name matches G2's seed token.
|
|
79
|
+
*/
|
|
80
|
+
colorStroke?: string;
|
|
81
|
+
/** Positive semantic color. Matches T8's seed token name. */
|
|
82
|
+
colorPositive?: string;
|
|
83
|
+
/** Negative semantic color. Matches T8's seed token name. */
|
|
84
|
+
colorNegative?: string;
|
|
85
|
+
/** Neutral semantic color for unchanged or unknown status. */
|
|
86
|
+
colorNeutral?: string;
|
|
87
|
+
/** Primary categorical palette. Matches G2's theme field and seed token name. */
|
|
88
|
+
category10?: string[];
|
|
89
|
+
/** Extended categorical palette. Matches G2's theme field and seed token name. */
|
|
90
|
+
category20?: string[];
|
|
91
|
+
/** Base font family. Matches T8 and renderer text style names. */
|
|
92
|
+
fontFamily?: string;
|
|
93
|
+
/** Base font size in pixels. Matches T8 and renderer text style names. */
|
|
94
|
+
fontSize?: number;
|
|
95
|
+
/** Base font weight. Matches renderer text style names. */
|
|
96
|
+
fontWeight?: number | 'normal' | 'bold';
|
|
97
|
+
/** Line height in pixels for G2 labels/legend text, Summary and existing tooltips. */
|
|
98
|
+
lineHeight?: number;
|
|
99
|
+
/** Compact gap in pixels: axis labels, legend spacing and tooltip vertical padding. */
|
|
100
|
+
spacingSmall?: number;
|
|
101
|
+
/** Roomier gap in pixels: title/subtitle, axes, legends, table cells and tooltip horizontal padding. */
|
|
102
|
+
spacingMedium?: number;
|
|
103
|
+
/** Default mark and structural line width. */
|
|
104
|
+
lineWidth?: number;
|
|
105
|
+
/** Default corner radius for intervals, nodes and surfaces. */
|
|
106
|
+
radius?: number;
|
|
107
|
+
}
|
|
@@ -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
|
+
};
|