Skip to content

Commit 3724eb2

Browse files
authored
Merge pull request #8 from pdsuwwz/feature/chart-echarts
📈 Charts catalog
2 parents e83fac5 + 1e4a9dd commit 3724eb2

File tree

19 files changed

+1341
-7
lines changed

19 files changed

+1341
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
* [ ] 表单详情(类似只读)
4040
* [ ] 表单 props rules Mixins 封装
4141
* 图表 Chart (D3, Echarts...)
42-
* [ ] 仪表盘
43-
* [ ] 折线图
44-
* [ ] 柱状图
45-
* [ ] 饼图
46-
* [ ] 散点图
47-
* [ ] 架构图
48-
* [ ] 雷达图
42+
* [x] 仪表盘
43+
* [x] 折线图
44+
* [x] 柱状图
45+
* [x] 饼图
46+
* [x] 散点图
47+
* [x] 架构图
48+
* [x] 雷达图
4949
* [ ] 混合图
5050
* 工具 Tools
5151
* [x] axios 封装

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@fortawesome/vue-fontawesome": "~2.0.0",
1616
"axios": "^0.20.0",
1717
"core-js": "^3.6.5",
18+
"echarts": "^4.9.0",
1819
"element-ui": "^2.13.2",
1920
"js-cookie": "^2.2.1",
2021
"vue": "^2.6.11",
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<div class="wrap-dialog">
3+
<el-dialog
4+
:title="title"
5+
:visible.sync="dialogVisible"
6+
:close-on-click-modal="false"
7+
:close-on-press-escape="false"
8+
:show-close="false"
9+
>
10+
<div>
11+
<slot />
12+
</div>
13+
<div slot="footer">
14+
<el-button @click="dialogVisibleHide">
15+
取 消
16+
</el-button>
17+
<el-button
18+
type="primary"
19+
@click="dialogVisibleHide"
20+
>
21+
确 定
22+
</el-button>
23+
</div>
24+
</el-dialog>
25+
</div>
26+
</template>
27+
28+
<script>
29+
30+
export default {
31+
components: {},
32+
props: {
33+
dialogVisible: {
34+
type: Boolean,
35+
deep: true,
36+
default: () => false
37+
},
38+
title: {
39+
type: String,
40+
deep: true,
41+
default: () => '图标'
42+
}
43+
},
44+
data () {
45+
return {
46+
}
47+
},
48+
computed: {},
49+
watch: {},
50+
beforeCreate () {
51+
},
52+
created () {
53+
},
54+
mounted () {
55+
},
56+
methods: {
57+
dialogVisibleHide () {
58+
this.$emit('dialogVisibleHide', false)
59+
}
60+
}
61+
}
62+
</script>
63+
<style lang='scss' scoped>
64+
//@import url(); 引入公共css类
65+
.wrap-dialog {
66+
67+
}
68+
</style>
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<template>
2+
<div class="layout-wrap">
3+
<div class="wrap-flex">
4+
<div
5+
v-for="(item, index) in chartsData"
6+
:key="index"
7+
class="wrap-flex-item"
8+
@click="onClcikItem(item)"
9+
>
10+
<div class="wrap-img">
11+
<img
12+
:src="item.imgUrl"
13+
alt=""
14+
>
15+
</div>
16+
<div class="wrap-label">
17+
<h1 :title="item.name">
18+
{{ item.name }}
19+
</h1>
20+
</div>
21+
</div>
22+
</div>
23+
<Dialog
24+
:dialog-visible="DialogVisible"
25+
:title="DialogTitle"
26+
@dialogVisibleHide="dialogVisibleHide"
27+
>
28+
<template #default>
29+
<div id="echarts-container" />
30+
</template>
31+
</Dialog>
32+
</div>
33+
</template>
34+
35+
<script>
36+
import Dialog from '@/modules/ChartsTest/components/dialog/index.vue'
37+
import Echarts from 'echarts'
38+
import echartsUtils from '@/modules/ChartsTest/utils/echarts'
39+
export default {
40+
components: {
41+
Dialog
42+
},
43+
props: {
44+
chartsData: {
45+
type: Array,
46+
deep: true,
47+
default: () => {}
48+
}
49+
},
50+
data () {
51+
return {
52+
DialogVisible: false,
53+
DialogTitle: ''
54+
}
55+
},
56+
computed: {},
57+
watch: {},
58+
beforeCreate () {
59+
},
60+
created () {
61+
},
62+
mounted () {
63+
},
64+
methods: {
65+
dialogVisibleHide (visible) {
66+
this.DialogVisible = visible
67+
},
68+
onClcikItem ({ data, name, type }) {
69+
this.DialogVisible = true
70+
this.DialogTitle = name
71+
this.$nextTick(() => {
72+
const dom = document.querySelector('#echarts-container')
73+
const echarts = Echarts.init(dom)
74+
echarts.clear()
75+
echarts.setOption(echartsUtils[type](data))
76+
})
77+
}
78+
}
79+
}
80+
</script>
81+
<style lang='scss' scoped>
82+
//@import url(); 引入公共css类
83+
.layout-wrap {
84+
.wrap-flex {
85+
width: 100%;
86+
display: flex;
87+
flex-wrap: wrap;
88+
.wrap-flex-item {
89+
width: 350px;
90+
height: 300px;
91+
box-sizing: border-box;
92+
border: 1px solid rgb(238, 238, 238);
93+
margin: 20px 12px;
94+
border-radius: 5px;
95+
transition: all .2s;
96+
box-shadow: 0px 0px 0px transparent;
97+
padding: 20px 12px;
98+
background-image: linear-gradient(180deg, rgb(253, 252, 251) 0%, rgb(210, 210, 210) 100%);
99+
&:hover {
100+
border: 1px solid #ccc;
101+
box-shadow: 0px 0px 5px rgb(236, 236, 236);
102+
cursor: pointer;
103+
}
104+
.wrap-img {
105+
text-align: center;
106+
img {
107+
width: 294px;
108+
}
109+
}
110+
.wrap-label {
111+
height: 38px;
112+
line-height: 38px;
113+
h1 {
114+
width: 294px;
115+
font-size: 20px;
116+
margin: 0px auto;
117+
white-space: nowrap;
118+
text-overflow: ellipsis;
119+
overflow: hidden;
120+
}
121+
}
122+
}
123+
}
124+
/deep/ #echarts-container {
125+
width: 100%;
126+
height: 400px;
127+
}
128+
}
129+
</style>

0 commit comments

Comments
 (0)