@opentiny/vue-renderless 3.6.7 → 3.8.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/action-sheet/index.js +28 -1
- package/action-sheet/vue.js +10 -4
- package/alert/index.js +24 -2
- package/alert/vue.js +15 -11
- package/amount/index.js +4 -4
- package/anchor/index.js +1 -1
- package/autocomplete/vue.js +3 -3
- package/autonavi-map/index.js +1 -1
- package/badge/vue.js +6 -6
- package/baidu-map/index.js +1 -1
- package/bulletin-board/index.js +1 -1
- package/calendar/index.js +2 -2
- package/calendar-bar/index.js +268 -0
- package/calendar-bar/vue.js +87 -0
- package/card/index.js +84 -0
- package/card/vue.js +70 -0
- package/card-group/index.js +16 -0
- package/card-group/vue.js +21 -0
- package/card-template/index.js +1 -1
- package/carousel/index.js +89 -2
- package/carousel/vue.js +14 -5
- package/carousel-item/index.js +8 -0
- package/carousel-item/vue.js +7 -3
- package/cascader/index.js +6 -6
- package/cascader/vue.js +3 -3
- package/cascader-menu/vue.js +2 -2
- package/cascader-panel/index.js +4 -4
- package/cascader-panel/node.js +4 -4
- package/cascader-panel/vue.js +2 -2
- package/cascader-select/index.js +179 -0
- package/cascader-select/vue.js +74 -0
- package/cell/vue.js +16 -0
- package/chart-bar/index.js +3 -3
- package/chart-boxplot/index.js +2 -2
- package/chart-candle/index.js +3 -3
- package/chart-core/deps/utils.js +7 -7
- package/chart-core/index.js +2 -2
- package/chart-funnel/index.js +3 -3
- package/chart-gauge/index.js +3 -3
- package/chart-graph/index.js +1 -1
- package/chart-heatmap/index.js +2 -2
- package/chart-line/index.js +3 -3
- package/chart-liquidfill/index.js +2 -2
- package/chart-map/index.js +3 -3
- package/chart-pie/index.js +3 -3
- package/chart-radar/index.js +3 -3
- package/chart-sankey/index.js +3 -3
- package/chart-scatter/index.js +4 -4
- package/chart-sunburst/index.js +1 -1
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +3 -3
- package/chart-wordcloud/index.js +2 -2
- package/checkbox/index.js +21 -0
- package/checkbox/vue.js +16 -3
- package/checkbox-button/vue.js +1 -1
- package/collapse-item/vue.js +1 -1
- package/column-list-group/index.js +0 -0
- package/column-list-group/vue.js +14 -0
- package/column-list-item/index.js +50 -0
- package/column-list-item/vue.js +39 -0
- package/common/array.js +3 -3
- package/common/bigInt.js +5 -2
- package/common/dataset/index.js +3 -3
- package/common/date.js +2 -2
- package/common/deps/ResizeObserver.js +1 -1
- package/common/deps/clickoutside.js +1 -1
- package/common/deps/date-util.js +4 -4
- package/common/deps/date.js +2 -2
- package/common/deps/debounce.js +1 -1
- package/common/deps/dom.js +1 -1
- package/common/deps/fullscreen/apis.js +3 -3
- package/common/deps/fullscreen/screenfull.js +1 -1
- package/common/deps/infinite-scroll.js +176 -0
- package/common/deps/letter-only.js +1 -1
- package/common/deps/number-only.js +1 -1
- package/common/deps/observe-visibility.js +106 -0
- package/common/deps/popper.js +20 -22
- package/common/deps/popup-manager.js +2 -2
- package/common/deps/repeat-click.js +1 -1
- package/common/deps/resize-event.js +1 -1
- package/common/deps/tree-model/node.js +5 -5
- package/common/deps/tree-model/tree-store.js +3 -3
- package/common/deps/upload-ajax.js +2 -2
- package/common/deps/vue-popper.js +4 -4
- package/common/deps/vue-popup.js +4 -4
- package/common/index.js +2 -2
- package/common/object.js +1 -1
- package/common/runtime.js +24 -24
- package/common/string.js +23 -4
- package/common/validate/rules/range.js +2 -2
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +3 -3
- package/common/validate/schema.js +1 -1
- package/common/validate/util.js +1 -1
- package/common/validate/validations/array.js +1 -1
- package/common/validate/validations/date.js +1 -1
- package/common/validate/validations/enum.js +1 -1
- package/common/validate/validations/float.js +1 -1
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/common/validate/validations/number.js +1 -1
- package/common/validate/validations/pattern.js +1 -1
- package/common/validate/validations/string.js +1 -1
- package/common/validate/validations/type.js +1 -1
- package/container/index.js +1 -1
- package/crop/index.js +2 -2
- package/currency/index.js +2 -2
- package/date-panel/index.js +7 -7
- package/date-panel/vue.js +3 -2
- package/date-picker-mobile/index.js +250 -0
- package/date-picker-mobile/vue.js +86 -0
- package/date-range/index.js +1 -1
- package/date-range/vue.js +1 -1
- package/date-table/index.js +3 -3
- package/date-table/vue.js +1 -1
- package/dialog-box/index.js +10 -6
- package/dialog-box/vue.js +1 -1
- package/dialog-select/index.js +345 -0
- package/dialog-select/vue.js +110 -0
- package/drawer/index.js +83 -0
- package/drawer/vue.js +51 -0
- package/drop-times/index.js +1 -1
- package/dropdown/index.js +2 -2
- package/dropdown/vue.js +1 -1
- package/dropdown-item/index.js +1 -1
- package/dropdown-item/mf.js +79 -0
- package/dropdown-menu/index.js +30 -1
- package/dropdown-menu/vue.js +17 -7
- package/dynamic-scroller/index.js +117 -0
- package/dynamic-scroller/vue.js +88 -0
- package/dynamic-scroller-item/index.js +147 -0
- package/dynamic-scroller-item/vue.js +92 -0
- package/espace/index.js +1 -1
- package/espace/vue.js +1 -1
- package/exception/vue.js +3 -1
- package/fall-menu/index.js +4 -4
- package/file-upload/index.js +872 -408
- package/file-upload/vue.js +87 -36
- package/filter/index.js +131 -0
- package/filter/tag-group.js +43 -0
- package/filter/vue.js +73 -0
- package/filter-bar/index.js +9 -0
- package/filter-bar/vue.js +16 -0
- package/filter-box/index.js +17 -0
- package/filter-box/vue.js +19 -0
- package/filter-panel/index.js +42 -0
- package/filter-panel/vue.js +33 -0
- package/floatbar/index.js +1 -1
- package/flowchart/index.js +721 -0
- package/flowchart/vue.js +81 -0
- package/form/index.js +15 -1
- package/form/vue.js +10 -4
- package/form-item/index.js +46 -6
- package/form-item/vue.js +27 -3
- package/fullscreen/index.js +1 -1
- package/fullscreen/vue.js +1 -1
- package/grid/plugins/export.js +2 -2
- package/grid/plugins/exportExcel.js +2 -2
- package/grid/plugins/resize.js +1 -1
- package/grid/static/base/helperEqualCompare.js +1 -1
- package/grid/static/base/isPlainObject.js +1 -1
- package/grid/utils/common.js +3 -3
- package/grid/utils/dom.js +3 -3
- package/grid/utils/event.js +2 -2
- package/guide/index.js +168 -0
- package/guide/vue.js +36 -0
- package/hrapprover/index.js +1 -1
- package/image/index.js +8 -4
- package/image/vue.js +12 -6
- package/image-viewer/index.js +3 -3
- package/image-viewer/vue.js +16 -6
- package/input/index.js +34 -1
- package/input/vue.js +22 -6
- package/ip-address/index.js +1 -1
- package/ip-address/vue.js +1 -1
- package/link-menu/index.js +2 -2
- package/link-menu/vue.js +2 -2
- package/loading/index.js +2 -2
- package/loading/vue.js +2 -1
- package/locales/index.js +1 -1
- package/logout/index.js +1 -1
- package/milestone/index.js +5 -1
- package/modal/index.js +68 -39
- package/modal/vue.js +15 -12
- package/month-range/index.js +1 -1
- package/month-range/vue.js +1 -1
- package/month-table/index.js +5 -5
- package/month-table/vue.js +1 -1
- package/multi-select/index.js +5 -2
- package/multi-select/vue.js +4 -5
- package/nav-menu/index.js +6 -6
- package/notify/index.js +3 -3
- package/numeric/index.js +15 -5
- package/numeric/vue.js +15 -6
- package/option/index.js +1 -1
- package/package.json +2 -1
- package/pager-item/index.js +1 -1
- package/panel/index.js +1 -1
- package/picker/index.js +7 -7
- package/picker/vue.js +1 -1
- package/picker-column/index.js +1 -1
- package/popconfirm/index.js +25 -0
- package/popconfirm/vue.js +22 -0
- package/popeditor/index.js +7 -7
- package/popeditor/vue.js +2 -2
- package/popover/index.js +11 -3
- package/popover/vue.js +33 -10
- package/popup/index.js +4 -4
- package/pull-refresh/index.js +8 -11
- package/pull-refresh/vue.js +7 -7
- package/radio/index.js +17 -0
- package/radio/vue.js +18 -3
- package/radio-button/index.js +8 -0
- package/radio-button/vue.js +19 -4
- package/radio-group/index.js +1 -1
- package/radio-group/vue.js +5 -2
- package/rate/index.js +4 -2
- package/rate/vue.js +1 -1
- package/record/index.js +190 -0
- package/record/vue.js +44 -0
- package/recycle-scroller/index.js +470 -0
- package/recycle-scroller/vue.js +135 -0
- package/river/index.js +371 -0
- package/river/river.js +352 -0
- package/river/vue.js +77 -0
- package/roles/index.js +1 -1
- package/scrollbar/vue-bar.js +1 -1
- package/scrollbar/vue.js +1 -1
- package/search/index.js +3 -3
- package/select/index.js +17 -14
- package/select/vue.js +14 -8
- package/select-dropdown/vue.js +1 -1
- package/select-mobile/index.js +111 -0
- package/select-mobile/vue.js +58 -0
- package/select-view/index.js +170 -0
- package/select-view/vue.js +82 -0
- package/selected-box/index.js +216 -0
- package/selected-box/vue.js +98 -0
- package/slide-bar/index.js +1 -1
- package/slider/index.js +49 -4
- package/slider/vue.js +15 -4
- package/split/vue.js +1 -1
- package/standard-list-item/index.js +18 -0
- package/standard-list-item/vue.js +22 -0
- package/steps/index.js +30 -0
- package/steps/slide-bar.js +122 -0
- package/steps/vue.js +15 -3
- package/switch/index.js +1 -1
- package/switch/vue.js +2 -1
- package/tab-bar/index.js +2 -2
- package/tab-item/index.js +2 -2
- package/tab-item/vue.js +1 -1
- package/tab-item-mf/index.js +0 -0
- package/tab-item-mf/vue.js +16 -0
- package/tab-nav/index.js +78 -4
- package/tab-nav/vue.js +11 -3
- package/tabbar-item/index.js +1 -1
- package/tabbar-item/vue.js +1 -1
- package/tabs/index.js +8 -9
- package/tabs/vue.js +1 -1
- package/tabs-mf/index.js +109 -0
- package/tabs-mf/vue-bar.js +49 -0
- package/tabs-mf/vue-nav-item.js +22 -0
- package/tabs-mf/vue-nav.js +13 -0
- package/tabs-mf/vue.js +45 -0
- package/tabs-mf/wheel.js +71 -0
- package/tag/index.js +8 -2
- package/tag/vue.js +13 -5
- package/tag-group/index.js +24 -0
- package/tag-group/vue.js +29 -0
- package/tall-storage/index.js +1 -1
- package/tall-storage/vue.js +1 -1
- package/time/index.js +1 -1
- package/time/vue.js +2 -2
- package/time-line/index.js +28 -7
- package/time-line/vue.js +9 -4
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +1 -1
- package/time-picker-mobile/index.js +30 -0
- package/time-picker-mobile/vue.js +30 -0
- package/time-range/index.js +1 -1
- package/time-range/vue.js +1 -1
- package/time-spinner/index.js +2 -2
- package/time-spinner/vue.js +1 -1
- package/toggle-menu/index.js +2 -2
- package/toggle-menu/vue.js +1 -1
- package/tooltip/index.js +30 -3
- package/tooltip/vue.js +33 -12
- package/top-box/index.js +3 -3
- package/transfer/index.js +1 -1
- package/transfer-panel/index.js +2 -2
- package/tree/index.js +6 -6
- package/tree/vue.js +1 -1
- package/tree-node/index.js +1 -1
- package/upload/index.js +1 -2
- package/upload/vue.js +2 -2
- package/upload-dragger/index.js +5 -1
- package/upload-dragger/vue.js +9 -3
- package/upload-list/index.js +158 -8
- package/upload-list/vue.js +77 -25
- package/user/index.js +86 -70
- package/user/vue.js +15 -5
- package/user-account/vue.js +1 -1
- package/user-contact/index.js +49 -3
- package/user-contact/vue.js +17 -8
- package/user-head-group/vue.js +17 -0
- package/user-link/index.js +10 -2
- package/user-link/vue.js +11 -6
- package/wheel/index.js +1 -1
- package/wizard/index.js +3 -3
- package/year-range/index.js +125 -0
- package/year-range/vue.js +88 -0
- package/year-table/index.js +175 -11
- package/year-table/vue.js +17 -5
package/river/index.js
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../chunk-PKUHTIDK.js";
|
|
5
|
+
import { layout, bpath, txt, hexToRgba } from "./river";
|
|
6
|
+
const buildOption = ({ api, emit, props, state, vm }) => () => {
|
|
7
|
+
const WIDTH = state.canvasWidth = api.getContainerWidth() || props.config.canvasWidth;
|
|
8
|
+
const {
|
|
9
|
+
statusYes: STATUS_YES,
|
|
10
|
+
statusNo: STATUS_NO,
|
|
11
|
+
canvasHeight: HEIGHT,
|
|
12
|
+
statusColor: STATUS_COLOR,
|
|
13
|
+
tooltip: userTooltip,
|
|
14
|
+
title: userTitle
|
|
15
|
+
} = props.config;
|
|
16
|
+
const chartData = layout(props.data, __spreadProps(__spreadValues({}, props.config), { canvasWidth: WIDTH }), vm.$el);
|
|
17
|
+
const chartNodeData = chartData.filter((item) => item.type === "node");
|
|
18
|
+
const chartLinkData = chartData.filter((item) => item.type === "link");
|
|
19
|
+
const chartIconData = chartData.filter((item) => item.type === "icon");
|
|
20
|
+
const chartLegeData = chartData.filter((item) => item.type === "lege");
|
|
21
|
+
state.nameInfo = chartData.find((item) => item.type === "name");
|
|
22
|
+
emit("paths", JSON.parse(JSON.stringify(state.nameInfo.paths)));
|
|
23
|
+
const renderNode = api.getRenderNode(chartNodeData);
|
|
24
|
+
const renderLink = api.getRenderLink(chartLinkData);
|
|
25
|
+
const renderIcon = api.getRenderIcon({ chartIconData, STATUS_COLOR, STATUS_YES, STATUS_NO });
|
|
26
|
+
const renderLege = api.getRenderLege(chartLegeData);
|
|
27
|
+
const serieLine = api.getMarkLine(HEIGHT);
|
|
28
|
+
const tooltip = api.getTooltip({ userTooltip, chartData });
|
|
29
|
+
const option = {
|
|
30
|
+
grid: { left: "0%", right: "0%", bottom: "0%", top: "0%" },
|
|
31
|
+
xAxis: { min: 0, max: WIDTH, show: false },
|
|
32
|
+
yAxis: { min: 0, max: HEIGHT, show: false },
|
|
33
|
+
series: [
|
|
34
|
+
{ type: "custom", name: "1", renderItem: renderNode, data: chartNodeData, zlevel: 1 },
|
|
35
|
+
{ type: "custom", name: "2", renderItem: renderLink, data: chartLinkData, zlevel: 2 },
|
|
36
|
+
{ type: "custom", name: "3", renderItem: renderIcon, data: chartIconData, zlevel: 3 },
|
|
37
|
+
{ type: "custom", name: "4", renderItem: renderLege, data: chartLegeData, zlevel: 4 },
|
|
38
|
+
serieLine
|
|
39
|
+
],
|
|
40
|
+
tooltip: { formatter: tooltip },
|
|
41
|
+
title: userTitle
|
|
42
|
+
};
|
|
43
|
+
return option;
|
|
44
|
+
};
|
|
45
|
+
const getRenderNode = ({ api: api0, echarts }) => (chartNodeData) => {
|
|
46
|
+
const so = api0.setRiverRgbaOpacity;
|
|
47
|
+
return (params, api) => {
|
|
48
|
+
const { dataIndex, coordSys } = params;
|
|
49
|
+
const { x: sx, y: sy, width: sw, height: sh } = coordSys;
|
|
50
|
+
const data = chartNodeData[dataIndex];
|
|
51
|
+
const { x, y, width, height, g, lp, data: dataNode } = data;
|
|
52
|
+
const rectShape = echarts.graphic.clipRectByRect({ x, y, width, height }, { x: sx, y: sy, width: sw, height: sh });
|
|
53
|
+
const lg = g[0].map((stop, i) => ({ offset: stop, color: so(dataNode, g[1][i]) }));
|
|
54
|
+
const nodeLabel = txt(dataNode.label, api.font({}), lp[2]);
|
|
55
|
+
return {
|
|
56
|
+
type: "group",
|
|
57
|
+
name: "node-group",
|
|
58
|
+
children: [
|
|
59
|
+
{
|
|
60
|
+
type: "rect",
|
|
61
|
+
transition: ["shape"],
|
|
62
|
+
shape: rectShape,
|
|
63
|
+
style: { fill: new echarts.graphic.LinearGradient(0, 0, 1, 0, lg) }
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: "text",
|
|
67
|
+
style: {
|
|
68
|
+
x: lp[0],
|
|
69
|
+
y: lp[1],
|
|
70
|
+
text: nodeLabel.t,
|
|
71
|
+
textFill: so(dataNode, "rgba(0,0,0,1)")
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const getRenderLink = ({ api, echarts }) => (chartLinkData) => {
|
|
79
|
+
const so = api.setRiverRgbaOpacity;
|
|
80
|
+
return (params) => {
|
|
81
|
+
const { dataIndex } = params;
|
|
82
|
+
const data = chartLinkData[dataIndex];
|
|
83
|
+
const { lb, g, data: dataLink } = data;
|
|
84
|
+
const [posX, posY] = lb;
|
|
85
|
+
const p = bpath(data);
|
|
86
|
+
const lg = g[0].map((stop, i) => ({ offset: stop, color: so(dataLink, g[1][i]) }));
|
|
87
|
+
return {
|
|
88
|
+
type: "group",
|
|
89
|
+
name: "link-group",
|
|
90
|
+
position: [posX, posY],
|
|
91
|
+
children: [
|
|
92
|
+
{
|
|
93
|
+
type: "path",
|
|
94
|
+
transition: ["shape"],
|
|
95
|
+
shape: { d: p },
|
|
96
|
+
style: { fill: new echarts.graphic.LinearGradient(0, 0, 1, 0, lg) }
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const getRenderIcon = ({ api: api0 }) => ({ chartIconData, STATUS_COLOR, STATUS_YES, STATUS_NO }) => {
|
|
103
|
+
const so = api0.setRiverRgbaOpacity;
|
|
104
|
+
const si = api0.setRiverIconStyle;
|
|
105
|
+
return (params, api) => {
|
|
106
|
+
const { dataIndex } = params;
|
|
107
|
+
const data = chartIconData[dataIndex];
|
|
108
|
+
const { x, y, radius, lp, data: dataIcon } = data;
|
|
109
|
+
const { status, text, skip } = dataIcon;
|
|
110
|
+
if (skip)
|
|
111
|
+
return null;
|
|
112
|
+
const circleFill = STATUS_COLOR[String(status)];
|
|
113
|
+
const labelText = txt(dataIcon.label, api.font({}), lp[2]);
|
|
114
|
+
const labelTextX = labelText.o ? lp[0] - x : lp[0] + lp[2] / 2 - x;
|
|
115
|
+
const labelTextTa = labelText.o ? "" : "center";
|
|
116
|
+
const iconText = getIconText({ status, STATUS_YES, STATUS_NO, text, api, si, dataIcon });
|
|
117
|
+
return {
|
|
118
|
+
type: "group",
|
|
119
|
+
position: [x, y],
|
|
120
|
+
children: [
|
|
121
|
+
{
|
|
122
|
+
type: "circle",
|
|
123
|
+
transition: ["shape"],
|
|
124
|
+
shape: { cx: 0, cy: 0, r: si(dataIcon, "radius", radius) },
|
|
125
|
+
style: { fill: so(dataIcon, hexToRgba(si(dataIcon, "fill", circleFill))) }
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "text",
|
|
129
|
+
style: {
|
|
130
|
+
x: labelTextX,
|
|
131
|
+
y: lp[1] - y,
|
|
132
|
+
text: labelText.t,
|
|
133
|
+
textFill: so(dataIcon, hexToRgba(si(dataIcon, "labelColor", "#000"))),
|
|
134
|
+
textAlign: labelTextTa
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
iconText
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
const getIconText = ({ status, STATUS_YES, STATUS_NO, text, api, si, dataIcon }) => {
|
|
143
|
+
let tmp = { type: "path", transition: ["shape"], shape: {}, style: { fill: si(dataIcon, "color", "#fff") } };
|
|
144
|
+
if (status === STATUS_YES) {
|
|
145
|
+
tmp.shape.d = "M-1.7 4.5l9.4-9.4c.4-.4 1-.4 1.4 0 .4.4.4 1 0 1.4l-10 10.1c-.4.4-1 .4-1.";
|
|
146
|
+
tmp.shape.d += "4 0-.1 0-.1-.1-.2-.1l-5.8-5.8c-.4-.4-.4-1 0-1.4.4-.4 1-.4 1.4 0l5.2 5.2z";
|
|
147
|
+
} else if (status === STATUS_NO) {
|
|
148
|
+
tmp.shape.d = "M19.1 1.6H-6.9c-.5 0-.9-.4-.9-1s.4-1 .9-1h14.2c.5 0 .9.4.9 1s-.4 1-.9 1z";
|
|
149
|
+
} else {
|
|
150
|
+
tmp = {
|
|
151
|
+
type: "text",
|
|
152
|
+
style: {
|
|
153
|
+
x: 0,
|
|
154
|
+
y: 1,
|
|
155
|
+
text,
|
|
156
|
+
textVerticalAlign: "middle",
|
|
157
|
+
textAlign: "center",
|
|
158
|
+
textFill: si(dataIcon, "color", "#fff"),
|
|
159
|
+
textFont: api.font({ fontSize: 14 })
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return tmp;
|
|
164
|
+
};
|
|
165
|
+
const getRenderLege = () => (chartLegeData) => {
|
|
166
|
+
return (params, api) => {
|
|
167
|
+
const { dataIndex } = params;
|
|
168
|
+
const data = chartLegeData[dataIndex];
|
|
169
|
+
const { cx, cy, radius, color, x, y, t, tw } = data;
|
|
170
|
+
const legeLabel = txt(t, api.font({}), tw);
|
|
171
|
+
return {
|
|
172
|
+
type: "group",
|
|
173
|
+
name: "lege-group",
|
|
174
|
+
children: [
|
|
175
|
+
{ type: "circle", transition: ["shape"], shape: { cx, cy, r: radius }, style: { fill: color } },
|
|
176
|
+
{
|
|
177
|
+
type: "text",
|
|
178
|
+
style: { x, y, text: legeLabel.t, textVerticalAlign: "middle", textAlign: "left", textFill: color }
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
const getTooltip = () => ({ userTooltip, chartData }) => {
|
|
185
|
+
return (params) => {
|
|
186
|
+
const { data } = params;
|
|
187
|
+
const { data: dataItem, type, t: legeLabel, color: legeColor } = data;
|
|
188
|
+
if (typeof userTooltip === "function") {
|
|
189
|
+
return userTooltip(params, chartData);
|
|
190
|
+
} else if (type === "node") {
|
|
191
|
+
return dataItem.label;
|
|
192
|
+
} else if (type === "icon") {
|
|
193
|
+
return `
|
|
194
|
+
<div>Status: ${dataItem.status}</div>
|
|
195
|
+
<div>Label: ${dataItem.label}</div>
|
|
196
|
+
`;
|
|
197
|
+
} else if (type === "link") {
|
|
198
|
+
const riverNodes = chartData.filter((item) => item.type === "node");
|
|
199
|
+
const sourceRiverNode = riverNodes.find((riverNode) => riverNode.data.name === dataItem.source);
|
|
200
|
+
const targetRiverNode = riverNodes.find((riverNode) => riverNode.data.name === dataItem.target);
|
|
201
|
+
return `
|
|
202
|
+
<div>From: ${sourceRiverNode.data.label}</div>
|
|
203
|
+
<div>To: ${targetRiverNode.data.label}</div>
|
|
204
|
+
<div>Val: ${dataItem.value}</div>
|
|
205
|
+
`;
|
|
206
|
+
} else if (type === "lege") {
|
|
207
|
+
return `<div style="background:${legeColor};color:#fff">${legeLabel}</div>`;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
const getMarkLine = () => (h) => ({
|
|
212
|
+
type: "line",
|
|
213
|
+
symbol: "none",
|
|
214
|
+
data: [
|
|
215
|
+
[0, 0],
|
|
216
|
+
[0, h]
|
|
217
|
+
],
|
|
218
|
+
lineStyle: { width: 1, type: [2, 6], color: "#fff" },
|
|
219
|
+
zlevel: 0
|
|
220
|
+
});
|
|
221
|
+
const setChartOption = (state) => (option) => state.myChart.setOption(option);
|
|
222
|
+
const setListeners = ({ api, emit, state }) => (option) => {
|
|
223
|
+
const modifyOption = (option2, riverIcon) => {
|
|
224
|
+
const serieLine = option2.series.find((serie) => serie.type === "line");
|
|
225
|
+
if (riverIcon) {
|
|
226
|
+
const { x } = riverIcon;
|
|
227
|
+
serieLine.data[0][0] = serieLine.data[1][0] = x;
|
|
228
|
+
serieLine.lineStyle.color = "#000";
|
|
229
|
+
} else {
|
|
230
|
+
serieLine.lineStyle.color = "#fff";
|
|
231
|
+
}
|
|
232
|
+
return option2;
|
|
233
|
+
};
|
|
234
|
+
state.myChart.on("mousemove", { seriesName: "3" }, (params) => {
|
|
235
|
+
if (!state.markLineShow) {
|
|
236
|
+
api.setChartOption(modifyOption(option, params.data));
|
|
237
|
+
state.markLineShow = true;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
state.myChart.getZr().on("mousemove", (event) => {
|
|
241
|
+
const notIcon = (parent = event.target) => {
|
|
242
|
+
do {
|
|
243
|
+
if (~["link-group", "node-group"].indexOf(parent.name))
|
|
244
|
+
return true;
|
|
245
|
+
} while (parent = parent.parent);
|
|
246
|
+
};
|
|
247
|
+
if (state.markLineShow && (!event.target || notIcon())) {
|
|
248
|
+
api.setChartOption(modifyOption(option));
|
|
249
|
+
state.markLineShow = false;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
state.myChart.on("click", { seriesName: "1" }, (params) => emit("click-node", params));
|
|
253
|
+
state.myChart.on("click", { seriesName: "2" }, (params) => emit("click-link", params));
|
|
254
|
+
state.myChart.on("click", { seriesName: "3" }, (params) => emit("click-icon", params));
|
|
255
|
+
state.myChart.on("click", { seriesName: "4" }, (params) => emit("click-lege", params));
|
|
256
|
+
};
|
|
257
|
+
const setRiverRgbaOpacity = ({ props, state }) => (data, rgba) => {
|
|
258
|
+
const { config } = props;
|
|
259
|
+
const { nameInfo, lighting } = state;
|
|
260
|
+
const { nameField } = nameInfo;
|
|
261
|
+
const { grayOpcity, lightOpcity } = config;
|
|
262
|
+
const isw = (arr, name) => arr.find((item) => !name.indexOf(`${item}/`));
|
|
263
|
+
if (lighting && lighting.length) {
|
|
264
|
+
const ci = rgba.lastIndexOf(",");
|
|
265
|
+
const bi = rgba.lastIndexOf(")");
|
|
266
|
+
const dataName = data[nameField];
|
|
267
|
+
if (~lighting.indexOf(dataName)) {
|
|
268
|
+
return rgba.slice(0, ci + 1) + lightOpcity + rgba.slice(bi);
|
|
269
|
+
} else if (isw(lighting, dataName)) {
|
|
270
|
+
return rgba.slice(0, ci + 1) + 1 + rgba.slice(bi);
|
|
271
|
+
} else {
|
|
272
|
+
return rgba.slice(0, ci + 1) + grayOpcity + rgba.slice(bi);
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
return rgba;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const lightUp = ({ api, state }) => (param) => {
|
|
279
|
+
const { nameInfo } = state;
|
|
280
|
+
const { paths, nameSplit } = nameInfo;
|
|
281
|
+
const getIndexVal = (i) => i >= 0 && i < paths.length ? paths[i].split(nameSplit) : [];
|
|
282
|
+
const getPathVal = (path) => path ? path.split(nameSplit) : [];
|
|
283
|
+
const getArrayVal = (arr) => {
|
|
284
|
+
let res = [];
|
|
285
|
+
arr.forEach((item) => {
|
|
286
|
+
if (typeof item === "number")
|
|
287
|
+
res = res.concat(getIndexVal(item));
|
|
288
|
+
else if (typeof item === "string")
|
|
289
|
+
res = res.concat(getPathVal(item));
|
|
290
|
+
res = [...new Set(res)];
|
|
291
|
+
});
|
|
292
|
+
return res;
|
|
293
|
+
};
|
|
294
|
+
if (typeof param === "number") {
|
|
295
|
+
state.lighting = getIndexVal(param);
|
|
296
|
+
} else if (typeof param === "string") {
|
|
297
|
+
state.lighting = getPathVal(param);
|
|
298
|
+
} else if (Array.isArray(param) && param.length) {
|
|
299
|
+
state.lighting = getArrayVal(param);
|
|
300
|
+
} else {
|
|
301
|
+
state.lighting = [];
|
|
302
|
+
}
|
|
303
|
+
api.setChartOption(state.option);
|
|
304
|
+
};
|
|
305
|
+
const setRiverIconStyle = (state) => (data, type, oldValue) => {
|
|
306
|
+
const { styling, nameInfo } = state;
|
|
307
|
+
const { nameField } = nameInfo;
|
|
308
|
+
const dataName = data[nameField];
|
|
309
|
+
if (styling && styling.length) {
|
|
310
|
+
for (let i = 0; i < styling.length; i++) {
|
|
311
|
+
const stl = styling[i];
|
|
312
|
+
if (stl.name && dataName === stl.name && type && stl[type])
|
|
313
|
+
return stl[type];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return oldValue;
|
|
317
|
+
};
|
|
318
|
+
const style = ({ api, state }) => (param) => {
|
|
319
|
+
const styl = (obj) => {
|
|
320
|
+
const { nodeName, iconIndex, styles } = obj;
|
|
321
|
+
return Object.assign({}, styles, { name: `n${nodeName}/${iconIndex}`.toLowerCase() });
|
|
322
|
+
};
|
|
323
|
+
if (Array.isArray(param)) {
|
|
324
|
+
const styling = [];
|
|
325
|
+
param.forEach((item) => styling.push(styl(item)));
|
|
326
|
+
state.styling = styling;
|
|
327
|
+
} else if (typeof param === "object") {
|
|
328
|
+
state.styling = [styl(param)];
|
|
329
|
+
} else {
|
|
330
|
+
state.styling = [];
|
|
331
|
+
}
|
|
332
|
+
api.setChartOption(state.option);
|
|
333
|
+
};
|
|
334
|
+
const computeCanvasStyle = ({ props, state }) => () => {
|
|
335
|
+
const { canvasWidth, canvasTransformOrigin, canvasTransform } = state;
|
|
336
|
+
const { canvasHeight } = props.config;
|
|
337
|
+
const res = {};
|
|
338
|
+
if (canvasWidth)
|
|
339
|
+
res.width = canvasWidth + "px";
|
|
340
|
+
if (canvasHeight)
|
|
341
|
+
res.height = canvasHeight + "px";
|
|
342
|
+
if (canvasTransformOrigin)
|
|
343
|
+
res.transformOrigin = canvasTransformOrigin;
|
|
344
|
+
if (canvasTransform)
|
|
345
|
+
res.transform = canvasTransform;
|
|
346
|
+
return res;
|
|
347
|
+
};
|
|
348
|
+
const getContainerWidth = (state) => () => state.containerEl && state.containerEl.getBoundingClientRect().width;
|
|
349
|
+
const resizeListener = ({ props, state }) => () => {
|
|
350
|
+
const { ignoreZoom = true } = props.config;
|
|
351
|
+
const ratio = ignoreZoom ? window.innerWidth / window.outerWidth : 1;
|
|
352
|
+
state.canvasTransform = "scale(" + ratio + ")";
|
|
353
|
+
};
|
|
354
|
+
export {
|
|
355
|
+
buildOption,
|
|
356
|
+
computeCanvasStyle,
|
|
357
|
+
getContainerWidth,
|
|
358
|
+
getMarkLine,
|
|
359
|
+
getRenderIcon,
|
|
360
|
+
getRenderLege,
|
|
361
|
+
getRenderLink,
|
|
362
|
+
getRenderNode,
|
|
363
|
+
getTooltip,
|
|
364
|
+
lightUp,
|
|
365
|
+
resizeListener,
|
|
366
|
+
setChartOption,
|
|
367
|
+
setListeners,
|
|
368
|
+
setRiverIconStyle,
|
|
369
|
+
setRiverRgbaOpacity,
|
|
370
|
+
style
|
|
371
|
+
};
|