diff --git a/src/components/Histogram.vue b/src/components/Histogram.vue index fbca642..2b7462f 100644 --- a/src/components/Histogram.vue +++ b/src/components/Histogram.vue @@ -89,27 +89,27 @@ export default { { label: "骨科", value: [32], - isHave:false + isHave: false, }, { label: "心胸外科", value: [24], - isHave:false + isHave: false, }, { label: "普通外科", value: [42], - isHave:false + isHave: false, }, { label: "神经外科", value: [20], - isHave:false + isHave: false, }, { label: "整形外科", value: [18], - isHave:false + isHave: false, }, ], colors: [ @@ -135,61 +135,83 @@ export default { ], ], option: {}, + myChart: null, }; }, + watch: { + getDataList(newVal) { + if (this.$store.getters.isMock) { + return; + } + if (newVal.length) { + this.wrapData(newVal); + this.initOption(); + // 手动更新数据 + this.option && this.myChart && this.myChart.setOption(this.option); + } + }, + }, created() { - // 包装接口数据 - this.wrapData(this.getDataList); - - this.option = { - grid: { - height: "80%", - top: "8%", - // bottom: "5%", - }, - xAxis: { - axisTick: { - show: false, - }, - nameTextStyle: { - color: "#fff", + // 包装接口数据--初始化调用 + if (this.getDataList.length) { + if (this.$store.getters.isMock) { + console.log("sssxx"); + } else { + this.wrapData(this.getDataList); + } + } + this.initOption(); + }, + methods: { + initOption() { + this.option = { + grid: { + height: "80%", + top: "8%", + // bottom: "5%", }, - data: this.labels, - axisLabel: { - interval: 0, - rotate: -20, // 表示倾斜的角度 - color: "#fff", + xAxis: { + axisTick: { + show: false, + }, + nameTextStyle: { + color: "#fff", + }, + data: this.labels, + axisLabel: { + interval: 0, + rotate: -20, // 表示倾斜的角度 + color: "#fff", + }, }, - }, - legend: { - // data: this.getlegendData(), - // right: "25", - // top: "18", - // icon: "rect", - // itemHeight: 10, - // itemWidth: 10, - // textStyle: { - // color: "red", - // }, - show: false, - }, - yAxis: { - type: "value", - axisLabel: { - color: "#fff", + legend: { + // data: this.getlegendData(), + // right: "25", + // top: "18", + // icon: "rect", + // itemHeight: 10, + // itemWidth: 10, + // textStyle: { + // color: "red", + // }, + show: false, }, - splitLine: { - show: true, - lineStyle: { - type: "dashed", - color: ["#fff"], + yAxis: { + type: "value", + axisLabel: { + color: "#fff", + }, + splitLine: { + show: true, + lineStyle: { + type: "dashed", + color: ["#fff"], + }, }, }, - }, - series: this.getSeriesData(), - }; - }, - methods: { + series: this.getSeriesData(), + }; + }, getlegendData() { let that = this; const data = []; @@ -227,13 +249,13 @@ export default { color: "#fff", }, formatter: function (data) { - let txt = ''; - that.seriesData.forEach(a =>{ + let txt = ""; + that.seriesData.forEach((a) => { if (a.label == data.seriesName && !a.isHave) { a.isHave = true; txt = data.value; } - }) + }); return txt; }, }, @@ -295,15 +317,15 @@ export default { that.seriesData.push({ label: item.deptName, value: [item.deptCount], - isHave:false + isHave: false, }); }); }, }, mounted() { var chartDom = document.getElementById("main"); - var myChart = echarts.init(chartDom); - this.option && myChart.setOption(this.option); + this.myChart = echarts.init(chartDom); + this.option && this.myChart.setOption(this.option); }, }; diff --git a/src/store/index.js b/src/store/index.js index 3201cae..af2912c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,14 +1,14 @@ -import Vue from 'vue'; -import Vuex from 'vuex'; +import Vue from "vue"; +import Vuex from "vuex"; Vue.use(Vuex); export default new Vuex.Store({ state: { - isMock: false, + isMock: true, }, getters: { - isMock: state => state.isMock, + isMock: (state) => state.isMock, }, mutations: {}, actions: {}, diff --git a/src/views/pageMonitor/bottomLeft/OpHistogram.vue b/src/views/pageMonitor/bottomLeft/OpHistogram.vue new file mode 100644 index 0000000..123bf06 --- /dev/null +++ b/src/views/pageMonitor/bottomLeft/OpHistogram.vue @@ -0,0 +1,329 @@ + + + + + diff --git a/src/views/pageMonitor/bottomLeft/index.vue b/src/views/pageMonitor/bottomLeft/index.vue index 290dfef..b6979c1 100644 --- a/src/views/pageMonitor/bottomLeft/index.vue +++ b/src/views/pageMonitor/bottomLeft/index.vue @@ -45,7 +45,7 @@ + + diff --git a/src/views/pageMonitor/bottomRight/index.vue b/src/views/pageMonitor/bottomRight/index.vue index c572330..b49a315 100644 --- a/src/views/pageMonitor/bottomRight/index.vue +++ b/src/views/pageMonitor/bottomRight/index.vue @@ -48,7 +48,7 @@