@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
|
@@ -5,7 +5,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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
7
|
import { Chart } from '@antv/g2';
|
|
8
|
-
import {
|
|
8
|
+
import { getThemeObject } from "../../theme/g2";
|
|
9
|
+
import { getCartesianAxis, getCartesianLayout, getCategoryBackgroundHighlightState, getCategoryHighlightInteraction } from "../../util";
|
|
10
|
+
import { getColorLegend, getDataLabels } from "../../util/components";
|
|
11
|
+
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* ColumnDataItem is the type for each data item in the column chart.
|
|
@@ -52,7 +55,6 @@ export var Column = function Column(options) {
|
|
|
52
55
|
_options$theme = options.theme,
|
|
53
56
|
chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
|
|
54
57
|
var chart = null;
|
|
55
|
-
var hasRendered = false;
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* Render the column chart with the given configuration.
|
|
@@ -64,6 +66,8 @@ export var Column = function Column(options) {
|
|
|
64
66
|
_config$theme = config.theme,
|
|
65
67
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
66
68
|
title = config.title,
|
|
69
|
+
subtitle = config.subtitle,
|
|
70
|
+
label = config.label,
|
|
67
71
|
axisXTitle = config.axisXTitle,
|
|
68
72
|
axisYTitle = config.axisYTitle,
|
|
69
73
|
_config$group = config.group,
|
|
@@ -71,14 +75,34 @@ export var Column = function Column(options) {
|
|
|
71
75
|
_config$stack = config.stack,
|
|
72
76
|
stack = _config$stack === void 0 ? false : _config$stack,
|
|
73
77
|
_config$style = config.style,
|
|
74
|
-
|
|
78
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
75
79
|
|
|
76
80
|
// Clean up previous chart if exists
|
|
77
81
|
if (chart) {
|
|
78
82
|
chart.destroy();
|
|
79
83
|
}
|
|
80
84
|
var hasGroupField = data.length > 0 && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.group) !== undefined;
|
|
81
|
-
var
|
|
85
|
+
var cartesianAxisOptions = {
|
|
86
|
+
axisXTitle: axisXTitle,
|
|
87
|
+
axisYTitle: axisYTitle,
|
|
88
|
+
xLabels: data.map(function (_ref) {
|
|
89
|
+
var category = _ref.category;
|
|
90
|
+
return category;
|
|
91
|
+
}),
|
|
92
|
+
chartWidth: width
|
|
93
|
+
};
|
|
94
|
+
var appearance = getThemeObject('column', theme, localStyle);
|
|
95
|
+
var rendererTheme = appearance.theme;
|
|
96
|
+
var intervalMark = _objectSpread(_objectSpread(_objectSpread({}, rendererTheme.type !== 'academy' && appearance.mark.interval.radius === undefined ? {
|
|
97
|
+
radiusTopLeft: 4,
|
|
98
|
+
radiusTopRight: 4
|
|
99
|
+
} : {}), {}, {
|
|
100
|
+
columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
|
|
101
|
+
}, !hasGroupField ? {
|
|
102
|
+
fill: rendererTheme.category10[0]
|
|
103
|
+
} : {}), appearance.mark.interval);
|
|
104
|
+
var baseTheme = rendererTheme.type;
|
|
105
|
+
var colors = rendererTheme.category10;
|
|
82
106
|
|
|
83
107
|
// Create chart
|
|
84
108
|
chart = new Chart({
|
|
@@ -91,15 +115,6 @@ export var Column = function Column(options) {
|
|
|
91
115
|
// Configure chart encode and transform based on group/stack
|
|
92
116
|
var encode = {};
|
|
93
117
|
var transform = [];
|
|
94
|
-
var radiusStyle = {};
|
|
95
|
-
|
|
96
|
-
// academy theme uses no rounded corners; other themes use rounded top corners
|
|
97
|
-
if (theme !== 'academy') {
|
|
98
|
-
radiusStyle = {
|
|
99
|
-
radiusTopLeft: 4,
|
|
100
|
-
radiusTopRight: 4
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
118
|
|
|
104
119
|
// Configure transforms based on group/stack flags
|
|
105
120
|
if (hasGroupField && group) {
|
|
@@ -137,30 +152,34 @@ export var Column = function Column(options) {
|
|
|
137
152
|
range: colors
|
|
138
153
|
}
|
|
139
154
|
} : {});
|
|
140
|
-
var cartesianAxisOptions = {
|
|
141
|
-
axisXTitle: axisXTitle,
|
|
142
|
-
axisYTitle: axisYTitle,
|
|
143
|
-
xLabels: data.map(function (_ref) {
|
|
144
|
-
var category = _ref.category;
|
|
145
|
-
return category;
|
|
146
|
-
}),
|
|
147
|
-
chartWidth: width
|
|
148
|
-
};
|
|
149
155
|
|
|
150
156
|
// Configure chart options
|
|
151
157
|
// Note: Using 'any' type due to G2's complex type system with transformations
|
|
152
158
|
// This is consistent with how G2 5.0 is used elsewhere in the codebase
|
|
153
159
|
var chartOptions = _objectSpread(_objectSpread({
|
|
154
|
-
|
|
160
|
+
// G2 growInY currently computes interval label bounds from the animated
|
|
161
|
+
// clip path, which leaves inside labels at the axis baseline. Keep the
|
|
162
|
+
// interval and its labels in sync until the upstream runtime is fixed.
|
|
163
|
+
animate: false,
|
|
155
164
|
type: 'interval',
|
|
156
165
|
data: data,
|
|
157
|
-
title: title
|
|
166
|
+
title: title ? {
|
|
167
|
+
title: title,
|
|
168
|
+
subtitle: subtitle
|
|
169
|
+
} : '',
|
|
158
170
|
encode: encode,
|
|
159
171
|
transform: transform,
|
|
160
172
|
scale: scaleConfig
|
|
161
173
|
}, getCartesianLayout(cartesianAxisOptions)), {}, {
|
|
162
174
|
axis: getCartesianAxis(cartesianAxisOptions),
|
|
163
175
|
legend: getColorLegend(hasGroupField),
|
|
176
|
+
labels: getDataLabels(rendererTheme, {
|
|
177
|
+
visible: label,
|
|
178
|
+
defaultVisible: true,
|
|
179
|
+
text: 'value',
|
|
180
|
+
position: 'inside',
|
|
181
|
+
contrast: 'inside'
|
|
182
|
+
}),
|
|
164
183
|
tooltip: {
|
|
165
184
|
items: [function (d) {
|
|
166
185
|
return {
|
|
@@ -169,24 +188,16 @@ export var Column = function Column(options) {
|
|
|
169
188
|
};
|
|
170
189
|
}]
|
|
171
190
|
},
|
|
172
|
-
state: getCategoryBackgroundHighlightState(
|
|
191
|
+
state: getCategoryBackgroundHighlightState(baseTheme),
|
|
173
192
|
interaction: {
|
|
174
193
|
tooltip: true,
|
|
175
194
|
elementHighlight: getCategoryHighlightInteraction()
|
|
176
195
|
},
|
|
177
|
-
style:
|
|
178
|
-
|
|
179
|
-
}, !hasGroupField ? {
|
|
180
|
-
fill: colors[0]
|
|
181
|
-
} : {}),
|
|
182
|
-
viewStyle: style.backgroundColor ? {
|
|
183
|
-
viewFill: style.backgroundColor
|
|
184
|
-
} : undefined,
|
|
185
|
-
theme: getThemeObject(theme)
|
|
196
|
+
style: intervalMark,
|
|
197
|
+
theme: rendererTheme
|
|
186
198
|
});
|
|
187
199
|
chart.options(chartOptions);
|
|
188
200
|
chart.render();
|
|
189
|
-
hasRendered = true;
|
|
190
201
|
};
|
|
191
202
|
|
|
192
203
|
/**
|
|
@@ -197,7 +208,6 @@ export var Column = function Column(options) {
|
|
|
197
208
|
chart.destroy();
|
|
198
209
|
chart = null;
|
|
199
210
|
}
|
|
200
|
-
hasRendered = false;
|
|
201
211
|
};
|
|
202
212
|
return {
|
|
203
213
|
render: render,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions, VisualizationTheme } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* DualAxesSeriesItem defines a single series in the dual-axes chart.
|
|
4
4
|
*/
|
|
@@ -15,11 +15,10 @@ export interface DualAxesConfig {
|
|
|
15
15
|
categories: string[];
|
|
16
16
|
series: DualAxesSeriesItem[];
|
|
17
17
|
title?: string;
|
|
18
|
+
subtitle?: string;
|
|
18
19
|
axisXTitle?: string;
|
|
19
20
|
theme?: VisualizationTheme;
|
|
20
|
-
style?: {
|
|
21
|
-
backgroundColor?: string;
|
|
22
|
-
palette?: string[];
|
|
21
|
+
style?: ThemeStyle & {
|
|
23
22
|
startAtZero?: boolean;
|
|
24
23
|
};
|
|
25
24
|
}
|
|
@@ -4,14 +4,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
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
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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
7
|
import { Chart } from '@antv/g2';
|
|
14
|
-
import {
|
|
8
|
+
import { getThemeObject } from "../../theme/g2";
|
|
9
|
+
import { bindCrosshairAxisLabels, getCartesianAxis, getCartesianLayout, getChartAnimation, getLineHighlightState, getSeriesHighlightByColorInteraction, getSharedTooltipInteraction } from "../../util";
|
|
10
|
+
import { getColorLegend } from "../../util/components";
|
|
11
|
+
import { CHART_STYLE_DEFAULTS } from "../../util/tokens";
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* DualAxesSeriesItem defines a single series in the dual-axes chart.
|
|
@@ -83,6 +80,7 @@ export var DualAxes = function DualAxes(options) {
|
|
|
83
80
|
chartTheme = _options$theme === void 0 ? 'default' : _options$theme;
|
|
84
81
|
var chart = null;
|
|
85
82
|
var hasRendered = false;
|
|
83
|
+
var cleanupCrosshairAxisLabels = null;
|
|
86
84
|
|
|
87
85
|
/**
|
|
88
86
|
* Render the dual-axes chart with the given configuration.
|
|
@@ -93,21 +91,43 @@ export var DualAxes = function DualAxes(options) {
|
|
|
93
91
|
_config$theme = config.theme,
|
|
94
92
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
95
93
|
title = config.title,
|
|
94
|
+
subtitle = config.subtitle,
|
|
96
95
|
axisXTitle = config.axisXTitle,
|
|
97
96
|
_config$style = config.style,
|
|
98
|
-
|
|
97
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
99
98
|
|
|
100
99
|
// Clean up previous chart if exists
|
|
101
100
|
if (chart) {
|
|
101
|
+
var _cleanupCrosshairAxis;
|
|
102
|
+
(_cleanupCrosshairAxis = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis === void 0 || _cleanupCrosshairAxis();
|
|
103
|
+
cleanupCrosshairAxisLabels = null;
|
|
102
104
|
chart.destroy();
|
|
103
105
|
}
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
var cartesianAxisOptions = {
|
|
107
|
+
axisXTitle: axisXTitle,
|
|
108
|
+
xLabels: categories,
|
|
109
|
+
chartWidth: width
|
|
110
|
+
};
|
|
111
|
+
var cartesianAxis = getCartesianAxis(cartesianAxisOptions);
|
|
112
|
+
var appearance = getThemeObject('dual-axes', theme, localStyle);
|
|
113
|
+
var rendererTheme = appearance.theme;
|
|
114
|
+
var intervalMark = _objectSpread(_objectSpread({
|
|
115
|
+
fillOpacity: 0.86,
|
|
116
|
+
columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
|
|
117
|
+
}, rendererTheme.type !== 'academy' && appearance.mark.interval.radius === undefined ? {
|
|
118
|
+
radiusTopLeft: 4,
|
|
119
|
+
radiusTopRight: 4
|
|
120
|
+
} : {}), appearance.mark.interval);
|
|
121
|
+
var lineMark = _objectSpread({
|
|
122
|
+
shape: 'smooth',
|
|
123
|
+
lineWidth: CHART_STYLE_DEFAULTS.lineWidth,
|
|
124
|
+
lineCap: 'round',
|
|
125
|
+
lineJoin: 'round'
|
|
126
|
+
}, appearance.mark.line);
|
|
127
|
+
var baseTheme = rendererTheme.type;
|
|
128
|
+
var colors = rendererTheme.category10;
|
|
129
|
+
var _localStyle$startAtZe = localStyle.startAtZero,
|
|
130
|
+
startAtZero = _localStyle$startAtZe === void 0 ? false : _localStyle$startAtZe;
|
|
111
131
|
|
|
112
132
|
// Transform data
|
|
113
133
|
var data = transformData(series, categories);
|
|
@@ -149,12 +169,6 @@ export var DualAxes = function DualAxes(options) {
|
|
|
149
169
|
displayName: displayName
|
|
150
170
|
}];
|
|
151
171
|
}));
|
|
152
|
-
var cartesianAxisOptions = {
|
|
153
|
-
axisXTitle: axisXTitle,
|
|
154
|
-
xLabels: categories,
|
|
155
|
-
chartWidth: width
|
|
156
|
-
};
|
|
157
|
-
var cartesianAxis = getCartesianAxis(cartesianAxisOptions);
|
|
158
172
|
|
|
159
173
|
// Create children configurations for each series
|
|
160
174
|
var children = seriesMeta.map(function (_ref3) {
|
|
@@ -171,6 +185,13 @@ export var DualAxes = function DualAxes(options) {
|
|
|
171
185
|
}]
|
|
172
186
|
};
|
|
173
187
|
if (item.type === 'column') {
|
|
188
|
+
var axis = {
|
|
189
|
+
y: _objectSpread(_objectSpread({}, cartesianAxis.y), {}, {
|
|
190
|
+
title: item.axisYTitle || false,
|
|
191
|
+
titleFill: color,
|
|
192
|
+
titleFontWeight: 500
|
|
193
|
+
}, rendererTheme.axis)
|
|
194
|
+
};
|
|
174
195
|
return {
|
|
175
196
|
type: 'interval',
|
|
176
197
|
encode: {
|
|
@@ -188,30 +209,30 @@ export var DualAxes = function DualAxes(options) {
|
|
|
188
209
|
},
|
|
189
210
|
tooltip: tooltip,
|
|
190
211
|
axis: {
|
|
191
|
-
y:
|
|
192
|
-
title: item.axisYTitle || '',
|
|
193
|
-
titleFill: color,
|
|
194
|
-
titleFontWeight: 500
|
|
195
|
-
})
|
|
212
|
+
y: axis.y
|
|
196
213
|
},
|
|
197
214
|
style: _objectSpread({
|
|
198
|
-
fill: color
|
|
199
|
-
|
|
200
|
-
columnWidthRatio: CHART_STYLE_DEFAULTS.intervalWidthRatio
|
|
201
|
-
}, theme !== 'academy' ? {
|
|
202
|
-
radiusTopLeft: 4,
|
|
203
|
-
radiusTopRight: 4
|
|
204
|
-
} : {}),
|
|
215
|
+
fill: color
|
|
216
|
+
}, intervalMark),
|
|
205
217
|
animate: getChartAnimation(hasRendered, 'growInY')
|
|
206
218
|
};
|
|
207
219
|
} else {
|
|
220
|
+
var lineWidth = lineMark.lineWidth;
|
|
221
|
+
var _axis = {
|
|
222
|
+
y: _objectSpread(_objectSpread({}, cartesianAxis.y), {}, {
|
|
223
|
+
title: item.axisYTitle || false,
|
|
224
|
+
position: 'right',
|
|
225
|
+
titleFill: color,
|
|
226
|
+
titleFontWeight: 500,
|
|
227
|
+
grid: false
|
|
228
|
+
}, rendererTheme.axis)
|
|
229
|
+
};
|
|
208
230
|
// line type
|
|
209
231
|
return {
|
|
210
232
|
type: 'line',
|
|
211
233
|
encode: {
|
|
212
234
|
x: 'category',
|
|
213
235
|
y: yField,
|
|
214
|
-
shape: 'smooth',
|
|
215
236
|
color: function color() {
|
|
216
237
|
return yField;
|
|
217
238
|
}
|
|
@@ -224,25 +245,18 @@ export var DualAxes = function DualAxes(options) {
|
|
|
224
245
|
},
|
|
225
246
|
tooltip: tooltip,
|
|
226
247
|
axis: {
|
|
227
|
-
y:
|
|
228
|
-
position: 'right',
|
|
229
|
-
title: item.axisYTitle || '',
|
|
230
|
-
titleFill: color,
|
|
231
|
-
titleFontWeight: 500,
|
|
232
|
-
grid: false
|
|
233
|
-
})
|
|
248
|
+
y: _axis.y
|
|
234
249
|
},
|
|
235
|
-
style: {
|
|
236
|
-
stroke: color
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
lineJoin: 'round'
|
|
240
|
-
},
|
|
241
|
-
state: getLineHighlightState(CHART_STYLE_DEFAULTS.lineWidth),
|
|
250
|
+
style: _objectSpread({
|
|
251
|
+
stroke: color
|
|
252
|
+
}, lineMark),
|
|
253
|
+
state: getLineHighlightState(lineWidth),
|
|
242
254
|
animate: getChartAnimation(hasRendered, 'pathIn')
|
|
243
255
|
};
|
|
244
256
|
}
|
|
245
257
|
});
|
|
258
|
+
var xAxis = cartesianAxis.x;
|
|
259
|
+
var legend = getColorLegend(series.length > 0);
|
|
246
260
|
|
|
247
261
|
// Configure chart options
|
|
248
262
|
// Note: Using 'any' type due to G2's complex type system with transformations
|
|
@@ -250,11 +264,14 @@ export var DualAxes = function DualAxes(options) {
|
|
|
250
264
|
var chartOptions = _objectSpread(_objectSpread({
|
|
251
265
|
type: 'view',
|
|
252
266
|
data: data,
|
|
253
|
-
title: title
|
|
267
|
+
title: title ? {
|
|
268
|
+
title: title,
|
|
269
|
+
subtitle: subtitle
|
|
270
|
+
} : '',
|
|
254
271
|
children: children
|
|
255
272
|
}, getCartesianLayout(cartesianAxisOptions)), {}, {
|
|
256
273
|
axis: {
|
|
257
|
-
x:
|
|
274
|
+
x: xAxis
|
|
258
275
|
},
|
|
259
276
|
scale: {
|
|
260
277
|
y: {
|
|
@@ -271,8 +288,8 @@ export var DualAxes = function DualAxes(options) {
|
|
|
271
288
|
})
|
|
272
289
|
}
|
|
273
290
|
},
|
|
274
|
-
legend: {
|
|
275
|
-
color: {
|
|
291
|
+
legend: legend === false ? false : {
|
|
292
|
+
color: _objectSpread(_objectSpread({}, legend.color), {}, {
|
|
276
293
|
labelFormatter: function labelFormatter(value) {
|
|
277
294
|
var _seriesByField$get;
|
|
278
295
|
return ((_seriesByField$get = seriesByField.get(value)) === null || _seriesByField$get === void 0 ? void 0 : _seriesByField$get.displayName) || value;
|
|
@@ -281,19 +298,39 @@ export var DualAxes = function DualAxes(options) {
|
|
|
281
298
|
var _seriesByField$get2;
|
|
282
299
|
return ((_seriesByField$get2 = seriesByField.get(value)) === null || _seriesByField$get2 === void 0 ? void 0 : _seriesByField$get2.type) === 'line' ? 'smooth' : 'rect';
|
|
283
300
|
}
|
|
284
|
-
}
|
|
301
|
+
})
|
|
285
302
|
},
|
|
286
303
|
interaction: _objectSpread({
|
|
287
304
|
tooltip: getSharedTooltipInteraction({
|
|
288
305
|
crosshairs: true
|
|
289
306
|
})
|
|
290
307
|
}, getSeriesHighlightByColorInteraction()),
|
|
291
|
-
|
|
292
|
-
viewFill: style.backgroundColor
|
|
293
|
-
} : undefined,
|
|
294
|
-
theme: getThemeObject(theme)
|
|
308
|
+
theme: rendererTheme
|
|
295
309
|
});
|
|
296
310
|
chart.options(chartOptions);
|
|
311
|
+
var lineYFields = seriesMeta.filter(function (_ref6) {
|
|
312
|
+
var item = _ref6.item;
|
|
313
|
+
return item.type === 'line';
|
|
314
|
+
}).map(function (_ref7) {
|
|
315
|
+
var yField = _ref7.yField;
|
|
316
|
+
return yField;
|
|
317
|
+
});
|
|
318
|
+
if (lineYFields.length) {
|
|
319
|
+
var currentChart = chart;
|
|
320
|
+
var cleanups = lineYFields.map(function (yField, index) {
|
|
321
|
+
return bindCrosshairAxisLabels(currentChart, baseTheme, {
|
|
322
|
+
showXLabel: index === 0,
|
|
323
|
+
useStandaloneYLabel: true,
|
|
324
|
+
yAxisPosition: 'right',
|
|
325
|
+
yField: yField
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
cleanupCrosshairAxisLabels = function cleanupCrosshairAxisLabels() {
|
|
329
|
+
return cleanups.forEach(function (cleanup) {
|
|
330
|
+
return cleanup();
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
}
|
|
297
334
|
chart.render();
|
|
298
335
|
hasRendered = true;
|
|
299
336
|
};
|
|
@@ -303,6 +340,9 @@ export var DualAxes = function DualAxes(options) {
|
|
|
303
340
|
*/
|
|
304
341
|
var destroy = function destroy() {
|
|
305
342
|
if (chart) {
|
|
343
|
+
var _cleanupCrosshairAxis2;
|
|
344
|
+
(_cleanupCrosshairAxis2 = cleanupCrosshairAxisLabels) === null || _cleanupCrosshairAxis2 === void 0 || _cleanupCrosshairAxis2();
|
|
345
|
+
cleanupCrosshairAxisLabels = null;
|
|
306
346
|
chart.destroy();
|
|
307
347
|
chart = null;
|
|
308
348
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VisualizationOptions } from '../../types';
|
|
1
|
+
import type { ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
export interface FishboneNode {
|
|
3
3
|
name: string;
|
|
4
4
|
children?: FishboneNode[];
|
|
@@ -9,16 +9,10 @@ export interface FishboneNode {
|
|
|
9
9
|
export interface FishboneDiagramConfig {
|
|
10
10
|
type?: 'fishbone-diagram';
|
|
11
11
|
data: FishboneNode;
|
|
12
|
-
theme?:
|
|
12
|
+
theme?: VisualizationTheme;
|
|
13
13
|
title?: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
palette?: string[];
|
|
17
|
-
/** Canvas background color, overrides theme default */
|
|
18
|
-
backgroundColor?: string;
|
|
19
|
-
/** Node rendering style: 'rough' for hand-drawn look, 'default' for smooth */
|
|
20
|
-
texture?: 'rough' | 'default';
|
|
21
|
-
};
|
|
14
|
+
subtitle?: string;
|
|
15
|
+
style?: ThemeStyle;
|
|
22
16
|
}
|
|
23
17
|
/**
|
|
24
18
|
* FishboneDiagramInstance represents a fishbone diagram instance.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
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
2
|
var _excluded = ["children"];
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
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."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _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
|
+
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; }
|
|
3
9
|
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; }
|
|
4
10
|
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; }
|
|
5
11
|
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; }
|
|
@@ -8,7 +14,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
8
14
|
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; }
|
|
9
15
|
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; }
|
|
10
16
|
import { Graph, treeToGraphData } from '@antv/g6';
|
|
11
|
-
import {
|
|
17
|
+
import { getThemeObject } from "../../theme/g6";
|
|
18
|
+
import { getGraphTitle } from "../../util/components";
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* FishboneDiagramConfig defines the configuration for rendering the fishbone diagram.
|
|
@@ -19,19 +26,26 @@ import { getBackgroundColor, getTheme, normalizePalette } from "../../util/theme
|
|
|
19
26
|
*/
|
|
20
27
|
|
|
21
28
|
var FONT_FAMILY = 'system-ui, sans-serif';
|
|
22
|
-
function getNodeSize(
|
|
23
|
-
|
|
29
|
+
function getNodeSize(text, depth, style) {
|
|
30
|
+
var _style$labelFontSize;
|
|
31
|
+
var defaultFontSize = depth === 0 ? 24 : depth === 1 ? 18 : 16;
|
|
32
|
+
var fontSize = (_style$labelFontSize = style.labelFontSize) !== null && _style$labelFontSize !== void 0 ? _style$labelFontSize : defaultFontSize;
|
|
33
|
+
var scale = fontSize / defaultFontSize;
|
|
34
|
+
if (depth >= 2) return [2, Math.ceil(30 * scale)];
|
|
35
|
+
var textWidth = measureText(text, fontSize, style.labelFontWeight, style.labelFontFamily);
|
|
36
|
+
return [Math.ceil(textWidth + (depth === 0 ? 80 : 50) * scale), Math.ceil((depth === 0 ? 70 : 42) * scale)];
|
|
24
37
|
}
|
|
25
38
|
var measureText = function () {
|
|
26
39
|
var canvas = null;
|
|
27
40
|
return function (text) {
|
|
28
41
|
var fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
|
|
29
42
|
var fontWeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'normal';
|
|
43
|
+
var fontFamily = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : FONT_FAMILY;
|
|
30
44
|
if (typeof document === 'undefined') return text.length * fontSize * 0.6;
|
|
31
45
|
if (!canvas) canvas = document.createElement('canvas');
|
|
32
46
|
var ctx = canvas.getContext('2d');
|
|
33
|
-
if (!ctx) return 0;
|
|
34
|
-
ctx.font = "".concat(fontWeight, " ").concat(fontSize, "px ").concat(
|
|
47
|
+
if (!ctx) return text.length * fontSize * 0.6;
|
|
48
|
+
ctx.font = "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily);
|
|
35
49
|
return ctx.measureText(text).width;
|
|
36
50
|
};
|
|
37
51
|
}();
|
|
@@ -95,8 +109,9 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
95
109
|
_config$theme = config.theme,
|
|
96
110
|
theme = _config$theme === void 0 ? chartTheme : _config$theme,
|
|
97
111
|
title = config.title,
|
|
112
|
+
subtitle = config.subtitle,
|
|
98
113
|
_config$style = config.style,
|
|
99
|
-
|
|
114
|
+
localStyle = _config$style === void 0 ? {} : _config$style;
|
|
100
115
|
if (!(data !== null && data !== void 0 && data.name)) {
|
|
101
116
|
throw new Error('FishboneDiagram: data with a name field is required');
|
|
102
117
|
}
|
|
@@ -109,13 +124,26 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
109
124
|
containerEl.innerHTML = '';
|
|
110
125
|
|
|
111
126
|
// Theme-derived colors, allowing style.palette to override the theme default
|
|
112
|
-
var
|
|
113
|
-
var
|
|
114
|
-
var
|
|
127
|
+
var appearance = getThemeObject('fishbone-diagram', theme, localStyle);
|
|
128
|
+
var graphTitle = getGraphTitle(title, subtitle, appearance.titleStyle);
|
|
129
|
+
var rendererTheme = appearance.theme;
|
|
130
|
+
var baseTheme = appearance.baseTheme;
|
|
131
|
+
var isDark = baseTheme === 'dark';
|
|
132
|
+
var backgroundColor = appearance.backgroundColor;
|
|
133
|
+
var palette = appearance.colors;
|
|
115
134
|
var rootFill = isDark ? '#2a2a2a' : '#EFF0F0';
|
|
116
135
|
var rootLabelFill = isDark ? '#e0e0e0' : '#262626';
|
|
117
136
|
var leafLabelFill = isDark ? '#c0c0c0' : '#262626';
|
|
118
137
|
var edgeStroke = isDark ? '#555' : '#99ADD1';
|
|
138
|
+
var nodeTheme = appearance.node.style;
|
|
139
|
+
// Deep nodes only anchor the layout; their labels consume the theme,
|
|
140
|
+
// while box paint (including outlines and shadows) belongs to depths 0–1.
|
|
141
|
+
var leafTheme = Object.fromEntries(Object.entries(nodeTheme).filter(function (_ref) {
|
|
142
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
143
|
+
key = _ref2[0];
|
|
144
|
+
return key.startsWith('label');
|
|
145
|
+
}));
|
|
146
|
+
var edgeTheme = appearance.edge.style;
|
|
119
147
|
containerEl.style.backgroundColor = backgroundColor;
|
|
120
148
|
var graphData = convertData(data);
|
|
121
149
|
assignBranchColors(graphData, palette);
|
|
@@ -126,15 +154,9 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
126
154
|
height: height,
|
|
127
155
|
autoFit: 'view',
|
|
128
156
|
autoResize: true,
|
|
129
|
-
padding:
|
|
130
|
-
theme:
|
|
131
|
-
plugins:
|
|
132
|
-
key: 'title',
|
|
133
|
-
type: 'title',
|
|
134
|
-
title: title,
|
|
135
|
-
titleFill: isDark ? '#e0e6ed' : '#000',
|
|
136
|
-
titleFontFamily: 'sans-serif'
|
|
137
|
-
}] : [],
|
|
157
|
+
padding: graphTitle.padding,
|
|
158
|
+
theme: rendererTheme,
|
|
159
|
+
plugins: graphTitle.plugins,
|
|
138
160
|
data: graphData,
|
|
139
161
|
node: {
|
|
140
162
|
type: 'rect',
|
|
@@ -142,19 +164,21 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
142
164
|
var _d$depth;
|
|
143
165
|
var depth = (_d$depth = d.depth) !== null && _d$depth !== void 0 ? _d$depth : 0;
|
|
144
166
|
var nodeStyle = {
|
|
145
|
-
radius:
|
|
146
|
-
size: getNodeSize(String(d.id), depth),
|
|
167
|
+
radius: baseTheme === 'academy' ? 0 : 8,
|
|
147
168
|
labelText: String(d.id),
|
|
148
169
|
labelPlacement: 'left',
|
|
149
170
|
labelFontFamily: FONT_FAMILY
|
|
150
171
|
};
|
|
172
|
+
if (appearance.texture === 'rough') {
|
|
173
|
+
nodeStyle.lineWidth = 0.5;
|
|
174
|
+
}
|
|
151
175
|
if (depth === 0) {
|
|
152
176
|
Object.assign(nodeStyle, {
|
|
153
177
|
fill: rootFill,
|
|
154
178
|
labelFill: rootLabelFill,
|
|
155
179
|
labelFontWeight: 'bold',
|
|
156
180
|
labelFontSize: 24,
|
|
157
|
-
labelOffsetY:
|
|
181
|
+
labelOffsetY: 0,
|
|
158
182
|
labelPlacement: 'center'
|
|
159
183
|
});
|
|
160
184
|
} else if (depth === 1) {
|
|
@@ -169,24 +193,25 @@ export var FishboneDiagram = function FishboneDiagram(options) {
|
|
|
169
193
|
} else {
|
|
170
194
|
Object.assign(nodeStyle, {
|
|
171
195
|
fill: 'transparent',
|
|
196
|
+
stroke: 'transparent',
|
|
197
|
+
lineWidth: 0,
|
|
172
198
|
labelFill: leafLabelFill,
|
|
173
199
|
labelFontSize: 16
|
|
174
200
|
});
|
|
175
201
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
202
|
+
Object.assign(nodeStyle, depth < 2 ? nodeTheme : leafTheme);
|
|
203
|
+
nodeStyle.size = getNodeSize(String(d.id), depth, nodeStyle);
|
|
179
204
|
return nodeStyle;
|
|
180
205
|
}
|
|
181
206
|
},
|
|
182
207
|
edge: {
|
|
183
208
|
type: 'polyline',
|
|
184
|
-
style: _objectSpread({
|
|
209
|
+
style: _objectSpread(_objectSpread({
|
|
185
210
|
lineWidth: 3,
|
|
186
211
|
stroke: edgeStroke
|
|
187
|
-
},
|
|
212
|
+
}, appearance.texture === 'rough' ? {
|
|
188
213
|
labelFontFamily: 'Comic Sans MS'
|
|
189
|
-
} : {})
|
|
214
|
+
} : {}), edgeTheme)
|
|
190
215
|
},
|
|
191
216
|
layout: {
|
|
192
217
|
type: 'fishbone',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraphData, VisualizationOptions } from '../../types';
|
|
1
|
+
import type { GraphData, ThemeStyle, VisualizationOptions, VisualizationTheme } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* FlowDiagramConfig defines the configuration for rendering the flow diagram.
|
|
4
4
|
*/
|
|
@@ -6,11 +6,9 @@ export interface FlowDiagramConfig {
|
|
|
6
6
|
type?: 'flow-diagram';
|
|
7
7
|
data: GraphData;
|
|
8
8
|
title?: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
palette?: string[];
|
|
13
|
-
};
|
|
9
|
+
subtitle?: string;
|
|
10
|
+
theme?: VisualizationTheme;
|
|
11
|
+
style?: ThemeStyle;
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
16
14
|
* FlowDiagramInstance represents a flow diagram instance with render and destroy methods.
|