xt-element-ui 1.1.3 → 1.1.5
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/lib/css/2.9f53fb10.css +1 -0
- package/lib/css/3.f955b130.css +1 -0
- package/lib/css/4.04feac2c.css +1 -0
- package/lib/css/5.6a8558e0.css +1 -0
- package/lib/css/6.e474b334.css +1 -0
- package/lib/index.common.0.js +16448 -15696
- package/lib/index.common.2.js +298 -270
- package/lib/index.common.3.js +82 -54
- package/lib/index.common.4.js +519 -489
- package/lib/index.common.5.js +74 -46
- package/lib/index.common.6.js +76 -48
- package/lib/index.common.js +1741 -316
- package/lib/index.css +1 -1
- package/lib/index.umd.0.js +16448 -15696
- package/lib/index.umd.2.js +298 -270
- package/lib/index.umd.3.js +82 -54
- package/lib/index.umd.4.js +519 -489
- package/lib/index.umd.5.js +74 -46
- package/lib/index.umd.6.js +76 -48
- package/lib/index.umd.js +1747 -321
- package/lib/index.umd.min.0.js +3 -3
- package/lib/index.umd.min.2.js +1 -1
- package/lib/index.umd.min.3.js +1 -1
- package/lib/index.umd.min.4.js +1 -1
- package/lib/index.umd.min.5.js +1 -1
- package/lib/index.umd.min.6.js +1 -1
- package/lib/index.umd.min.js +1 -1
- package/package.json +2 -1
- package/src/components/ex-button/index.js +2 -0
- package/src/components/ex-button/index.vue +61 -0
- package/src/components/ex-button/style/index.scss +31 -0
- package/src/components/ex-card/index.js +7 -0
- package/src/components/ex-card/index.vue +150 -0
- package/src/components/ex-card/style/index.scss +69 -0
- package/src/components/{chart → ex-chart}/ExBar.vue +3 -0
- package/src/components/{chart → ex-chart}/ExLine.vue +3 -0
- package/src/components/{chart → ex-chart}/ExMulti.vue +5 -0
- package/src/components/{chart → ex-chart}/ExPie.vue +3 -0
- package/src/components/{chart → ex-chart}/ExTrend.vue +3 -0
- package/src/components/ex-chart/index.js +2 -0
- package/src/components/ex-chart/index.vue +134 -0
- package/src/components/{chart → ex-chart}/theme/dark.js +1 -1
- package/src/components/{chart → ex-chart}/utils.js +40 -12
- package/src/components/{table → ex-table}/index.vue +62 -116
- package/src/components/index.scss +16 -7
- package/src/components/{button → xt-button}/index.vue +1 -1
- package/src/components/{card-item → xt-card-item}/index.vue +1 -1
- package/src/components/{config-provider → xt-config-provider}/index.vue +66 -0
- package/src/components/{date-picker → xt-date-picker}/index.vue +1 -1
- package/src/components/{date-picker → xt-date-picker}/quarter.vue +4 -2
- package/src/components/xt-grid-box/index.vue +135 -0
- package/src/components/xt-grid-box/style/index.scss +93 -0
- package/src/components/xt-grid-item/index.js +2 -0
- package/src/components/xt-grid-item/index.vue +107 -0
- package/src/components/{text → xt-text}/index.vue +6 -0
- package/src/components/{text → xt-text}/style/index.scss +26 -1
- package/src/config/element-registry.js +136 -0
- package/src/index.js +62 -32
- package/src/styles/theme/colors.scss +1 -0
- package/src/styles/theme/font.scss +6 -3
- package/lib/css/2.3f7aa432.css +0 -1
- package/lib/css/3.ffcc175d.css +0 -1
- package/lib/css/4.9abd1f2b.css +0 -1
- package/lib/css/5.1a31ed8a.css +0 -1
- package/lib/css/6.c2d0d77e.css +0 -1
- package/src/components/chart/index.js +0 -2
- package/src/components/chart/index.vue +0 -51
- package/src/components/grid-box/index.vue +0 -42
- /package/src/components/{chart → ex-chart}/pieList.vue +0 -0
- /package/src/components/{chart → ex-chart}/theme/blue.js +0 -0
- /package/src/components/{chart → ex-chart}/theme/orange.js +0 -0
- /package/src/components/{chart → ex-chart}/theme/starry.js +0 -0
- /package/src/components/{chart → ex-chart}/theme/white.js +0 -0
- /package/src/components/{table → ex-table}/ExCell.vue +0 -0
- /package/src/components/{table → ex-table}/ExColumn.vue +0 -0
- /package/src/components/{table → ex-table}/index.js +0 -0
- /package/src/components/{table → ex-table}/processor.js +0 -0
- /package/src/components/{button → xt-button}/index.js +0 -0
- /package/src/components/{button → xt-button}/style/index.scss +0 -0
- /package/src/components/{card → xt-card}/index.js +0 -0
- /package/src/components/{card → xt-card}/index.vue +0 -0
- /package/src/components/{card → xt-card}/style/index.scss +0 -0
- /package/src/components/{card-item → xt-card-item}/index.js +0 -0
- /package/src/components/{card-item → xt-card-item}/style/index.scss +0 -0
- /package/src/components/{config-provider → xt-config-provider}/index.js +0 -0
- /package/src/components/{config-provider → xt-config-provider}/style/index.scss +0 -0
- /package/src/components/{date-picker → xt-date-picker}/SearchDate.vue +0 -0
- /package/src/components/{date-picker → xt-date-picker}/index.js +0 -0
- /package/src/components/{flex-box → xt-flex-box}/index.js +0 -0
- /package/src/components/{flex-box → xt-flex-box}/index.vue +0 -0
- /package/src/components/{flex-box → xt-flex-box}/style/index.scss +0 -0
- /package/src/components/{grid-box → xt-grid-box}/index.js +0 -0
- /package/src/components/{input → xt-input}/index.js +0 -0
- /package/src/components/{input → xt-input}/index.vue +0 -0
- /package/src/components/{input → xt-input}/style/index.scss +0 -0
- /package/src/components/{layout → xt-layout}/BaseCollapse.vue +0 -0
- /package/src/components/{layout → xt-layout}/ExFieldset.vue +0 -0
- /package/src/components/{page → xt-page}/index.js +0 -0
- /package/src/components/{page → xt-page}/index.vue +0 -0
- /package/src/components/{select-tree → xt-select-tree}/index.js +0 -0
- /package/src/components/{select-tree → xt-select-tree}/index.vue +0 -0
- /package/src/components/{text → xt-text}/index.js +0 -0
- /package/src/components/{upload → xt-upload}/index.js +0 -0
- /package/src/components/{upload → xt-upload}/index.vue +0 -0
- /package/src/components/{upload → xt-upload}/preview.vue +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-card
|
|
3
|
+
class="ex-card"
|
|
4
|
+
:class="cardClasses"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
>
|
|
7
|
+
<template #header v-if="$slots.header || title">
|
|
8
|
+
<slot name="header">{{ title }}</slot>
|
|
9
|
+
</template>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</el-card>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
name: 'ExCard',
|
|
17
|
+
inheritAttrs: false,
|
|
18
|
+
inject: {
|
|
19
|
+
xtConfig: {
|
|
20
|
+
default: () => ({
|
|
21
|
+
theme: 'light',
|
|
22
|
+
size: 'medium',
|
|
23
|
+
primaryColor: '#1890ff'
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
props: {
|
|
28
|
+
title: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: ''
|
|
31
|
+
},
|
|
32
|
+
shadow: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'always',
|
|
35
|
+
validator: (val) => ['always', 'hover', 'never'].includes(val)
|
|
36
|
+
},
|
|
37
|
+
bordered: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: true
|
|
40
|
+
},
|
|
41
|
+
bodyClass: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: ''
|
|
44
|
+
},
|
|
45
|
+
size: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: null,
|
|
48
|
+
validator: (val) => !val || ['small', 'medium', 'large'].includes(val)
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
computed: {
|
|
52
|
+
finalSize() {
|
|
53
|
+
// 优先使用组件自身的 size,其次继承 XtConfigProvider 的 size,最后使用默认值
|
|
54
|
+
return this.size || this.xtConfig.size || 'medium'
|
|
55
|
+
},
|
|
56
|
+
cardClasses() {
|
|
57
|
+
return [
|
|
58
|
+
`ex-card-${this.shadow}`,
|
|
59
|
+
`ex-card-${this.finalSize}`,
|
|
60
|
+
{
|
|
61
|
+
'ex-card-no-border': !this.bordered,
|
|
62
|
+
[this.bodyClass]: this.bodyClass
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<style scoped lang="scss">
|
|
71
|
+
.ex-card {
|
|
72
|
+
transition: all 0.3s;
|
|
73
|
+
border-radius: 8px;
|
|
74
|
+
|
|
75
|
+
::v-deep .el-card__header {
|
|
76
|
+
padding: 12px 16px;
|
|
77
|
+
border-bottom: 1px solid #ebeef5;
|
|
78
|
+
background-color: #fafafa;
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
::v-deep .el-card__body {
|
|
83
|
+
padding: 16px;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* small size */
|
|
88
|
+
.ex-card-small {
|
|
89
|
+
border-radius: 8px;
|
|
90
|
+
|
|
91
|
+
::v-deep .el-card__header {
|
|
92
|
+
padding: 12px 16px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
::v-deep .el-card__body {
|
|
96
|
+
padding: 16px;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* medium size */
|
|
101
|
+
.ex-card-medium {
|
|
102
|
+
border-radius: 10px;
|
|
103
|
+
|
|
104
|
+
::v-deep .el-card__header {
|
|
105
|
+
padding: 14px 18px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
::v-deep .el-card__body {
|
|
109
|
+
padding: 18px;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* large size */
|
|
114
|
+
.ex-card-large {
|
|
115
|
+
border-radius: 12px;
|
|
116
|
+
|
|
117
|
+
::v-deep .el-card__header {
|
|
118
|
+
padding: 16px 20px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
::v-deep .el-card__body {
|
|
122
|
+
padding: 20px;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.ex-card-always {
|
|
127
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.ex-card-hover {
|
|
131
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
132
|
+
|
|
133
|
+
&:hover {
|
|
134
|
+
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.15);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.ex-card-never {
|
|
139
|
+
box-shadow: none;
|
|
140
|
+
border: 1px solid #ebeef5;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.ex-card-no-border {
|
|
144
|
+
border: none;
|
|
145
|
+
|
|
146
|
+
::v-deep .el-card__header {
|
|
147
|
+
border-bottom: none;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// ExCard 组件样式
|
|
2
|
+
@import '../../../styles/variables.scss';
|
|
3
|
+
|
|
4
|
+
.ex-card {
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
transition: all 0.3s;
|
|
7
|
+
font-size: var(--ex-card-font-size, 14px);
|
|
8
|
+
|
|
9
|
+
.el-card__header {
|
|
10
|
+
padding: var(--ex-card-header-padding, 16px 20px);
|
|
11
|
+
border-bottom: 1px solid #ebeef5;
|
|
12
|
+
background-color: #fafafa;
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.el-card__body {
|
|
17
|
+
padding: var(--ex-card-body-padding, 20px);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ex-card-small {
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
|
|
24
|
+
.el-card__header {
|
|
25
|
+
font-size: 12px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ex-card-medium {
|
|
30
|
+
font-size: 14px;
|
|
31
|
+
|
|
32
|
+
.el-card__header {
|
|
33
|
+
font-size: 14px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ex-card-large {
|
|
38
|
+
font-size: 16px;
|
|
39
|
+
|
|
40
|
+
.el-card__header {
|
|
41
|
+
font-size: 16px;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ex-card-always {
|
|
46
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ex-card-hover {
|
|
50
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.15);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ex-card-never {
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
border: 1px solid #ebeef5;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.ex-card-no-border {
|
|
63
|
+
border: none;
|
|
64
|
+
|
|
65
|
+
.el-card__header {
|
|
66
|
+
border-bottom: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ex-bar v-if="type=='bar'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-bar>
|
|
3
|
+
<ex-line v-else-if="type=='line'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-line>
|
|
4
|
+
<ex-pie v-else-if="type=='pie'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-pie>
|
|
5
|
+
<ex-multi v-else-if="type=='multi'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-multi>
|
|
6
|
+
<ex-trend v-else-if="type=='trend'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-trend>
|
|
7
|
+
</template>
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
name: "ExChart",
|
|
11
|
+
components: {
|
|
12
|
+
ExBar: () => import("./ExBar.vue"),
|
|
13
|
+
ExLine: () => import("./ExLine.vue"),
|
|
14
|
+
ExPie: () => import("./ExPie.vue"),
|
|
15
|
+
ExMulti: () => import("./ExMulti.vue"),
|
|
16
|
+
ExTrend: () => import("./ExTrend.vue")
|
|
17
|
+
},
|
|
18
|
+
props: {
|
|
19
|
+
theme: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "medium",
|
|
26
|
+
validator: (value) => {
|
|
27
|
+
return ['small', 'medium', 'large'].includes(value)
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
type: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
default: "bar"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
myTheme: this.theme,
|
|
39
|
+
mySize: this.size,
|
|
40
|
+
observer: null
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
mounted() {
|
|
44
|
+
// 初始化时检测父元素的 data-theme
|
|
45
|
+
this.detectParentTheme();
|
|
46
|
+
|
|
47
|
+
// 监听父元素的 data-theme 属性变化
|
|
48
|
+
this.observeThemeChange();
|
|
49
|
+
},
|
|
50
|
+
beforeUnmount() {
|
|
51
|
+
// 清理观察器
|
|
52
|
+
if (this.observer) {
|
|
53
|
+
this.observer.disconnect();
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
watch: {
|
|
57
|
+
theme(newVal) {
|
|
58
|
+
this.myTheme = newVal;
|
|
59
|
+
},
|
|
60
|
+
size(newVal) {
|
|
61
|
+
this.mySize = newVal;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
methods: {
|
|
65
|
+
// 检测父元素的 data-theme 属性
|
|
66
|
+
detectParentTheme() {
|
|
67
|
+
if (this.theme) {
|
|
68
|
+
// 如果用户显式传入了 theme prop,使用传入的值
|
|
69
|
+
this.myTheme = this.theme;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 查找最近的带有 data-theme 属性的父元素
|
|
74
|
+
let parent = this.$el ? this.$el.parentElement : null;
|
|
75
|
+
while (parent) {
|
|
76
|
+
const parentTheme = parent.getAttribute('data-theme');
|
|
77
|
+
if (parentTheme) {
|
|
78
|
+
this.myTheme = parentTheme === 'dark' ? 'dark' : 'default';
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
parent = parent.parentElement;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 如果没有找到,检查 document.body 或 document.documentElement
|
|
85
|
+
const bodyTheme = document.body.getAttribute('data-theme');
|
|
86
|
+
const htmlTheme = document.documentElement.getAttribute('data-theme');
|
|
87
|
+
if (bodyTheme === 'dark' || htmlTheme === 'dark') {
|
|
88
|
+
this.myTheme = 'dark';
|
|
89
|
+
} else {
|
|
90
|
+
this.myTheme = 'default';
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
// 监听主题变化
|
|
95
|
+
observeThemeChange() {
|
|
96
|
+
if (!this.$el) return;
|
|
97
|
+
|
|
98
|
+
// 创建 MutationObserver 监听父元素的属性变化
|
|
99
|
+
this.observer = new MutationObserver((mutations) => {
|
|
100
|
+
mutations.forEach((mutation) => {
|
|
101
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') {
|
|
102
|
+
const newTheme = mutation.target.getAttribute('data-theme');
|
|
103
|
+
if (newTheme === 'dark') {
|
|
104
|
+
this.myTheme = 'dark';
|
|
105
|
+
} else if (newTheme === 'light') {
|
|
106
|
+
this.myTheme = 'default';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// 监听当前元素和所有父元素的属性变化
|
|
113
|
+
let parent = this.$el.parentElement;
|
|
114
|
+
while (parent) {
|
|
115
|
+
this.observer.observe(parent, {
|
|
116
|
+
attributes: true,
|
|
117
|
+
attributeFilter: ['data-theme']
|
|
118
|
+
});
|
|
119
|
+
parent = parent.parentElement;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 同时监听 body 和 html 的变化
|
|
123
|
+
this.observer.observe(document.body, {
|
|
124
|
+
attributes: true,
|
|
125
|
+
attributeFilter: ['data-theme']
|
|
126
|
+
});
|
|
127
|
+
this.observer.observe(document.documentElement, {
|
|
128
|
+
attributes: true,
|
|
129
|
+
attributeFilter: ['data-theme']
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
</script>
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as echarts from "echarts";
|
|
2
|
-
|
|
3
1
|
import themeWhite from "./theme/white";
|
|
4
2
|
import themeDark from "./theme/dark";
|
|
5
3
|
import themeBlue from "./theme/blue";
|
|
@@ -15,8 +13,22 @@ const themeKeys = {
|
|
|
15
13
|
"orange": themeOrange
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
// echarts 仅在客户端加载,避免 SSR 编译/渲染报错
|
|
17
|
+
let echarts = null;
|
|
18
|
+
|
|
19
|
+
function getEcharts() {
|
|
20
|
+
if (!echarts && typeof window !== 'undefined') {
|
|
21
|
+
try {
|
|
22
|
+
echarts = require('echarts');
|
|
23
|
+
// 注册所有主题
|
|
24
|
+
for (const key in themeKeys) {
|
|
25
|
+
echarts.registerTheme(key, themeKeys[key]);
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.warn('[ExChart] echarts 加载失败:', e.message);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return echarts;
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
// 字体大小配置
|
|
@@ -162,6 +174,10 @@ EchartsUtil.applyFontSize = function(themeOption, size) {
|
|
|
162
174
|
};
|
|
163
175
|
|
|
164
176
|
EchartsUtil.init = function(dom, theme, customOption, size) {
|
|
177
|
+
const ec = getEcharts();
|
|
178
|
+
// SSR 环境下忽略初始化
|
|
179
|
+
if (!ec || !dom) return null;
|
|
180
|
+
|
|
165
181
|
theme = theme || "default";
|
|
166
182
|
size = size || "medium";
|
|
167
183
|
customOption = customOption || {};
|
|
@@ -178,7 +194,7 @@ EchartsUtil.init = function(dom, theme, customOption, size) {
|
|
|
178
194
|
|
|
179
195
|
const option = this.mergeOptions(themeOption, customOption);
|
|
180
196
|
|
|
181
|
-
const chart =
|
|
197
|
+
const chart = ec.init(dom, useTheme);
|
|
182
198
|
chart.setOption(option, true);
|
|
183
199
|
|
|
184
200
|
this.chartInstanceList.push({
|
|
@@ -193,7 +209,8 @@ EchartsUtil.init = function(dom, theme, customOption, size) {
|
|
|
193
209
|
};
|
|
194
210
|
|
|
195
211
|
EchartsUtil.changeSingleTheme = function(dom, chartIns, customOption, newTheme) {
|
|
196
|
-
|
|
212
|
+
const ec = getEcharts();
|
|
213
|
+
if (!ec || !dom || !chartIns) return;
|
|
197
214
|
|
|
198
215
|
customOption = customOption || {};
|
|
199
216
|
newTheme = newTheme || "default";
|
|
@@ -201,7 +218,7 @@ EchartsUtil.changeSingleTheme = function(dom, chartIns, customOption, newTheme)
|
|
|
201
218
|
this.currentTheme = newTheme;
|
|
202
219
|
chartIns.dispose();
|
|
203
220
|
|
|
204
|
-
const newChart =
|
|
221
|
+
const newChart = ec.init(dom, newTheme, customOption);
|
|
205
222
|
|
|
206
223
|
const item = this.chartInstanceList.find(function(v) {
|
|
207
224
|
return v.dom === dom;
|
|
@@ -214,26 +231,37 @@ EchartsUtil.changeSingleTheme = function(dom, chartIns, customOption, newTheme)
|
|
|
214
231
|
return newChart;
|
|
215
232
|
};
|
|
216
233
|
|
|
217
|
-
EchartsUtil.changeAllTheme = function(newTheme) {
|
|
218
|
-
|
|
234
|
+
EchartsUtil.changeAllTheme = function(newTheme, newSize) {
|
|
235
|
+
const ec = getEcharts();
|
|
236
|
+
if (!ec || !newTheme) return;
|
|
219
237
|
|
|
220
238
|
this.currentTheme = newTheme;
|
|
239
|
+
// 如果传入了新的 size,则更新全局 size
|
|
240
|
+
if (newSize) {
|
|
241
|
+
this.currentSize = newSize;
|
|
242
|
+
}
|
|
221
243
|
|
|
222
244
|
this.chartInstanceList.forEach(function(item) {
|
|
223
245
|
const dom = item.dom;
|
|
224
246
|
const chart = item.chart;
|
|
225
247
|
const customOption = item.customOption;
|
|
248
|
+
// 使用图表自己的 size,如果没有则使用全局 size
|
|
249
|
+
const useSize = item.size || EchartsUtil.currentSize;
|
|
226
250
|
|
|
227
251
|
if (chart) {
|
|
228
252
|
chart.dispose();
|
|
229
253
|
}
|
|
230
254
|
|
|
231
|
-
const newChart =
|
|
232
|
-
|
|
255
|
+
const newChart = ec.init(dom, newTheme);
|
|
256
|
+
let themeOption = themeKeys[newTheme];
|
|
257
|
+
// 应用字体大小配置
|
|
258
|
+
themeOption = EchartsUtil.applyFontSize(themeOption, useSize);
|
|
233
259
|
const option = EchartsUtil.mergeOptions(themeOption, customOption);
|
|
234
260
|
|
|
235
261
|
newChart.setOption(option, true);
|
|
236
262
|
item.chart = newChart;
|
|
263
|
+
// 更新图表的 size 记录
|
|
264
|
+
item.size = useSize;
|
|
237
265
|
EchartsUtil.bindResize(newChart);
|
|
238
266
|
});
|
|
239
267
|
};
|
|
@@ -270,4 +298,4 @@ EchartsUtil.destroyAll = function() {
|
|
|
270
298
|
|
|
271
299
|
export default EchartsUtil;
|
|
272
300
|
|
|
273
|
-
export {
|
|
301
|
+
export { getEcharts };
|