style:地图
Showing
3 changed files
with
12 additions
and
13 deletions
1 | <template> | 1 | <template><div :id="id" :class="className" :style="{ height: height, width: width }" /></template> |
2 | <div :id="id" :class="className" :style="{ height: height, width: width }" /> | ||
3 | </template> | ||
4 | 2 | ||
5 | <script> | 3 | <script> |
6 | import tdTheme from "./theme.json"; // 引入默认主题 | 4 | import tdTheme from "./theme.json"; // 引入默认主题 |
7 | import "../map/hanzhong.js"; | ||
8 | |||
9 | export default { | 5 | export default { |
10 | name: "echart", | 6 | name: "echart", |
11 | props: { | 7 | props: { |
... | @@ -30,14 +26,14 @@ export default { | ... | @@ -30,14 +26,14 @@ export default { |
30 | default: () => ({}), | 26 | default: () => ({}), |
31 | }, | 27 | }, |
32 | }, | 28 | }, |
33 | data() { | 29 | data () { |
34 | return { | 30 | return { |
35 | chart: null, | 31 | chart: null, |
36 | }; | 32 | }; |
37 | }, | 33 | }, |
38 | watch: { | 34 | watch: { |
39 | options: { | 35 | options: { |
40 | handler(options) { | 36 | handler (options) { |
41 | // 设置true清空echart缓存 | 37 | // 设置true清空echart缓存 |
42 | this.chart.setOption(options, true); | 38 | this.chart.setOption(options, true); |
43 | window.addEventListener("resize", () => { | 39 | window.addEventListener("resize", () => { |
... | @@ -49,19 +45,19 @@ export default { | ... | @@ -49,19 +45,19 @@ export default { |
49 | deep: true, | 45 | deep: true, |
50 | }, | 46 | }, |
51 | }, | 47 | }, |
52 | mounted() { | 48 | mounted () { |
53 | this.$echarts.registerTheme("tdTheme", tdTheme); // 覆盖默认主题 | 49 | this.$echarts.registerTheme("tdTheme", tdTheme); // 覆盖默认主题 |
54 | this.initChart(); | 50 | this.initChart(); |
55 | }, | 51 | }, |
56 | beforeDestroy() { | 52 | beforeDestroy () { |
57 | this.chart.dispose(); | 53 | this.chart.dispose(); |
58 | this.chart = null; | 54 | this.chart = null; |
59 | }, | 55 | }, |
60 | methods: { | 56 | methods: { |
61 | initChart() { | 57 | initChart () { |
62 | // 初始化echart | 58 | // 初始化echart |
63 | this.chart = this.$echarts.init(this.$el, "tdTheme"); | 59 | this.chart = this.$echarts.init(this.$el, "tdTheme"); |
64 | function nowSize(val, initWidth = 1920) { | 60 | function nowSize (val, initWidth = 1920) { |
65 | return val * (nowClientWidth / initWidth); | 61 | return val * (nowClientWidth / initWidth); |
66 | } | 62 | } |
67 | this.chart.setOption(this.options, true); | 63 | this.chart.setOption(this.options, true); | ... | ... |
... | @@ -18,6 +18,9 @@ export default { | ... | @@ -18,6 +18,9 @@ export default { |
18 | components: { | 18 | components: { |
19 | Echart, | 19 | Echart, |
20 | }, | 20 | }, |
21 | created () { | ||
22 | require(`@/common/map/hanzhong.js`) | ||
23 | }, | ||
21 | props: { | 24 | props: { |
22 | cdata: { | 25 | cdata: { |
23 | type: Array, | 26 | type: Array, |
... | @@ -98,7 +101,7 @@ export default { | ... | @@ -98,7 +101,7 @@ export default { |
98 | geo: { | 101 | geo: { |
99 | aspectScale: 1, //长宽比 | 102 | aspectScale: 1, //长宽比 |
100 | zoom: 1.1, | 103 | zoom: 1.1, |
101 | mapType: '汉中市', // 自定义扩展图表类型 | 104 | mapType: '', // 自定义扩展图表类型 |
102 | top: '15%', | 105 | top: '15%', |
103 | left: '10%', | 106 | left: '10%', |
104 | map: '汉中市', | 107 | map: '汉中市', | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | <div class="navbar-con"> | 2 | <div class="navbar-con"> |
3 | <div class="navbar"> | 3 | <div class="navbar"> |
4 | <div class="title"> | 4 | <div class="title"> |
5 | {{ logoName[0].DNAME }} | 5 | {{ logoName[0] && logoName[0].DNAME }} |
6 | </div> | 6 | </div> |
7 | <div class="user"> | 7 | <div class="user"> |
8 | 欢迎进入系统 {{ userInfo.name }} | 8 | 欢迎进入系统 {{ userInfo.name }} | ... | ... |
-
Please register or sign in to post a comment