|
@@ -1,42 +1,44 @@
|
|
|
<!-- **************************************NO.13 消火栓*************************************** -->
|
|
|
<template>
|
|
|
- <div class="chart-container">
|
|
|
- <div id="hydrant" style="width: 100%; height:55vh;">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <div class="chart-container">
|
|
|
+ <div id="hydrant" style="width: 100%; height:55vh;">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import * as echarts from 'echarts';
|
|
|
+ import * as echarts from 'echarts';
|
|
|
import {getWgry} from '@/api/bigdata.js'
|
|
|
|
|
|
- export default {
|
|
|
- name: 'hydrant',
|
|
|
- data() {
|
|
|
- return {
|
|
|
- count: 0,
|
|
|
- data_wgry:[]
|
|
|
- }
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- this.wgry()
|
|
|
- },
|
|
|
+ export default {
|
|
|
+ name: 'hydrant',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ count: 0,
|
|
|
+ getWgry: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.zzz()
|
|
|
+ },
|
|
|
|
|
|
- methods: {
|
|
|
- wgry(){
|
|
|
- let that = this
|
|
|
- getWgry().then(resp => {
|
|
|
- that.data_wgry = resp.data
|
|
|
- that.myEcharts()
|
|
|
- })
|
|
|
+ methods: {
|
|
|
+ zzz() {
|
|
|
+ setTimeout(() => {
|
|
|
+ let that = this
|
|
|
+ getWgry().then(resp => {
|
|
|
+ that.getWgry = resp.data
|
|
|
+ // alert("网格人员")
|
|
|
+ that.myEcharts()
|
|
|
+ })
|
|
|
+ }, 1000)
|
|
|
},
|
|
|
+ // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=Ve9zCnhVwZvXTdD0
|
|
|
+ myEcharts() {
|
|
|
+ let that = this
|
|
|
+ var chartDom = document.getElementById('hydrant');
|
|
|
+ var myChart = echarts.init(chartDom);
|
|
|
|
|
|
- // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=Ve9zCnhVwZvXTdD0
|
|
|
- myEcharts() {
|
|
|
-
|
|
|
-
|
|
|
- var chartDom = document.getElementById('hydrant');
|
|
|
- var myChart = echarts.init(chartDom);
|
|
|
function rand(m, n) {
|
|
|
if (!n) {
|
|
|
return Math.floor(Math.random() * m);
|
|
@@ -50,8 +52,7 @@
|
|
|
var max = 0,
|
|
|
len = arr.length;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
- var item = arr[i][key];
|
|
|
- if (max < item) max = item;
|
|
|
+ max += arr[i][key];
|
|
|
}
|
|
|
return max;
|
|
|
}
|
|
@@ -65,7 +66,7 @@
|
|
|
return val;
|
|
|
}
|
|
|
|
|
|
- var arr = this.data_wgry
|
|
|
+ var arr = that.getWgry
|
|
|
// for (var i = 0; i < 10; i++) {
|
|
|
// arr.push({
|
|
|
// name: '类目名称' + rand(99),
|
|
@@ -75,8 +76,8 @@
|
|
|
|
|
|
var max = getMax(arr, 'value'),
|
|
|
angleAxisData = getValArr(arr, 'name');
|
|
|
- $.each(arr, function(i, e) {
|
|
|
- e.value = (e.amount / max * 100).toFixed(2);
|
|
|
+ $.each(arr, function (i, e) {
|
|
|
+ e.value = (e.value / max * 100).toFixed(2);
|
|
|
});
|
|
|
var option = {
|
|
|
backgroundColor: '#222',
|
|
@@ -147,7 +148,7 @@
|
|
|
type: 'bar',
|
|
|
data: arr,
|
|
|
itemStyle: {
|
|
|
- color: function(params) {
|
|
|
+ color: function (params) {
|
|
|
var colorList = ['#5cc6ca', '#d87a7f', '#f5b97f', '#5ab1ef', '#b6a2de', '#8d98b3', '#e5d02d', '#97b552', '#956f6d', '#d0579c'];
|
|
|
return colorList[params.dataIndex];
|
|
|
}
|
|
@@ -155,21 +156,21 @@
|
|
|
coordinateSystem: 'polar',
|
|
|
}]
|
|
|
};
|
|
|
- option && myChart.setOption(option);
|
|
|
- },
|
|
|
+ option && myChart.setOption(option);
|
|
|
+ },
|
|
|
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
- .chart-container {
|
|
|
- width: 100%;
|
|
|
- height: auto;
|
|
|
- position: relative;
|
|
|
- padding-bottom: 10px;
|
|
|
- display: flex;
|
|
|
- }
|
|
|
+ .chart-container {
|
|
|
+ width: 100%;
|
|
|
+ height: auto;
|
|
|
+ position: relative;
|
|
|
+ padding-bottom: 10px;
|
|
|
+ display: flex;
|
|
|
+ }
|
|
|
</style>
|