@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
|
@@ -23,8 +23,10 @@ __export(word_cloud_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(word_cloud_exports);
|
|
25
25
|
var import_g2 = require("@antv/g2");
|
|
26
|
+
var import_g22 = require("../../theme/g2");
|
|
26
27
|
var import_components = require("../../util/components");
|
|
27
|
-
var
|
|
28
|
+
var import_interaction = require("../../util/interaction");
|
|
29
|
+
var import_tokens = require("../../util/tokens");
|
|
28
30
|
var WORD_CLOUD_MAX_WORDS = 50;
|
|
29
31
|
var WORD_CLOUD_FONT_FAMILY = "Impact";
|
|
30
32
|
var WORD_CLOUD_ROTATIONS = [-90, -60, -30, 0, 30, 60];
|
|
@@ -61,7 +63,6 @@ var createSeededRandom = (seed) => {
|
|
|
61
63
|
return ((value ^ value >>> 14) >>> 0) / 4294967296;
|
|
62
64
|
};
|
|
63
65
|
};
|
|
64
|
-
var getWordCloudPalette = (palette, theme) => (0, import_theme.normalizePalette)(palette, theme);
|
|
65
66
|
var prepareWordCloudData = (data, colors) => {
|
|
66
67
|
const rankedData = data.map((item, index) => ({ item, index })).filter(
|
|
67
68
|
({ item }) => item.text.trim().length > 0 && Number.isFinite(item.value) && item.value > 0
|
|
@@ -97,8 +98,9 @@ var WordCloud = (options) => {
|
|
|
97
98
|
data = [],
|
|
98
99
|
theme = chartTheme,
|
|
99
100
|
title,
|
|
101
|
+
subtitle,
|
|
100
102
|
locale: renderLocale = locale,
|
|
101
|
-
style = {}
|
|
103
|
+
style: localStyle = {}
|
|
102
104
|
} = config;
|
|
103
105
|
const chartLocale = (0, import_components.resolveChartLocale)(renderLocale);
|
|
104
106
|
const labels = WORD_CLOUD_LABELS[chartLocale];
|
|
@@ -112,7 +114,11 @@ var WordCloud = (options) => {
|
|
|
112
114
|
if (chart) {
|
|
113
115
|
chart.destroy();
|
|
114
116
|
}
|
|
115
|
-
const
|
|
117
|
+
const appearance = (0, import_g22.getThemeObject)("word-cloud", theme, localStyle);
|
|
118
|
+
const { theme: rendererTheme } = appearance;
|
|
119
|
+
const colors = rendererTheme.category10;
|
|
120
|
+
const wordCloudStyle = appearance.mark.wordCloud;
|
|
121
|
+
const fontFamily = wordCloudStyle.fontFamily ?? WORD_CLOUD_FONT_FAMILY;
|
|
116
122
|
const preparedData = prepareWordCloudData(data, colors);
|
|
117
123
|
const layoutSeed = hashWordCloudData(preparedData);
|
|
118
124
|
const rotationRandom = createSeededRandom(layoutSeed ^ 2654435769);
|
|
@@ -126,9 +132,9 @@ var WordCloud = (options) => {
|
|
|
126
132
|
animate: false,
|
|
127
133
|
type: "wordCloud",
|
|
128
134
|
data: preparedData,
|
|
129
|
-
title: title
|
|
135
|
+
title: title ? { title, subtitle } : "",
|
|
130
136
|
layout: {
|
|
131
|
-
font:
|
|
137
|
+
font: fontFamily,
|
|
132
138
|
fontSize: [11, 44],
|
|
133
139
|
fontWeight: (d) => d.fontWeight,
|
|
134
140
|
padding: 2,
|
|
@@ -142,9 +148,10 @@ var WordCloud = (options) => {
|
|
|
142
148
|
},
|
|
143
149
|
style: {
|
|
144
150
|
fill: (d) => d.wordColor,
|
|
145
|
-
fontFamily
|
|
151
|
+
fontFamily,
|
|
146
152
|
fontWeight: (d) => d.weight ?? d.fontWeight,
|
|
147
|
-
stroke: (d) => d.wordColor
|
|
153
|
+
stroke: (d) => d.wordColor,
|
|
154
|
+
...wordCloudStyle
|
|
148
155
|
},
|
|
149
156
|
scale: {
|
|
150
157
|
color: { range: colors }
|
|
@@ -179,11 +186,10 @@ var WordCloud = (options) => {
|
|
|
179
186
|
},
|
|
180
187
|
interaction: {
|
|
181
188
|
tooltip: true,
|
|
182
|
-
elementHighlight:
|
|
183
|
-
elementHoverScale:
|
|
189
|
+
elementHighlight: { delay: import_tokens.CHART_STYLE_DEFAULTS.interactionDelay },
|
|
190
|
+
elementHoverScale: (0, import_interaction.getElementHoverScaleInteraction)(rendererTheme.type)
|
|
184
191
|
},
|
|
185
|
-
|
|
186
|
-
theme: (0, import_theme.getThemeObject)(theme)
|
|
192
|
+
theme: rendererTheme
|
|
187
193
|
};
|
|
188
194
|
chart.options(chartOptions);
|
|
189
195
|
chart.render();
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { GPTVis } from './gpt-vis';
|
|
|
2
2
|
export type { GPTVisConfig } from './gpt-vis';
|
|
3
3
|
export { isVisSyntax, parse } from './syntax';
|
|
4
4
|
export type { ParsedConfig } from './syntax';
|
|
5
|
-
export type
|
|
5
|
+
export type * from './types';
|
|
6
6
|
export { Area } from './vis/area';
|
|
7
7
|
export type { AreaConfig, AreaDataItem } from './vis/area';
|
|
8
8
|
export { Bar } from './vis/bar';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Theme } from '@antv/g2';
|
|
2
|
+
import type { ChartType, ThemeStyle, VisualizationTheme } from '../types';
|
|
3
|
+
/** Resolve appearance once. Data, label content, visibility and layout stay in the chart. */
|
|
4
|
+
export declare function getThemeObject(type: ChartType, theme?: VisualizationTheme, localStyle?: ThemeStyle): {
|
|
5
|
+
theme: Theme & {
|
|
6
|
+
type: 'light' | 'dark' | 'academy';
|
|
7
|
+
};
|
|
8
|
+
mark: Record<keyof NonNullable<ThemeStyle['mark']>, Record<string, any>>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
var _excluded = ["axis"];
|
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
|
+
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."); }
|
|
11
|
+
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); }
|
|
12
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
13
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
19
|
+
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); }
|
|
20
|
+
import { CHART_FONT_FAMILY, CHART_STYLE_DEFAULTS, getChartVisualTokens } from "../util/tokens";
|
|
21
|
+
import { mergeTheme } from "./merge";
|
|
22
|
+
import { resolveTheme } from "./resolve";
|
|
23
|
+
import { ACADEMY_COLOR_PALETTE, DEFAULT_COLOR_PALETTE, normalizePalette, pickStyle } from "./shared";
|
|
24
|
+
var createTheme = function createTheme(type) {
|
|
25
|
+
var tokens = getChartVisualTokens(type);
|
|
26
|
+
var isDark = type === 'dark';
|
|
27
|
+
var isAcademy = type === 'academy';
|
|
28
|
+
var colors = isAcademy ? ACADEMY_COLOR_PALETTE : DEFAULT_COLOR_PALETTE;
|
|
29
|
+
return {
|
|
30
|
+
type: type,
|
|
31
|
+
color: colors[0],
|
|
32
|
+
category10: colors,
|
|
33
|
+
category20: colors,
|
|
34
|
+
view: {
|
|
35
|
+
viewFill: tokens.background,
|
|
36
|
+
plotFill: 'transparent',
|
|
37
|
+
mainFill: 'transparent',
|
|
38
|
+
contentFill: 'transparent'
|
|
39
|
+
},
|
|
40
|
+
interval: {
|
|
41
|
+
rect: {
|
|
42
|
+
fillOpacity: 0.96
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
line: {
|
|
46
|
+
line: {
|
|
47
|
+
lineWidth: CHART_STYLE_DEFAULTS.lineWidth
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
area: {
|
|
51
|
+
area: {
|
|
52
|
+
fillOpacity: CHART_STYLE_DEFAULTS.areaOpacity
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
point: {
|
|
56
|
+
point: {
|
|
57
|
+
lineWidth: CHART_STYLE_DEFAULTS.pointLineWidth,
|
|
58
|
+
fillOpacity: 0.82
|
|
59
|
+
},
|
|
60
|
+
hollow: {
|
|
61
|
+
lineWidth: 2,
|
|
62
|
+
strokeOpacity: 1
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
axis: _objectSpread({
|
|
66
|
+
labelAutoHide: {
|
|
67
|
+
keepHeader: true,
|
|
68
|
+
keepTail: true
|
|
69
|
+
},
|
|
70
|
+
titleOpacity: 1,
|
|
71
|
+
titleFillOpacity: 1,
|
|
72
|
+
labelOpacity: 1,
|
|
73
|
+
labelFillOpacity: 1,
|
|
74
|
+
line: true,
|
|
75
|
+
lineLineWidth: 1,
|
|
76
|
+
lineStroke: tokens.axisLine,
|
|
77
|
+
lineStrokeOpacity: 1,
|
|
78
|
+
tick: true,
|
|
79
|
+
tickLineWidth: 1,
|
|
80
|
+
tickStroke: tokens.axisTick,
|
|
81
|
+
tickStrokeOpacity: 1
|
|
82
|
+
}, isAcademy ? {
|
|
83
|
+
titleFill: '#000000',
|
|
84
|
+
titleStrokeOpacity: 1,
|
|
85
|
+
titleFontSize: 11,
|
|
86
|
+
titleFontWeight: 'bold',
|
|
87
|
+
titleSpacing: 12,
|
|
88
|
+
labelFill: '#000000',
|
|
89
|
+
labelStrokeOpacity: 1,
|
|
90
|
+
labelFontSize: 10,
|
|
91
|
+
labelFontWeight: 'normal',
|
|
92
|
+
labelSpacing: 4,
|
|
93
|
+
tickLength: 5
|
|
94
|
+
} : {
|
|
95
|
+
titleFill: tokens.textSecondary,
|
|
96
|
+
titleFontFamily: CHART_FONT_FAMILY,
|
|
97
|
+
titleFontSize: 12,
|
|
98
|
+
titleFontWeight: 500,
|
|
99
|
+
titleLineWidth: 0,
|
|
100
|
+
titleSpacing: 16,
|
|
101
|
+
labelFill: tokens.textSecondary,
|
|
102
|
+
labelFontFamily: CHART_FONT_FAMILY,
|
|
103
|
+
labelFontSize: 12,
|
|
104
|
+
labelFontWeight: 400,
|
|
105
|
+
labelLineWidth: 0,
|
|
106
|
+
labelSpacing: 6,
|
|
107
|
+
tickLength: 3,
|
|
108
|
+
tickOpacity: 1
|
|
109
|
+
}),
|
|
110
|
+
axisX: _objectSpread({
|
|
111
|
+
grid: isAcademy,
|
|
112
|
+
labelAutoRotate: {
|
|
113
|
+
optionalAngles: [0, 45, 90],
|
|
114
|
+
recoverWhenFailed: true
|
|
115
|
+
}
|
|
116
|
+
}, isAcademy ? {
|
|
117
|
+
gridStroke: tokens.axisGrid,
|
|
118
|
+
gridStrokeOpacity: 1,
|
|
119
|
+
gridLineWidth: 1,
|
|
120
|
+
gridLineDash: [0, 0]
|
|
121
|
+
} : {}),
|
|
122
|
+
axisY: {
|
|
123
|
+
lineLineWidth: 1,
|
|
124
|
+
grid: true,
|
|
125
|
+
gridStroke: tokens.axisGrid,
|
|
126
|
+
gridStrokeOpacity: 1,
|
|
127
|
+
gridLineWidth: isAcademy ? 1 : 0.75,
|
|
128
|
+
gridLineDash: isAcademy ? [0, 0] : [3, 3],
|
|
129
|
+
gridFilter: function gridFilter(_, index) {
|
|
130
|
+
return index !== 0;
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
axisRadar: {
|
|
134
|
+
zIndex: 1,
|
|
135
|
+
titleFill: isAcademy ? tokens.textPrimary : tokens.textSecondary,
|
|
136
|
+
titleFontFamily: CHART_FONT_FAMILY,
|
|
137
|
+
titleFontSize: isAcademy ? 10 : 12,
|
|
138
|
+
titleFontWeight: isAcademy ? 600 : 500,
|
|
139
|
+
titleSpacing: 10,
|
|
140
|
+
labelFill: tokens.textSecondary,
|
|
141
|
+
labelOpacity: 1,
|
|
142
|
+
labelFontFamily: CHART_FONT_FAMILY,
|
|
143
|
+
labelFontSize: isAcademy ? 10 : 11,
|
|
144
|
+
line: true,
|
|
145
|
+
lineStroke: tokens.axisLine,
|
|
146
|
+
lineStrokeOpacity: isAcademy ? 1 : 0.64,
|
|
147
|
+
lineLineWidth: isAcademy ? 1 : 0.75,
|
|
148
|
+
tick: true,
|
|
149
|
+
tickLength: isAcademy ? 4 : 2,
|
|
150
|
+
tickStroke: tokens.axisTick,
|
|
151
|
+
tickStrokeOpacity: isAcademy ? 1 : 0.68,
|
|
152
|
+
tickCount: 4,
|
|
153
|
+
gridStroke: tokens.axisGrid,
|
|
154
|
+
gridStrokeOpacity: isAcademy ? 1 : 0.9,
|
|
155
|
+
gridLineWidth: isAcademy ? 1 : 0.75,
|
|
156
|
+
gridLineDash: [0, 0]
|
|
157
|
+
},
|
|
158
|
+
title: {
|
|
159
|
+
spacing: 6,
|
|
160
|
+
titleFill: tokens.textPrimary,
|
|
161
|
+
titleFontSize: 16,
|
|
162
|
+
titleFontWeight: 600,
|
|
163
|
+
subtitleFill: tokens.textSecondary,
|
|
164
|
+
subtitleFontSize: 12,
|
|
165
|
+
subtitleFontWeight: 400
|
|
166
|
+
},
|
|
167
|
+
legendCategory: {
|
|
168
|
+
backgroundFill: 'transparent',
|
|
169
|
+
padding: [5, 0, 10, 0],
|
|
170
|
+
itemMarkerSize: 10,
|
|
171
|
+
itemMarkerFillOpacity: 0.92,
|
|
172
|
+
itemMarkerStrokeOpacity: 0.92,
|
|
173
|
+
itemLabelFill: tokens.textPrimary,
|
|
174
|
+
itemLabelFillOpacity: 0.78,
|
|
175
|
+
itemLabelFontFamily: CHART_FONT_FAMILY,
|
|
176
|
+
itemLabelFontSize: 12,
|
|
177
|
+
itemLabelFontWeight: 400,
|
|
178
|
+
itemLabelLineHeight: 16,
|
|
179
|
+
itemLabelLetterSpacing: 0.1,
|
|
180
|
+
itemLabelTextBaseline: 'middle',
|
|
181
|
+
itemSpacing: [8, 0, 0],
|
|
182
|
+
itemCursor: 'pointer',
|
|
183
|
+
rowPadding: 8,
|
|
184
|
+
colPadding: 22,
|
|
185
|
+
navButtonFill: tokens.textSecondary,
|
|
186
|
+
navButtonFillOpacity: 0.72,
|
|
187
|
+
navButtonSize: 9,
|
|
188
|
+
navPageNumFill: tokens.textSecondary,
|
|
189
|
+
navPageNumFillOpacity: 0.72,
|
|
190
|
+
navPageNumFontFamily: CHART_FONT_FAMILY,
|
|
191
|
+
navPageNumFontSize: 11,
|
|
192
|
+
navPageNumFontWeight: 400,
|
|
193
|
+
navControllerPadding: 4,
|
|
194
|
+
navControllerSpacing: 14
|
|
195
|
+
},
|
|
196
|
+
tooltip: {
|
|
197
|
+
markerR: 4,
|
|
198
|
+
markerLineWidth: 2,
|
|
199
|
+
markerStroke: tokens.background,
|
|
200
|
+
crosshairsStroke: tokens.textSecondary,
|
|
201
|
+
crosshairsStrokeOpacity: 0.18,
|
|
202
|
+
crosshairsLineWidth: 1,
|
|
203
|
+
crosshairsLineDash: [0, 0],
|
|
204
|
+
css: {
|
|
205
|
+
'.g2-tooltip': {
|
|
206
|
+
'background-color': tokens.tooltipBackground,
|
|
207
|
+
border: "1px solid ".concat(tokens.tooltipBorder),
|
|
208
|
+
'border-radius': '10px',
|
|
209
|
+
'box-shadow': tokens.tooltipShadow,
|
|
210
|
+
color: tokens.textSecondary,
|
|
211
|
+
padding: '10px 12px',
|
|
212
|
+
'min-width': '164px',
|
|
213
|
+
'max-width': '300px',
|
|
214
|
+
overflow: 'hidden',
|
|
215
|
+
'box-sizing': 'border-box',
|
|
216
|
+
'backdrop-filter': 'blur(10px) saturate(1.08)',
|
|
217
|
+
'-webkit-backdrop-filter': 'blur(10px) saturate(1.08)',
|
|
218
|
+
'font-family': CHART_FONT_FAMILY,
|
|
219
|
+
'font-size': '12px',
|
|
220
|
+
'line-height': '18px',
|
|
221
|
+
'font-variant-numeric': 'tabular-nums',
|
|
222
|
+
'font-feature-settings': '"tnum" 1, "zero" 1',
|
|
223
|
+
'-webkit-font-smoothing': 'antialiased',
|
|
224
|
+
contain: 'layout paint style'
|
|
225
|
+
},
|
|
226
|
+
'.g2-tooltip-title': {
|
|
227
|
+
color: tokens.textSecondary,
|
|
228
|
+
'font-size': '11px',
|
|
229
|
+
'font-weight': '500',
|
|
230
|
+
'line-height': '16px',
|
|
231
|
+
'letter-spacing': '0.01em',
|
|
232
|
+
'margin-bottom': '6px',
|
|
233
|
+
'padding-bottom': '7px',
|
|
234
|
+
'border-bottom': "1px solid ".concat(tokens.tooltipDivider),
|
|
235
|
+
'max-width': '276px'
|
|
236
|
+
},
|
|
237
|
+
'.g2-tooltip-list': {
|
|
238
|
+
display: 'grid',
|
|
239
|
+
gap: '4px'
|
|
240
|
+
},
|
|
241
|
+
'.g2-tooltip-list-item': {
|
|
242
|
+
display: 'grid',
|
|
243
|
+
'grid-template-columns': 'minmax(0, 1fr) auto',
|
|
244
|
+
'align-items': 'center',
|
|
245
|
+
'column-gap': '18px',
|
|
246
|
+
'min-height': '22px',
|
|
247
|
+
'line-height': '22px'
|
|
248
|
+
},
|
|
249
|
+
'.g2-tooltip-list-item-name': {
|
|
250
|
+
gap: '8px',
|
|
251
|
+
'min-width': '0',
|
|
252
|
+
'max-width': '208px',
|
|
253
|
+
overflow: 'hidden',
|
|
254
|
+
color: tokens.textSecondary
|
|
255
|
+
},
|
|
256
|
+
'.g2-tooltip-list-item-name-label': {
|
|
257
|
+
color: tokens.textSecondary,
|
|
258
|
+
'font-weight': '400'
|
|
259
|
+
},
|
|
260
|
+
'.g2-tooltip-list-item-value': {
|
|
261
|
+
color: tokens.textPrimary,
|
|
262
|
+
'font-weight': '600',
|
|
263
|
+
flex: '0 0 auto',
|
|
264
|
+
'min-width': '40px',
|
|
265
|
+
'margin-left': '0',
|
|
266
|
+
'text-align': 'right',
|
|
267
|
+
'letter-spacing': '-0.01em',
|
|
268
|
+
'font-variant-numeric': 'tabular-nums',
|
|
269
|
+
'font-feature-settings': '"tnum" 1, "zero" 1'
|
|
270
|
+
},
|
|
271
|
+
'.g2-tooltip-list-item-marker': {
|
|
272
|
+
width: '7px',
|
|
273
|
+
height: '7px',
|
|
274
|
+
flex: '0 0 auto',
|
|
275
|
+
'margin-right': '0',
|
|
276
|
+
'border-radius': '999px',
|
|
277
|
+
'box-shadow': tokens.tooltipMarkerShadow
|
|
278
|
+
},
|
|
279
|
+
'.g2-tooltip-crosshair-x': {
|
|
280
|
+
'background-color': isDark ? 'rgba(255, 255, 255, 0.16)' : 'rgba(71, 84, 103, 0.16)'
|
|
281
|
+
},
|
|
282
|
+
'.g2-tooltip-crosshair-y': {
|
|
283
|
+
'background-color': isDark ? 'rgba(255, 255, 255, 0.16)' : 'rgba(71, 84, 103, 0.16)'
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
var TITLE_KEYS = ['align', 'spacing', 'titleFill', 'titleFillOpacity', 'titleFontFamily', 'titleFontSize', 'titleFontWeight', 'subtitleFill', 'subtitleFillOpacity', 'subtitleFontFamily', 'subtitleFontSize', 'subtitleFontWeight'];
|
|
290
|
+
var AXIS_KEYS = ['line', 'lineStroke', 'lineStrokeOpacity', 'lineLineWidth', 'lineLineDash', 'tick', 'tickStroke', 'tickStrokeOpacity', 'tickOpacity', 'tickLineWidth', 'tickLength', 'grid', 'gridStroke', 'gridStrokeOpacity', 'gridLineWidth', 'gridLineDash', 'labelFill', 'labelFillOpacity', 'labelOpacity', 'labelFontFamily', 'labelFontSize', 'labelFontWeight', 'labelSpacing', 'titleFill', 'titleFillOpacity', 'titleOpacity', 'titleFontFamily', 'titleFontSize', 'titleFontWeight', 'titleSpacing'];
|
|
291
|
+
var LEGEND_KEYS = ['titleFill', 'titleFillOpacity', 'titleFontFamily', 'titleFontSize', 'titleFontWeight', 'titleSpacing', 'itemLabelFill', 'itemLabelFillOpacity', 'itemLabelFontFamily', 'itemLabelFontSize', 'itemLabelFontWeight', 'itemLabelLineHeight', 'itemLabelLetterSpacing', 'itemSpacing', 'itemMarkerSize', 'itemMarkerFillOpacity', 'itemMarkerStroke', 'itemMarkerStrokeOpacity', 'itemMarkerLineWidth', 'rowPadding', 'colPadding'];
|
|
292
|
+
var LABEL_KEYS = ['fill', 'fillOpacity', 'stroke', 'strokeOpacity', 'lineWidth', 'opacity', 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'lineHeight'];
|
|
293
|
+
var MARK_PAINT_KEYS = ['fillOpacity', 'strokeOpacity', 'lineWidth', 'lineDash', 'opacity', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY'];
|
|
294
|
+
var MARK_KEYS = {
|
|
295
|
+
line: [].concat(MARK_PAINT_KEYS, ['shape', 'lineCap', 'lineJoin']),
|
|
296
|
+
area: [].concat(MARK_PAINT_KEYS, ['shape']),
|
|
297
|
+
point: [].concat(MARK_PAINT_KEYS, ['shape', 'size', 'stroke']),
|
|
298
|
+
interval: [].concat(MARK_PAINT_KEYS, ['shape', 'stroke', 'radius', 'radiusTopLeft', 'radiusTopRight', 'radiusBottomLeft', 'radiusBottomRight']),
|
|
299
|
+
box: [].concat(MARK_PAINT_KEYS, ['shape', 'stroke']),
|
|
300
|
+
path: [].concat(MARK_PAINT_KEYS, ['shape', 'stroke']),
|
|
301
|
+
density: [].concat(MARK_PAINT_KEYS, ['stroke']),
|
|
302
|
+
link: [].concat(MARK_PAINT_KEYS, ['shape', 'stroke']),
|
|
303
|
+
connector: [].concat(MARK_PAINT_KEYS, ['stroke', 'endMarker', 'endMarkerSize', 'endMarkerFill', 'endMarkerFillOpacity'])
|
|
304
|
+
};
|
|
305
|
+
var COMPOSITE_KEYS = {
|
|
306
|
+
liquid: [].concat(MARK_PAINT_KEYS, ['shape', 'contentFill', 'contentStroke', 'contentStrokeOpacity', 'contentLineWidth', 'contentFontFamily', 'contentFontSize', 'contentFontWeight', 'backgroundFill', 'backgroundFillOpacity', 'backgroundStroke', 'backgroundStrokeOpacity', 'backgroundLineWidth', 'outlineBorder', 'outlineStroke', 'outlineStrokeOpacity']),
|
|
307
|
+
treemap: [].concat(MARK_PAINT_KEYS, ['stroke', 'radius']),
|
|
308
|
+
wordCloud: ['fontFamily', 'opacity', 'fillOpacity', 'strokeOpacity'],
|
|
309
|
+
sankey: ['nodeFillOpacity', 'nodeStroke', 'nodeStrokeOpacity', 'nodeLineWidth', 'linkFillOpacity', 'linkStroke', 'linkStrokeOpacity', 'linkLineWidth', 'labelFill', 'labelFillOpacity', 'labelFontFamily', 'labelFontSize', 'labelFontWeight']
|
|
310
|
+
};
|
|
311
|
+
var expandTokens = function expandTokens(t) {
|
|
312
|
+
return {
|
|
313
|
+
axis: {
|
|
314
|
+
lineStroke: t.colorStroke,
|
|
315
|
+
tickStroke: t.colorStroke,
|
|
316
|
+
gridStroke: t.colorStroke,
|
|
317
|
+
lineLineWidth: t.lineWidth,
|
|
318
|
+
tickLineWidth: t.lineWidth,
|
|
319
|
+
gridLineWidth: t.lineWidth,
|
|
320
|
+
labelFill: t.colorTextSecondary,
|
|
321
|
+
titleFill: t.colorTextSecondary,
|
|
322
|
+
labelFontFamily: t.fontFamily,
|
|
323
|
+
titleFontFamily: t.fontFamily,
|
|
324
|
+
labelFontSize: t.fontSize,
|
|
325
|
+
titleFontSize: t.fontSize,
|
|
326
|
+
labelFontWeight: t.fontWeight,
|
|
327
|
+
titleFontWeight: t.fontWeight,
|
|
328
|
+
labelSpacing: t.spacingSmall,
|
|
329
|
+
titleSpacing: t.spacingMedium
|
|
330
|
+
},
|
|
331
|
+
legend: {
|
|
332
|
+
titleFill: t.colorText,
|
|
333
|
+
itemLabelFill: t.colorText,
|
|
334
|
+
titleFontFamily: t.fontFamily,
|
|
335
|
+
itemLabelFontFamily: t.fontFamily,
|
|
336
|
+
titleFontSize: t.fontSize,
|
|
337
|
+
itemLabelFontSize: t.fontSize,
|
|
338
|
+
titleFontWeight: t.fontWeight,
|
|
339
|
+
itemLabelFontWeight: t.fontWeight,
|
|
340
|
+
itemLabelLineHeight: t.lineHeight,
|
|
341
|
+
titleSpacing: t.spacingSmall,
|
|
342
|
+
itemSpacing: t.spacingSmall,
|
|
343
|
+
rowPadding: t.spacingSmall,
|
|
344
|
+
colPadding: t.spacingMedium
|
|
345
|
+
},
|
|
346
|
+
label: {
|
|
347
|
+
fontFamily: t.fontFamily,
|
|
348
|
+
fontSize: t.fontSize,
|
|
349
|
+
fontWeight: t.fontWeight,
|
|
350
|
+
lineHeight: t.lineHeight
|
|
351
|
+
},
|
|
352
|
+
mark: {
|
|
353
|
+
line: {
|
|
354
|
+
lineWidth: t.lineWidth
|
|
355
|
+
},
|
|
356
|
+
point: {
|
|
357
|
+
lineWidth: t.lineWidth
|
|
358
|
+
},
|
|
359
|
+
interval: {
|
|
360
|
+
lineWidth: t.lineWidth,
|
|
361
|
+
radius: t.radius
|
|
362
|
+
},
|
|
363
|
+
box: {
|
|
364
|
+
lineWidth: t.lineWidth
|
|
365
|
+
},
|
|
366
|
+
connector: {
|
|
367
|
+
lineWidth: t.lineWidth
|
|
368
|
+
},
|
|
369
|
+
path: {
|
|
370
|
+
lineWidth: t.lineWidth
|
|
371
|
+
},
|
|
372
|
+
density: {
|
|
373
|
+
lineWidth: t.lineWidth
|
|
374
|
+
},
|
|
375
|
+
link: {
|
|
376
|
+
lineWidth: t.lineWidth
|
|
377
|
+
},
|
|
378
|
+
treemap: {
|
|
379
|
+
lineWidth: t.lineWidth,
|
|
380
|
+
radius: t.radius
|
|
381
|
+
},
|
|
382
|
+
liquid: {
|
|
383
|
+
contentFill: t.colorText,
|
|
384
|
+
contentFontFamily: t.fontFamily,
|
|
385
|
+
contentFontWeight: t.fontWeight,
|
|
386
|
+
backgroundFill: t.colorSurface,
|
|
387
|
+
backgroundStroke: t.colorStroke,
|
|
388
|
+
outlineStroke: t.colorDefault
|
|
389
|
+
},
|
|
390
|
+
sankey: {
|
|
391
|
+
nodeStroke: t.colorStroke,
|
|
392
|
+
nodeLineWidth: t.lineWidth,
|
|
393
|
+
linkStroke: t.colorStroke,
|
|
394
|
+
linkLineWidth: t.lineWidth,
|
|
395
|
+
labelFill: t.colorText,
|
|
396
|
+
labelFontFamily: t.fontFamily,
|
|
397
|
+
labelFontSize: t.fontSize,
|
|
398
|
+
labelFontWeight: t.fontWeight
|
|
399
|
+
},
|
|
400
|
+
wordCloud: {
|
|
401
|
+
fontFamily: t.fontFamily
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
/** Resolve appearance once. Data, label content, visibility and layout stay in the chart. */
|
|
408
|
+
export function getThemeObject(type, theme, localStyle) {
|
|
409
|
+
var _style$palette, _tokens$colorTextSeco, _tokens$colorText, _tokens$colorTextInve, _tokens$colorTextSeco2, _tokens$lineWidth, _tokens$colorStroke, _tokens$spacingSmall, _tokens$spacingMedium, _tokens$lineWidth2, _tokens$colorStroke2;
|
|
410
|
+
var _resolveTheme = resolveTheme(type, theme, localStyle),
|
|
411
|
+
baseTheme = _resolveTheme.baseTheme,
|
|
412
|
+
tokens = _resolveTheme.tokens,
|
|
413
|
+
styles = _resolveTheme.styles;
|
|
414
|
+
// Existing Line/Area/Radar shorthand is normalized before higher-priority styles merge.
|
|
415
|
+
var layers = styles.map(function (layer) {
|
|
416
|
+
var _layer$mark$line$line, _layer$mark;
|
|
417
|
+
return ['line', 'area', 'radar'].includes(type) && (layer === null || layer === void 0 ? void 0 : layer.lineWidth) !== undefined ? mergeTheme(layer, {
|
|
418
|
+
mark: {
|
|
419
|
+
line: {
|
|
420
|
+
lineWidth: (_layer$mark$line$line = (_layer$mark = layer.mark) === null || _layer$mark === void 0 || (_layer$mark = _layer$mark.line) === null || _layer$mark === void 0 ? void 0 : _layer$mark.lineWidth) !== null && _layer$mark$line$line !== void 0 ? _layer$mark$line$line : layer.lineWidth
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}) : layer;
|
|
424
|
+
});
|
|
425
|
+
var style = mergeTheme.apply(void 0, [expandTokens(tokens)].concat(_toConsumableArray(layers)));
|
|
426
|
+
var values = getChartVisualTokens(baseTheme);
|
|
427
|
+
var colors = normalizePalette((_style$palette = style.palette) !== null && _style$palette !== void 0 && _style$palette.length ? style.palette : type === 'waterfall' ? ['#FF4D4F', '#2EBB59', '#1783FF'] : undefined, baseTheme);
|
|
428
|
+
if (type === 'dual-axes' && style.palette) {
|
|
429
|
+
colors.push.apply(colors, _toConsumableArray(normalizePalette(undefined, baseTheme).filter(function (color) {
|
|
430
|
+
return !colors.includes(color);
|
|
431
|
+
})));
|
|
432
|
+
}
|
|
433
|
+
var backgroundColor = style.backgroundColor || values.background;
|
|
434
|
+
var mark = {};
|
|
435
|
+
for (var _i = 0, _Object$entries = Object.entries(_objectSpread(_objectSpread({}, MARK_KEYS), COMPOSITE_KEYS)); _i < _Object$entries.length; _i++) {
|
|
436
|
+
var _style$mark;
|
|
437
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
438
|
+
name = _Object$entries$_i[0],
|
|
439
|
+
keys = _Object$entries$_i[1];
|
|
440
|
+
var kind = name;
|
|
441
|
+
mark[kind] = pickStyle((_style$mark = style.mark) === null || _style$mark === void 0 ? void 0 : _style$mark[kind], keys);
|
|
442
|
+
}
|
|
443
|
+
var axisStyle = pickStyle(style.axis, AXIS_KEYS);
|
|
444
|
+
var titleStyle = pickStyle(style.title, TITLE_KEYS);
|
|
445
|
+
var legendStyle = pickStyle(style.legend, LEGEND_KEYS);
|
|
446
|
+
var labelStyle = pickStyle(style.label, LABEL_KEYS);
|
|
447
|
+
var _createTheme = createTheme(baseTheme),
|
|
448
|
+
axisDefaults = _createTheme.axis,
|
|
449
|
+
builtInTheme = _objectWithoutProperties(_createTheme, _excluded);
|
|
450
|
+
var rendererTheme = mergeTheme(builtInTheme, {
|
|
451
|
+
color: colors[0],
|
|
452
|
+
category10: colors,
|
|
453
|
+
category20: colors,
|
|
454
|
+
view: {
|
|
455
|
+
viewFill: backgroundColor
|
|
456
|
+
},
|
|
457
|
+
tooltip: {
|
|
458
|
+
markerStroke: backgroundColor,
|
|
459
|
+
crosshairsStroke: (_tokens$colorTextSeco = tokens.colorTextSecondary) !== null && _tokens$colorTextSeco !== void 0 ? _tokens$colorTextSeco : values.textSecondary
|
|
460
|
+
},
|
|
461
|
+
title: titleStyle,
|
|
462
|
+
axis: axisStyle,
|
|
463
|
+
axisX: _objectSpread(_objectSpread(_objectSpread({}, axisDefaults), builtInTheme.axisX), axisStyle),
|
|
464
|
+
axisY: _objectSpread(_objectSpread(_objectSpread({}, axisDefaults), builtInTheme.axisY), axisStyle),
|
|
465
|
+
axisRadar: axisStyle,
|
|
466
|
+
legendCategory: legendStyle,
|
|
467
|
+
label: _objectSpread({
|
|
468
|
+
fill: (_tokens$colorText = tokens.colorText) !== null && _tokens$colorText !== void 0 ? _tokens$colorText : values.textPrimary
|
|
469
|
+
}, labelStyle),
|
|
470
|
+
innerLabel: _objectSpread({
|
|
471
|
+
fill: (_tokens$colorTextInve = tokens.colorTextInverse) !== null && _tokens$colorTextInve !== void 0 ? _tokens$colorTextInve : values.textInverse
|
|
472
|
+
}, labelStyle)
|
|
473
|
+
});
|
|
474
|
+
// Tooltips are existing renderer components; token expansion does not add interactions.
|
|
475
|
+
var css = rendererTheme.tooltip.css;
|
|
476
|
+
css['.g2-tooltip'] = mergeTheme(css['.g2-tooltip'], {
|
|
477
|
+
'background-color': tokens.colorSurface,
|
|
478
|
+
color: (_tokens$colorTextSeco2 = tokens.colorTextSecondary) !== null && _tokens$colorTextSeco2 !== void 0 ? _tokens$colorTextSeco2 : tokens.colorText,
|
|
479
|
+
border: tokens.colorStroke === undefined && tokens.lineWidth === undefined ? undefined : "".concat((_tokens$lineWidth = tokens.lineWidth) !== null && _tokens$lineWidth !== void 0 ? _tokens$lineWidth : 1, "px solid ").concat((_tokens$colorStroke = tokens.colorStroke) !== null && _tokens$colorStroke !== void 0 ? _tokens$colorStroke : values.tooltipBorder),
|
|
480
|
+
'border-radius': tokens.radius === undefined ? undefined : "".concat(tokens.radius, "px"),
|
|
481
|
+
'font-family': tokens.fontFamily,
|
|
482
|
+
'font-size': tokens.fontSize === undefined ? undefined : "".concat(tokens.fontSize, "px"),
|
|
483
|
+
'font-weight': tokens.fontWeight === undefined ? undefined : String(tokens.fontWeight),
|
|
484
|
+
'line-height': tokens.lineHeight === undefined ? undefined : "".concat(tokens.lineHeight, "px"),
|
|
485
|
+
padding: tokens.spacingSmall === undefined && tokens.spacingMedium === undefined ? undefined : "".concat((_tokens$spacingSmall = tokens.spacingSmall) !== null && _tokens$spacingSmall !== void 0 ? _tokens$spacingSmall : 10, "px ").concat((_tokens$spacingMedium = tokens.spacingMedium) !== null && _tokens$spacingMedium !== void 0 ? _tokens$spacingMedium : 12, "px")
|
|
486
|
+
});
|
|
487
|
+
for (var _i2 = 0, _arr = ['.g2-tooltip-title', '.g2-tooltip-list-item-name', '.g2-tooltip-list-item-name-label']; _i2 < _arr.length; _i2++) {
|
|
488
|
+
var _tokens$colorTextSeco3, _tokens$colorTextSeco4;
|
|
489
|
+
var _name = _arr[_i2];
|
|
490
|
+
if (tokens.fontSize !== undefined && _name === '.g2-tooltip-title') css[_name]['font-size'] = "".concat(tokens.fontSize, "px");
|
|
491
|
+
if (tokens.lineHeight !== undefined && _name === '.g2-tooltip-title') css[_name]['line-height'] = "".concat(tokens.lineHeight, "px");
|
|
492
|
+
if ((_tokens$colorTextSeco3 = tokens.colorTextSecondary) !== null && _tokens$colorTextSeco3 !== void 0 ? _tokens$colorTextSeco3 : tokens.colorText) css[_name].color = (_tokens$colorTextSeco4 = tokens.colorTextSecondary) !== null && _tokens$colorTextSeco4 !== void 0 ? _tokens$colorTextSeco4 : tokens.colorText;
|
|
493
|
+
}
|
|
494
|
+
if (tokens.colorText !== undefined) css['.g2-tooltip-list-item-value'].color = tokens.colorText;
|
|
495
|
+
if (tokens.colorStroke !== undefined || tokens.lineWidth !== undefined) css['.g2-tooltip-title']['border-bottom'] = "".concat((_tokens$lineWidth2 = tokens.lineWidth) !== null && _tokens$lineWidth2 !== void 0 ? _tokens$lineWidth2 : 1, "px solid ").concat((_tokens$colorStroke2 = tokens.colorStroke) !== null && _tokens$colorStroke2 !== void 0 ? _tokens$colorStroke2 : values.tooltipDivider);
|
|
496
|
+
if (tokens.lineHeight !== undefined) css['.g2-tooltip-list-item']['line-height'] = "".concat(tokens.lineHeight, "px");
|
|
497
|
+
if (tokens.colorSurface !== undefined) css['.g2-tooltip-list-item-marker']['box-shadow'] = "0 0 0 2px ".concat(tokens.colorSurface);
|
|
498
|
+
return {
|
|
499
|
+
theme: _objectSpread(_objectSpread({}, rendererTheme), {}, {
|
|
500
|
+
type: baseTheme
|
|
501
|
+
}),
|
|
502
|
+
mark: mark
|
|
503
|
+
};
|
|
504
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ChartType, ThemeStyle, VisualizationTheme } from '../types';
|
|
2
|
+
export declare function getThemeObject(type: ChartType, theme?: VisualizationTheme, localStyle?: ThemeStyle): {
|
|
3
|
+
baseTheme: "light" | "dark" | "academy";
|
|
4
|
+
theme: "light" | "dark";
|
|
5
|
+
colors: string[];
|
|
6
|
+
backgroundColor: string;
|
|
7
|
+
node: {
|
|
8
|
+
type: string | undefined;
|
|
9
|
+
style: {
|
|
10
|
+
[k: string]: any;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
edge: {
|
|
14
|
+
type: string | undefined;
|
|
15
|
+
style: {
|
|
16
|
+
[k: string]: any;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
titleStyle: {
|
|
20
|
+
titleFill: string;
|
|
21
|
+
titleFontFamily: string;
|
|
22
|
+
subtitleFill: string;
|
|
23
|
+
};
|
|
24
|
+
tooltipStyle: {
|
|
25
|
+
[k: string]: any;
|
|
26
|
+
};
|
|
27
|
+
texture: "rough" | "default" | undefined;
|
|
28
|
+
};
|