2c8d9f2d by yangwei
2 parents 2414a7eb 9aa814ee
<template>
<div :id="id" :class="className" :style="{ height: height, width: width }" />
</template>
<template><div :id="id" :class="className" :style="{ height: height, width: width }" /></template>
<script>
import tdTheme from "./theme.json"; // 引入默认主题
import "../map/hanzhong.js";
export default {
name: "echart",
props: {
......@@ -30,14 +26,14 @@ export default {
default: () => ({}),
},
},
data() {
data () {
return {
chart: null,
};
},
watch: {
options: {
handler(options) {
handler (options) {
// 设置true清空echart缓存
this.chart.setOption(options, true);
window.addEventListener("resize", () => {
......@@ -49,19 +45,19 @@ export default {
deep: true,
},
},
mounted() {
mounted () {
this.$echarts.registerTheme("tdTheme", tdTheme); // 覆盖默认主题
this.initChart();
},
beforeDestroy() {
beforeDestroy () {
this.chart.dispose();
this.chart = null;
},
methods: {
initChart() {
initChart () {
// 初始化echart
this.chart = this.$echarts.init(this.$el, "tdTheme");
function nowSize(val, initWidth = 1920) {
function nowSize (val, initWidth = 1920) {
return val * (nowClientWidth / initWidth);
}
this.chart.setOption(this.options, true);
......
......@@ -18,6 +18,9 @@ export default {
components: {
Echart,
},
created () {
require(`@/common/map/hanzhong.js`)
},
props: {
cdata: {
type: Array,
......@@ -98,7 +101,7 @@ export default {
geo: {
aspectScale: 1, //长宽比
zoom: 1.1,
mapType: '汉中市', // 自定义扩展图表类型
mapType: '', // 自定义扩展图表类型
top: '15%',
left: '10%',
map: '汉中市',
......
......@@ -2,7 +2,7 @@
<div class="navbar-con">
<div class="navbar">
<div class="title">
{{ logoName[0].DNAME }}
{{ logoName[0] && logoName[0].DNAME }}
</div>
<div class="user">
欢迎进入系统 {{ userName }}
......