2020-01-03 17:17:09 +08:00
|
|
|
|
<style lang="scss">
|
2020-06-01 19:10:45 +08:00
|
|
|
|
@import './chart.scss';
|
2020-01-03 17:17:09 +08:00
|
|
|
|
</style>
|
|
|
|
|
|
<template>
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<div class="nz-chart-resize">
|
|
|
|
|
|
<div class="resize-shadow" ref="resizeShadow"></div>
|
2020-05-31 13:44:47 +08:00
|
|
|
|
<div class="resize-box resize-box-echarts" ref="resizeBox">
|
2020-06-05 17:09:27 +08:00
|
|
|
|
<div class="line-chart-block" :id="'lineChartDiv'+chartIndex" @mouseenter="mouseEnterChart" @mouseleave="mouseLeaveChart">
|
2020-06-01 20:47:36 +08:00
|
|
|
|
<loading :ref="'localLoading'+chartIndex"></loading>
|
2020-06-07 21:39:07 +08:00
|
|
|
|
<div class="clearfix chartTitle" :class="{'drag-disabled': this.filter.from == 'alertRule'}" :id="'chartTitle'+chartIndex" >
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<el-popover
|
|
|
|
|
|
v-if="isError"
|
|
|
|
|
|
placement="top-start"
|
|
|
|
|
|
:close-delay=10
|
|
|
|
|
|
trigger="hover"
|
|
|
|
|
|
popper-class="chart-error-popper">
|
|
|
|
|
|
<div >{{errorContent}}</div>
|
2020-06-01 20:47:36 +08:00
|
|
|
|
<span slot="reference" class="panel-info-corner panel-info-corner--error">
|
2020-05-31 13:44:47 +08:00
|
|
|
|
<i class="nz-icon nz-icon-warning fa"></i>
|
|
|
|
|
|
<span class="panel-info-corner-inner"></span>
|
|
|
|
|
|
</span>
|
2020-05-29 21:06:55 +08:00
|
|
|
|
</el-popover>
|
2020-06-24 10:31:19 +08:00
|
|
|
|
<span class="moreTitle">
|
|
|
|
|
|
<el-popover
|
|
|
|
|
|
v-if="seriesItem.length!==seriesItemArr.length"
|
|
|
|
|
|
placement="top-start"
|
|
|
|
|
|
:close-delay=10
|
|
|
|
|
|
trigger="hover"
|
|
|
|
|
|
popper-class="chart-warring-popper">
|
|
|
|
|
|
<div class="moreTitle">{{$t('dashboard.panel.moreTitle')}}{{$t('dashboard.panel.showAll')}}{{seriesItem.length}}</div>
|
|
|
|
|
|
<span slot="reference" class="panel-info-corner panel-info-corner--error" @click="loadMore">
|
|
|
|
|
|
<i class="nz-icon nz-icon-warning fa"></i>
|
|
|
|
|
|
<span class="panel-info-corner-inner"></span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</span>
|
2020-06-05 17:09:27 +08:00
|
|
|
|
<el-dropdown trigger="click" class="nz-chart-top" :key="'chartDropdown'+chartIndex" v-clickoutside="clickos">
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<el-dropdown-menu style="display: none"></el-dropdown-menu>
|
2020-09-14 15:27:26 +08:00
|
|
|
|
<span class="el-dropdown-link chart-title" @click.stop="dropdownMenuShow=!dropdownMenuShow">
|
2020-11-17 17:14:12 +08:00
|
|
|
|
<span class="chart-title-text">{{chartData.title}}</span>
|
2020-10-22 13:52:40 +08:00
|
|
|
|
<span class="chart-title-icon" v-if="filter.from != 'alertRule'"><i class="nz-icon nz-icon-xialaxuanze " :class="{'visible':caretShow,'hidden':!caretShow}"></i></span>
|
2020-05-31 13:44:47 +08:00
|
|
|
|
</span>
|
2020-06-07 21:39:07 +08:00
|
|
|
|
<ul v-if="filter.from != 'alertRule'" slot="dropdown" v-show="dropdownMenuShow" :id="'dropdownUl'+chartIndex" :class="{'el-dropdown-menu nz-chart-dropdown':!isExplore,'el-dropdown-menu nz-chart-dropdown-one':isExplore}" style="position: absolute; top: 30px; left: calc(50% - 79px); transform-origin: center top; z-index: 1000;" >
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<li v-show="!isExplore" @click="refreshChart" class="el-dropdown-menu__item">
|
|
|
|
|
|
<i class="global-active-color el-icon-refresh-right" style="font-size: 16px;"></i><span>{{$t('dashboard.refresh')}}</span></li>
|
|
|
|
|
|
<li v-show="!isExplore" @click="editChart" class="el-dropdown-menu__item">
|
|
|
|
|
|
<i class="nz-icon nz-icon-edit" style="font-size: 14px; margin-right: 11px; margin-left: 1px;"></i>{{$t('dashboard.edit')}}</li>
|
|
|
|
|
|
<li v-show="!isExplore" @click="removeChart" class="el-dropdown-menu__item">
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<i class="nz-icon nz-icon-delete" style="font-size: 16px;"></i>{{$t('dashboard.delete')}}</li>
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<li @click="showAllScreen" class="el-dropdown-menu__item">
|
|
|
|
|
|
<i class="el-icon-full-screen" style="font-size: 16px;"></i>{{$t('dashboard.screen')}}</li>
|
|
|
|
|
|
<li v-show="!isExplore" @click="duplicate" class="el-dropdown-menu__item">
|
|
|
|
|
|
<i class="el-icon-copy-document" style="font-size: 16px;"></i>{{$t('dashboard.duplicate')}}</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</div>
|
2020-06-24 10:31:19 +08:00
|
|
|
|
<!--<div v-if="seriesItem.length!==seriesItemArr.length" class="more"><i class="el-icon-warning"></i> {{$t('dashboard.panel.moreFirstTitle')}} {{seriesLength}}{{$t('dashboard.panel.moreSecondTitle')}}<span @click="loadMore" class="moreClick">{{$t('dashboard.panel.moreThirdTitle')}}{{seriesItem.length}}</span></div>-->
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<div class="line-area" ref="lineChartArea" :id="'lineChartArea'+chartIndex" v-show="firstShow" style="width:100%;"></div>
|
2020-06-08 15:22:26 +08:00
|
|
|
|
<div class="chart-no-data" v-show="noData">No Data</div>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
<template v-if="!hasLegendOptions">
|
2020-11-20 14:38:40 +08:00
|
|
|
|
<div class='legend-container' ref="legendArea" v-show="firstShow" v-scrollBar:legend>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
<div v-for="(item, index) in legendListMore" :title="item.alias?item.alias:item.name" @click="clickLegend(item.name,index)" class="legend-item" :class="{'ft-gr':isGrey[index]}" :key="'legend_' + item.name+'_'+index">
|
|
|
|
|
|
<span class="legend-shape" :style="{background:(isGrey[index]?'#D3D3D3':item.color)}"></span>{{item.alias?item.alias:item.name}}
|
|
|
|
|
|
</div>
|
2020-05-29 21:06:55 +08:00
|
|
|
|
</div>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<div class='legend-container' ref="legendArea" v-show="firstShow" v-scrollBar:legend>
|
2020-11-02 10:32:23 +08:00
|
|
|
|
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
|
2020-09-18 11:04:44 +08:00
|
|
|
|
<th style="width: 100%"></th>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
<template v-for="legendOption in legendOptions">
|
2020-09-18 11:04:44 +08:00
|
|
|
|
<th v-if="legendOption.value == 'on'" class="option-th legend-option-cell" >
|
2020-09-18 10:53:09 +08:00
|
|
|
|
<span @click="legendValueSort(legendOption,legendListMore,legendOptions)">{{legendOption.option}}</span>
|
|
|
|
|
|
<span ><i style="font-size: 12px !important;" :class="{'nz-icon nz-icon-arrow-down':legendOption.sort =='asc','nz-icon nz-icon-arrow-up':legendOption.sort=='desc'}" ></i></span>
|
|
|
|
|
|
</th>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<tr v-for="(item, index) in legendListMore" :key="'legend_' + item.name+'_'+index">
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<div :title="item.alias?item.alias:item.name" @click="clickLegend(item.name,index)" class="legend-item" :class="{'ft-gr':isGrey[index]}" >
|
|
|
|
|
|
<span class="legend-shape" :style="{background:(isGrey[index]?'#D3D3D3':item.color)}"></span>{{item.alias?item.alias:item.name}}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<template v-for="legendOption in legendOptions">
|
2020-09-18 11:04:44 +08:00
|
|
|
|
<td v-if="legendOption.value == 'on'" class="legend-option-cell">{{formatLegendData(item[legendOption.option])}}</td>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2020-03-17 19:30:27 +08:00
|
|
|
|
<!--
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<Modal title="查看" v-model="screenModal" width="96%" class="line-chart-block-modal">-->
|
|
|
|
|
|
<el-dialog class="line-chart-block-modal nz-dialog"
|
|
|
|
|
|
:title="$t('dashboard.panel.view')"
|
|
|
|
|
|
:visible.sync="screenModal"
|
|
|
|
|
|
width="90%"
|
2020-06-23 18:48:40 +08:00
|
|
|
|
@close="screenModal = false;screenLegendListMore=[]"
|
2020-05-29 21:06:55 +08:00
|
|
|
|
style="margin-top: 1vh !important;"
|
2020-09-25 17:45:18 +08:00
|
|
|
|
@opened="initDialog"
|
|
|
|
|
|
:modal-append-to-body="false"
|
|
|
|
|
|
>
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<el-popover
|
|
|
|
|
|
v-if="isError"
|
|
|
|
|
|
placement="top-start"
|
|
|
|
|
|
:close-delay=10
|
|
|
|
|
|
trigger="hover"
|
|
|
|
|
|
popper-class="chart-error-popper">
|
|
|
|
|
|
<div >{{errorContent}}</div>
|
|
|
|
|
|
<span slot="reference" class="panel-info-corner panel-info-corner--error">
|
|
|
|
|
|
<i class="nz-icon nz-icon-warning fa-model" ></i>
|
|
|
|
|
|
<span class="panel-info-corner-inner"></span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</el-popover>
|
2020-06-24 10:31:19 +08:00
|
|
|
|
<span class="moreTitle">
|
|
|
|
|
|
<el-popover
|
|
|
|
|
|
v-if="seriesItemScreen.length!==seriesItemArrScreen.length"
|
|
|
|
|
|
placement="top-start"
|
|
|
|
|
|
:close-delay=10
|
|
|
|
|
|
trigger="hover"
|
|
|
|
|
|
popper-class="chart-warring-popper">
|
|
|
|
|
|
<div class="moreTitle">{{$t('dashboard.panel.moreTitle')}}{{$t('dashboard.panel.showAll')}}{{seriesItemScreen.length}}</div>
|
|
|
|
|
|
<span slot="reference" class="panel-info-corner panel-info-corner--error" @click="loadScreenMore">
|
|
|
|
|
|
<i class="nz-icon nz-icon-warning fa-model"></i>
|
|
|
|
|
|
<span class="panel-info-corner-inner"></span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</span>
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<div slot="title" >
|
|
|
|
|
|
<span class="nz-dialog-title" v-show="!isExplore">{{data.title}}</span>
|
|
|
|
|
|
<span class="nz-dialog-title" v-show="isExplore"> </span>
|
|
|
|
|
|
<div class="float-right panel-calendar dialog-tool">
|
2020-03-17 19:30:27 +08:00
|
|
|
|
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<time-picker ref="calendarPanel" class="nz-dashboard-picker" style="margin-top: -12px;" @change="dateChange"></time-picker>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="line-area" ref="screenShowArea" id="screenShowArea" style="margin-top:0px;" @mouseenter="mouseEnterFullChart" @mouseleave="mouseLeaveFullChart"></div>
|
2020-06-08 15:22:26 +08:00
|
|
|
|
<div class="chart-no-data" v-show="noData">No Data</div>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
<template v-if="!hasLegendOptions">
|
|
|
|
|
|
<div class="legend-container legend-container-screen" :id="'screenLegendArea'+chartIndex" @mouseenter="mouseEnterFullChart" @mouseleave="mouseLeaveFullChart" v-show="showLegend" v-scrollBar:legend>
|
|
|
|
|
|
<div v-for="(item, index) in screenLegendListMore" :title="item.alias?item.alias:item.name" @click="clickScreenLegend(item.name,index)" class="legend-item" :class="{'ft-gr':isGreyScreen[index]}" :key="'legend_' + item.name+'_'+index">
|
|
|
|
|
|
<span class="legend-shape" :style="{background:(isGreyScreen[index]?'#D3D3D3':item.color)}"></span>{{item.alias?item.alias:item.name}}
|
|
|
|
|
|
<br/><!--bgColorList[index]-->
|
|
|
|
|
|
</div>
|
2020-05-29 21:06:55 +08:00
|
|
|
|
</div>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<div class="legend-container legend-container-screen" :id="'screenLegendArea'+chartIndex" @mouseenter="mouseEnterFullChart" @mouseleave="mouseLeaveFullChart" v-show="showLegend" v-scrollBar:legend>
|
2020-11-02 10:32:23 +08:00
|
|
|
|
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
|
2020-09-18 11:04:44 +08:00
|
|
|
|
<th style="width: 100%"></th>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
<template v-for="legendOption in screenLegendOptions">
|
2020-09-18 11:04:44 +08:00
|
|
|
|
<th v-if="legendOption.value == 'on'" class="option-th legend-option-cell" >
|
2020-09-18 10:53:09 +08:00
|
|
|
|
<span @click="legendValueSort(legendOption,screenLegendListMore,screenLegendOptions)">{{legendOption.option}}</span>
|
|
|
|
|
|
<span ><i style="font-size: 12px !important;" :class="{'nz-icon nz-icon-arrow-down':legendOption.sort =='asc','nz-icon nz-icon-arrow-up':legendOption.sort=='desc'}" ></i></span>
|
|
|
|
|
|
</th>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<tr v-for="(item, index) in screenLegendListMore" :key="'legend_' + item.name+'_'+index">
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<div :title="item.alias?item.alias:item.name" @click="clickScreenLegend(item.name,index)" class="legend-item" :class="{'ft-gr':isGreyScreen[index]}" >
|
|
|
|
|
|
<span class="legend-shape" :style="{background:(isGreyScreen[index]?'#D3D3D3':item.color)}"></span>{{item.alias?item.alias:item.name}}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<template v-for="legendOption in screenLegendOptions">
|
2020-09-18 11:04:44 +08:00
|
|
|
|
<td v-if="legendOption.value == 'on'" class="legend-option-cell">{{formatLegendData(item[legendOption.option])}}</td>
|
2020-09-18 10:53:09 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2020-02-11 17:46:09 +08:00
|
|
|
|
|
2020-05-29 21:06:55 +08:00
|
|
|
|
<loading :ref="'localLoadingScreen'+chartIndex"></loading>
|
|
|
|
|
|
</el-dialog>
|
2020-03-19 20:44:14 +08:00
|
|
|
|
</div>
|
2020-06-07 21:39:07 +08:00
|
|
|
|
<span class="vue-resizable-handle" @mousedown="startResize" v-if="filter.from != 'alertRule'"></span>
|
2020-02-11 17:46:09 +08:00
|
|
|
|
</div>
|
2020-01-03 17:17:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2020-02-14 17:57:15 +08:00
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
import echarts from 'echarts';
|
|
|
|
|
|
import bus from '../../libs/bus';
|
2020-02-19 21:33:54 +08:00
|
|
|
|
import loading from "../common/loading";
|
2020-09-25 11:48:54 +08:00
|
|
|
|
import chartDataFormat from './chartDataFormat';
|
|
|
|
|
|
import {randomcolor} from '../common/js/radomcolor/randomcolor.js';
|
|
|
|
|
|
import timePicker from '../common/timePicker';
|
2020-06-03 18:58:07 +08:00
|
|
|
|
import chartConfig from "../page/dashboard/overview/chartConfig";
|
2020-09-29 09:25:43 +08:00
|
|
|
|
import {getChart, setChart,lineChartMove,getMousePoint} from "../common/js/common";
|
2020-09-25 11:48:54 +08:00
|
|
|
|
|
2020-02-14 17:57:15 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'lineChartBlock',
|
|
|
|
|
|
components: {
|
2020-02-19 21:33:54 +08:00
|
|
|
|
'loading': loading,
|
2020-04-24 17:00:56 +08:00
|
|
|
|
'time-picker':timePicker
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
props: {
|
2020-05-29 21:06:55 +08:00
|
|
|
|
chartData: {
|
|
|
|
|
|
type: Object
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// 看板id
|
|
|
|
|
|
panelId: {
|
|
|
|
|
|
type: Number,
|
|
|
|
|
|
default: 0,
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2020-02-19 21:33:54 +08:00
|
|
|
|
chartIndex:{
|
|
|
|
|
|
type: Number,
|
|
|
|
|
|
default: 0,
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// 展示设置内容
|
|
|
|
|
|
showSetting: {
|
|
|
|
|
|
type: Boolean,
|
|
|
|
|
|
default: true,
|
2020-01-10 17:13:41 +08:00
|
|
|
|
},
|
2020-04-14 21:46:38 +08:00
|
|
|
|
isExplore:{
|
|
|
|
|
|
type:Boolean,
|
|
|
|
|
|
default:false,
|
2020-09-25 11:48:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
tempDom: Object
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
data: {}, // 该图表信息,chartItem
|
2020-06-03 18:58:07 +08:00
|
|
|
|
noData:false,
|
2020-11-21 18:39:44 +08:00
|
|
|
|
/*seriesItem: [], // 保存信息
|
2020-06-23 18:48:40 +08:00
|
|
|
|
seriesItemArr:[],// 初次加载的数据
|
|
|
|
|
|
seriesLength:20,
|
2020-02-19 21:33:54 +08:00
|
|
|
|
seriesItemScreen:[],
|
2020-11-21 18:39:44 +08:00
|
|
|
|
seriesItemArrScreen:[],*/
|
|
|
|
|
|
/*legendListMore:[],
|
2020-06-23 18:48:40 +08:00
|
|
|
|
screenLegendListMore:[],
|
2020-11-21 18:39:44 +08:00
|
|
|
|
chartInfo:{},*/
|
2020-02-14 17:57:15 +08:00
|
|
|
|
images: '',
|
2020-04-29 16:35:58 +08:00
|
|
|
|
isStackArea:false,
|
2020-04-21 20:59:58 +08:00
|
|
|
|
isError:false,
|
2020-04-22 18:45:22 +08:00
|
|
|
|
errorContent:'',
|
2020-02-14 17:57:15 +08:00
|
|
|
|
toolbox: false,
|
|
|
|
|
|
items: {
|
|
|
|
|
|
metric_name: [], // 每条数据列名称
|
|
|
|
|
|
xAxis: [],
|
|
|
|
|
|
theData: [], // series数据组
|
|
|
|
|
|
},
|
|
|
|
|
|
panelIdInner: '', // 看板id=panelId,原写作chart,由set_data获取
|
|
|
|
|
|
chartName: '',
|
|
|
|
|
|
firstLoad: false, // 是否第一次加载
|
2020-02-19 21:33:54 +08:00
|
|
|
|
divFirstShow:false,
|
2020-11-21 18:39:44 +08:00
|
|
|
|
/*highchartStore: null, // 保存图表数据
|
2020-02-14 17:57:15 +08:00
|
|
|
|
echartStore:null,// 保存图表数据
|
2020-11-21 18:39:44 +08:00
|
|
|
|
echartModalStore: null, // 全屏查看时数据*/
|
2020-02-14 17:57:15 +08:00
|
|
|
|
chartType: 'line', // 图表类型
|
|
|
|
|
|
screenModal: false,
|
|
|
|
|
|
// 查询数据使用
|
|
|
|
|
|
filter: {
|
|
|
|
|
|
start_time: '',
|
|
|
|
|
|
end_time: '',
|
2020-06-07 21:39:07 +08:00
|
|
|
|
from: ""
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
stableFilter: {}, // 保存数据使用,初始化起止时间,单图or多图等
|
2020-11-21 18:39:44 +08:00
|
|
|
|
/*legend:[],
|
2020-02-14 17:57:15 +08:00
|
|
|
|
legendList:[],
|
2020-11-21 18:39:44 +08:00
|
|
|
|
screenLegendList:[],*/
|
2020-02-14 17:57:15 +08:00
|
|
|
|
isGrey:[],
|
|
|
|
|
|
isGreyScreen:[],
|
2020-11-21 18:39:44 +08:00
|
|
|
|
/*bgColorList: ['#7bbfea', '#b3424a', '#f05b72', '#596032', '#bd6758',
|
2020-02-14 17:57:15 +08:00
|
|
|
|
'#cd9a5b', '#918597', '#70a19f', '#005344', '#FF00FF',
|
|
|
|
|
|
'#f7acbc', '#5f5d46', '#66ffff', '#ccFF66', '#f47920',
|
|
|
|
|
|
'#769149', '#1d953f', '#abc88b', '#7f7522', '#9b95c9',
|
|
|
|
|
|
'#f3715c', '#ea66a6', '#d1c7b7', '#9d9087', '#77787b',
|
|
|
|
|
|
'#f58220', '#c37e00', '#00ae9d', '#f26522', '#76becc',
|
2020-04-17 22:43:28 +08:00
|
|
|
|
'#76624c', '#d71345', '#2468a2', '#ca8687', '#1b315e',
|
2020-11-21 18:39:44 +08:00
|
|
|
|
],*/
|
2020-06-09 10:54:06 +08:00
|
|
|
|
stackTotalColor:null,
|
2020-02-14 17:57:15 +08:00
|
|
|
|
firstShow: false, // 默认不显示操作按钮,
|
2020-03-17 19:30:27 +08:00
|
|
|
|
caretShow:false,
|
|
|
|
|
|
dropdownMenuShow:false,
|
2020-02-19 21:33:54 +08:00
|
|
|
|
showLegend:true,
|
2020-02-14 17:57:15 +08:00
|
|
|
|
searchTime:[new Date().setHours(new Date().getHours()-1),new Date()],
|
|
|
|
|
|
oldSearchTime:[],
|
2020-09-18 10:53:09 +08:00
|
|
|
|
screenTitleHeight:58,
|
|
|
|
|
|
hasLegendOptions:false,
|
2020-11-21 18:39:44 +08:00
|
|
|
|
/*legendOptions:[],
|
|
|
|
|
|
screenLegendOptions:[],*/
|
2020-02-14 17:57:15 +08:00
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {},
|
|
|
|
|
|
methods: {
|
2020-05-29 21:06:55 +08:00
|
|
|
|
startResize(e) {
|
|
|
|
|
|
let vm = this;
|
2020-09-25 14:15:13 +08:00
|
|
|
|
this.$chartResizeTool.start(vm, this.chartData, e,this.chartIndex);
|
2020-05-29 21:06:55 +08:00
|
|
|
|
},
|
2020-02-21 17:32:59 +08:00
|
|
|
|
setDivFirstShow(showDiv){
|
|
|
|
|
|
this.divFirstShow = showDiv;
|
|
|
|
|
|
},
|
2020-04-17 08:15:13 +08:00
|
|
|
|
mouseEnterChart(){
|
|
|
|
|
|
this.caretShow=true;
|
2020-09-25 11:48:54 +08:00
|
|
|
|
if (getChart(this.chartIndex)) {
|
|
|
|
|
|
getChart(this.chartIndex).setOption({
|
2020-04-17 08:15:13 +08:00
|
|
|
|
toolbox: {
|
|
|
|
|
|
show:true,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mouseLeaveChart(){
|
|
|
|
|
|
this.caretShow=false;
|
2020-09-25 11:48:54 +08:00
|
|
|
|
if (getChart(this.chartIndex)) {
|
|
|
|
|
|
getChart(this.chartIndex).setOption({
|
2020-04-17 08:15:13 +08:00
|
|
|
|
toolbox: {
|
|
|
|
|
|
show:false,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mouseEnterFullChart(){
|
|
|
|
|
|
if (this.echartModalStore) {
|
|
|
|
|
|
this.echartModalStore.setOption({
|
|
|
|
|
|
toolbox: {
|
|
|
|
|
|
show:true,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mouseLeaveFullChart(){
|
|
|
|
|
|
if (this.echartModalStore) {
|
|
|
|
|
|
this.echartModalStore.setOption({
|
|
|
|
|
|
toolbox: {
|
|
|
|
|
|
show:false,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
clickLegend(legendName,index){
|
2020-03-04 20:30:25 +08:00
|
|
|
|
//点击图表某一个legend,图表只显示当前点击的曲线或柱状图,其它隐藏,再次点击已选中的legend ,显示全部
|
|
|
|
|
|
let curIsGrey=this.isGrey[index];
|
2020-09-25 11:48:54 +08:00
|
|
|
|
if(getChart(this.chartIndex)){
|
2020-09-18 10:53:09 +08:00
|
|
|
|
this.legendListMore.forEach((item,i)=>{
|
2020-03-04 20:30:25 +08:00
|
|
|
|
let isGrey = this.isGrey[i];
|
|
|
|
|
|
if(index != i){
|
|
|
|
|
|
if(!curIsGrey && !isGrey){
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(this.chartIndex).dispatchAction({
|
2020-03-04 20:30:25 +08:00
|
|
|
|
type: 'legendUnSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
}else if(!curIsGrey && isGrey){
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(this.chartIndex).dispatchAction({
|
2020-03-04 20:30:25 +08:00
|
|
|
|
type: 'legendSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
}else{
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(this.chartIndex).dispatchAction({
|
2020-03-04 20:30:25 +08:00
|
|
|
|
type: 'legendUnSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}else {
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(this.chartIndex).dispatchAction({
|
2020-03-04 20:30:25 +08:00
|
|
|
|
type: 'legendSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-04-17 10:14:36 +08:00
|
|
|
|
});
|
2020-03-04 20:30:25 +08:00
|
|
|
|
this.isGrey.forEach((item,i)=>{
|
|
|
|
|
|
if(index != i){
|
|
|
|
|
|
if(!curIsGrey && !item){
|
|
|
|
|
|
this.$set(this.isGrey, i, true);
|
|
|
|
|
|
}else if(!curIsGrey && item){
|
|
|
|
|
|
this.$set(this.isGrey, i, false);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.$set(this.isGrey, i, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(item === true){
|
|
|
|
|
|
this.$set(this.isGrey, i, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2020-02-11 17:46:09 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
clickScreenLegend(legendName,index){
|
2020-03-04 20:30:25 +08:00
|
|
|
|
//点击图表某一个legend,图表只显示当前点击的曲线或柱状图,其它隐藏,再次点击已选中的legend ,显示全部
|
|
|
|
|
|
let curIsGrey=this.isGreyScreen[index];
|
|
|
|
|
|
if(this.echartModalStore){
|
2020-09-18 10:53:09 +08:00
|
|
|
|
this.screenLegendListMore.forEach((item,i)=>{
|
2020-03-04 20:30:25 +08:00
|
|
|
|
let isGrey = this.isGreyScreen[i];
|
|
|
|
|
|
if(index != i){
|
|
|
|
|
|
if(!curIsGrey && !isGrey){
|
|
|
|
|
|
this.echartModalStore.dispatchAction({
|
|
|
|
|
|
type: 'legendUnSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
}else if(!curIsGrey && isGrey){
|
|
|
|
|
|
this.echartModalStore.dispatchAction({
|
|
|
|
|
|
type: 'legendSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.echartModalStore.dispatchAction({
|
|
|
|
|
|
type: 'legendUnSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
|
|
|
this.echartModalStore.dispatchAction({
|
|
|
|
|
|
type: 'legendSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-04-17 10:14:36 +08:00
|
|
|
|
});
|
2020-03-04 20:30:25 +08:00
|
|
|
|
this.isGreyScreen.forEach((item,i)=>{
|
|
|
|
|
|
if(index != i){
|
|
|
|
|
|
if(!curIsGrey && !item){
|
|
|
|
|
|
this.$set(this.isGreyScreen, i, true);
|
|
|
|
|
|
}else if(!curIsGrey && item){
|
|
|
|
|
|
this.$set(this.isGreyScreen, i, false);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.$set(this.isGreyScreen, i, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(item === true){
|
|
|
|
|
|
this.$set(this.isGreyScreen, i, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2020-02-11 17:46:09 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
clearData(){
|
2020-09-25 11:48:54 +08:00
|
|
|
|
if(getChart(this.chartIndex)){
|
|
|
|
|
|
getChart(this.chartIndex).clear();
|
2020-09-27 09:13:34 +08:00
|
|
|
|
// getChart(this.chartIndex).dispose();//关闭销毁实例 不再占用内存
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
formatLegend(chartWidth,name){
|
|
|
|
|
|
if(!name){
|
|
|
|
|
|
return '';
|
|
|
|
|
|
}
|
|
|
|
|
|
//计算宽度
|
2020-09-25 11:48:54 +08:00
|
|
|
|
let span = document.querySelector(".temp-dom");
|
|
|
|
|
|
span.textContent = name;
|
|
|
|
|
|
let txtWidth = parseFloat(window.getComputedStyle(span).width) - this.tempDom.width;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if(txtWidth < chartWidth){
|
|
|
|
|
|
return name;
|
|
|
|
|
|
}else {
|
2020-09-25 11:48:54 +08:00
|
|
|
|
let charNum = `${(chartWidth-100)/(txtWidth/name.length)}`;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
return name.slice(0,charNum)+'...';
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// chartSite用于区分是全屏显示还是局部显示
|
|
|
|
|
|
initChart(chartInfo, dataArg, ele, chartSite,legend) {
|
2020-06-23 18:48:40 +08:00
|
|
|
|
this.chartInfo=chartInfo;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
const self = this;
|
|
|
|
|
|
this.chartType = ''; // 图表类型
|
|
|
|
|
|
if ( chartInfo.type === 4) {//line,bar
|
|
|
|
|
|
this.chartType = 'line';
|
2020-01-21 11:29:38 +08:00
|
|
|
|
}
|
2020-04-21 20:59:58 +08:00
|
|
|
|
let minTime = null;
|
2020-09-22 09:41:17 +08:00
|
|
|
|
let maxTime = null;
|
2020-04-21 20:59:58 +08:00
|
|
|
|
if(dataArg.length>0 && dataArg[0].data
|
|
|
|
|
|
&& dataArg[0].data.length>0 && dataArg[0].data[0].length>0){
|
|
|
|
|
|
let len = dataArg[0].data.length-1;
|
|
|
|
|
|
minTime = dataArg[0].data[0][0];
|
|
|
|
|
|
maxTime = dataArg[0].data[len][0];
|
|
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if (chartSite === 'local') {
|
2020-09-25 11:48:54 +08:00
|
|
|
|
setChart(this.chartIndex, echarts.init(ele));
|
|
|
|
|
|
//getChart(this.chartIndex) = echarts.init(ele);
|
2020-03-28 09:57:51 +08:00
|
|
|
|
//chartId='lineChartArea';
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}else if (chartSite === 'screen') {
|
|
|
|
|
|
this.echartModalStore = echarts.init(ele);
|
2020-03-28 09:57:51 +08:00
|
|
|
|
//chartId='screenShowArea';
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
var chartWidth = ele.clientWidth;
|
|
|
|
|
|
var title = {
|
2020-02-22 18:44:01 +08:00
|
|
|
|
show:false,
|
2020-02-14 17:57:15 +08:00
|
|
|
|
text: chartInfo.title || null,
|
|
|
|
|
|
textAlign: 'left',
|
|
|
|
|
|
useHTML: true,
|
|
|
|
|
|
textStyle: {
|
|
|
|
|
|
//display: 'inline-block',//无此属性
|
|
|
|
|
|
width: '60%',
|
|
|
|
|
|
fontStyle:'normal',
|
|
|
|
|
|
fontWeight:'bold',
|
|
|
|
|
|
color: "#333",
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2020-09-24 14:14:21 +08:00
|
|
|
|
|
2020-04-29 16:35:58 +08:00
|
|
|
|
let stackIconBorderColor = (chartInfo.type==='stackArea'?'#53a3cb':'#7e7e7e');
|
|
|
|
|
|
let stackIconChooseBorderColor = (chartInfo.type==='stackArea'?'#7e7e7e':'#53a3cb');
|
2020-09-22 17:06:13 +08:00
|
|
|
|
if(chartInfo.unit &&dataArg.length>0){
|
2020-09-22 09:41:17 +08:00
|
|
|
|
maxValue=dataArg[0].data[0][1];
|
|
|
|
|
|
minValue=dataArg[0].data[0][1];
|
|
|
|
|
|
for(let j = 0; j < dataArg.length ; j++){
|
2020-09-24 14:14:21 +08:00
|
|
|
|
dataArg[j].showAllSymbol=false;
|
2020-09-22 09:41:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-09-24 14:14:21 +08:00
|
|
|
|
let maxValueCopies = this.getMaxValue(dataArg,chartInfo);
|
|
|
|
|
|
let maxValue=maxValueCopies.maxValue;
|
|
|
|
|
|
let minValue=maxValueCopies.minValue;
|
|
|
|
|
|
let dot=maxValueCopies.dot;
|
|
|
|
|
|
let copies=maxValueCopies.copies;
|
|
|
|
|
|
let unit=maxValueCopies.unit;
|
|
|
|
|
|
let oldDot=maxValueCopies.oldDot;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
var option = {
|
2020-02-22 18:44:01 +08:00
|
|
|
|
title:{
|
|
|
|
|
|
show:false,
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
color: this.bgColorList,
|
2020-04-17 08:15:13 +08:00
|
|
|
|
toolbox:{
|
|
|
|
|
|
show:false,
|
|
|
|
|
|
top:'0',
|
2020-10-15 17:27:35 +08:00
|
|
|
|
right:'18',
|
2020-07-21 11:43:33 +08:00
|
|
|
|
showTitle:true,
|
2020-04-17 08:15:13 +08:00
|
|
|
|
feature:{
|
|
|
|
|
|
dataZoom:{
|
2020-07-21 11:43:33 +08:00
|
|
|
|
yAxisIndex:false,
|
|
|
|
|
|
title:{
|
|
|
|
|
|
zoom:self.$t('overall.toolBox.zoom'),
|
|
|
|
|
|
back:self.$t('overall.toolBox.back'),
|
|
|
|
|
|
}
|
2020-04-17 08:15:13 +08:00
|
|
|
|
},
|
|
|
|
|
|
magicType:{
|
2020-04-29 16:35:58 +08:00
|
|
|
|
type:['stack'],
|
2020-07-21 11:43:33 +08:00
|
|
|
|
title:{
|
|
|
|
|
|
stack:self.$t('overall.toolBox.stack')
|
|
|
|
|
|
},
|
2020-04-29 16:35:58 +08:00
|
|
|
|
iconStyle:{
|
|
|
|
|
|
borderColor:stackIconBorderColor,
|
|
|
|
|
|
},
|
|
|
|
|
|
emphasis:{
|
|
|
|
|
|
borderColor:stackIconChooseBorderColor,
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-04-17 08:15:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
|
confine:false,
|
2020-04-17 08:15:13 +08:00
|
|
|
|
backgroundColor:'rgba(221,228,237,1)',
|
|
|
|
|
|
textStyle:{
|
|
|
|
|
|
color:'#000'
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
extraCssText:'z-index:1000;',
|
2020-02-24 20:31:25 +08:00
|
|
|
|
/*enterable:true, 导致tooltip不消失,显示多个tooltip*/
|
2020-02-14 17:57:15 +08:00
|
|
|
|
position:function(point,params,dom,rect,size){
|
|
|
|
|
|
dom.style.transform = "translateZ(0)";
|
2020-09-27 09:13:34 +08:00
|
|
|
|
var windowWidth=window.innerWidth;//窗口宽度
|
|
|
|
|
|
var windowHeight=window.innerHeight;//窗口高度
|
2020-09-29 09:25:43 +08:00
|
|
|
|
var windowMouse=getMousePoint();
|
2020-02-14 17:57:15 +08:00
|
|
|
|
//提示框位置
|
|
|
|
|
|
var x=0;
|
|
|
|
|
|
var y=0;
|
|
|
|
|
|
//当前鼠标位置
|
|
|
|
|
|
var pointX = point[0];
|
|
|
|
|
|
var pointY = point[1];
|
|
|
|
|
|
//外层div大小
|
|
|
|
|
|
var viewWidth = size.viewSize[0];
|
|
|
|
|
|
var viewHeight = size.viewSize[1];
|
|
|
|
|
|
//提示框大小
|
|
|
|
|
|
var boxWidth = size.contentSize[0];
|
|
|
|
|
|
var boxHeight = size.contentSize[1];
|
|
|
|
|
|
if (chartSite === 'local') { // 本地显示
|
|
|
|
|
|
let chartDom = document.getElementById(chartInfo.title+"_"+chartInfo.id);
|
|
|
|
|
|
if(chartDom){
|
|
|
|
|
|
let parTop = document.getElementById(chartInfo.title+"_"+chartInfo.id).offsetTop;
|
|
|
|
|
|
let parleft = document.getElementById(chartInfo.title+"_"+chartInfo.id).offsetLeft;
|
|
|
|
|
|
|
|
|
|
|
|
let parent = document.getElementById('tableList');
|
|
|
|
|
|
let parClientHeight = parent.clientHeight;//可视高度
|
|
|
|
|
|
let parClientWidth = parent.clientWidth;//可视宽度
|
|
|
|
|
|
let parScrollTop = parent.scrollTop;
|
|
|
|
|
|
if((parClientWidth-pointX-parleft-20)>=boxWidth){//说明鼠标在左边放不下提示框
|
|
|
|
|
|
x=pointX+10;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
x = pointX - boxWidth;
|
|
|
|
|
|
}
|
2020-09-28 10:15:04 +08:00
|
|
|
|
if(windowMouse.y + 50 +boxHeight<windowHeight){//说明鼠标上面放不下提示框
|
2020-09-28 10:10:14 +08:00
|
|
|
|
y = pointY + 15;
|
2020-02-12 19:01:24 +08:00
|
|
|
|
}else {
|
2020-09-28 10:15:04 +08:00
|
|
|
|
y = pointY - boxHeight - 10;
|
2020-02-12 19:01:24 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
return [x,y];
|
|
|
|
|
|
}else {//preview page
|
2020-09-27 09:13:34 +08:00
|
|
|
|
|
|
|
|
|
|
if(windowMouse.x<(windowWidth/2)){//说明鼠标在左边放不下提示框
|
|
|
|
|
|
x=pointX + 15;
|
2020-09-24 14:14:21 +08:00
|
|
|
|
}else{
|
2020-09-27 09:13:34 +08:00
|
|
|
|
x = pointX - boxWidth - 15;
|
2020-09-24 14:14:21 +08:00
|
|
|
|
}
|
2020-09-28 10:15:04 +08:00
|
|
|
|
if(windowMouse.y + 50 +boxHeight<windowHeight){//说明鼠标上面放不下提示框
|
2020-09-27 09:13:34 +08:00
|
|
|
|
y = pointY + 15;
|
2020-09-24 14:14:21 +08:00
|
|
|
|
}else {
|
2020-09-28 10:15:04 +08:00
|
|
|
|
y = pointY - boxHeight - 10;
|
2020-09-24 14:14:21 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
return [x,y];
|
2020-02-12 19:01:24 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
if(pointX<(viewWidth/2)){//说明鼠标在左边放不下提示框
|
|
|
|
|
|
x=pointX+10;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
x = pointX - boxWidth;
|
|
|
|
|
|
}
|
2020-09-28 10:15:04 +08:00
|
|
|
|
if(windowMouse.y + 50 +boxHeight<windowHeight){//说明鼠标上面放不下提示框
|
2020-09-28 10:10:14 +08:00
|
|
|
|
y = pointY + 15;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}else {
|
2020-09-28 10:15:04 +08:00
|
|
|
|
y = pointY - boxHeight - 10;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
return [x,y];
|
2020-02-12 19:01:24 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
formatter:function(params){
|
2020-03-12 15:26:40 +08:00
|
|
|
|
let str = `<div>`;
|
2020-04-29 16:35:58 +08:00
|
|
|
|
let sum = 0;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
params.forEach((item, i) => {
|
2020-04-21 20:59:58 +08:00
|
|
|
|
let tip=legend[item.seriesIndex];
|
|
|
|
|
|
let color = self.bgColorList[item.seriesIndex];
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if(i===0){
|
2020-09-02 18:36:34 +08:00
|
|
|
|
let value=item.data[0];
|
2020-04-09 16:14:32 +08:00
|
|
|
|
let t_date = new Date(value);
|
2020-02-14 17:57:15 +08:00
|
|
|
|
str += [t_date.getFullYear(), t_date.getMonth() + 1, t_date.getDate()].join('-') + " "
|
|
|
|
|
|
+ [t_date.getHours(), t_date.getMinutes(),t_date.getSeconds()].join(':');
|
2020-03-12 15:26:40 +08:00
|
|
|
|
str +=`<br/>`;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
2020-09-29 14:05:18 +08:00
|
|
|
|
let val =item.data[1]?parseFloat(Number(item.data[1]).toFixed(2)):'';
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if(val===0){
|
2020-11-16 19:09:00 +08:00
|
|
|
|
val = Number(item.data[1]).toExponential(2);
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
2020-04-29 16:35:58 +08:00
|
|
|
|
sum +=val;
|
2020-03-12 15:26:40 +08:00
|
|
|
|
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
|
2020-04-17 21:50:26 +08:00
|
|
|
|
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
|
2020-03-12 15:26:40 +08:00
|
|
|
|
str += `<div style="padding-left: 10px;">`;
|
2020-09-22 09:41:17 +08:00
|
|
|
|
str += chartDataFormat.getUnit(chartInfo.unit?chartInfo.unit:2).compute(val,null,-1,oldDot);
|
2020-03-12 15:26:40 +08:00
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
str += `</div>`;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
});
|
2020-04-29 16:35:58 +08:00
|
|
|
|
if(self.data.type==='stackArea' || self.isStackArea){
|
2020-06-09 10:54:06 +08:00
|
|
|
|
if(!self.stackTotalColor||self.stackTotalColor==''){
|
|
|
|
|
|
self.stackTotalColor=randomcolor();
|
|
|
|
|
|
}
|
2020-04-29 16:35:58 +08:00
|
|
|
|
sum = parseFloat(Number(sum).toFixed(2));
|
|
|
|
|
|
str +=`<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
|
2020-06-09 10:54:06 +08:00
|
|
|
|
str +=`<div style="line-height: 18px; font-size: 12px;padding-left:0px;">`
|
|
|
|
|
|
str +=`<span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${self.stackTotalColor};}'></span>`;
|
2020-04-29 16:35:58 +08:00
|
|
|
|
str +=self.$t("dashboard.panel.chartTotal");
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
str +=`<div style="padding-left: 10px;">`;
|
|
|
|
|
|
str +=chartDataFormat.getUnit(chartInfo.unit?chartInfo.unit:2).compute(sum,null,2);
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-14 17:57:15 +08:00
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
return str;
|
|
|
|
|
|
},
|
2020-01-16 16:56:28 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
legend: {
|
|
|
|
|
|
show:false,
|
2020-01-16 16:56:28 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
grid: {
|
2020-04-17 08:15:13 +08:00
|
|
|
|
top: 30,
|
2020-02-24 20:31:25 +08:00
|
|
|
|
left: 0,
|
|
|
|
|
|
right: 30,
|
|
|
|
|
|
containLabel: true,
|
2020-04-17 08:15:13 +08:00
|
|
|
|
bottom:8,//156
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
xAxis: {
|
|
|
|
|
|
type: 'time',
|
2020-09-24 14:14:21 +08:00
|
|
|
|
animation:false,
|
|
|
|
|
|
showAllSymbol:false,
|
2020-02-14 17:57:15 +08:00
|
|
|
|
axisLabel: {
|
2020-04-30 11:25:22 +08:00
|
|
|
|
interval: '0',
|
|
|
|
|
|
showMaxLabel:false,
|
2020-02-14 17:57:15 +08:00
|
|
|
|
rotate: 0,
|
2020-06-04 11:58:20 +08:00
|
|
|
|
show:true,
|
|
|
|
|
|
fontSize: 10,
|
2020-02-14 17:57:15 +08:00
|
|
|
|
formatter: function (value) {
|
2020-09-02 18:36:34 +08:00
|
|
|
|
value = value;
|
2020-04-21 20:59:58 +08:00
|
|
|
|
let t_date = new Date(value);
|
|
|
|
|
|
let hour = t_date.getHours();
|
|
|
|
|
|
hour=hour>9?hour:"0"+hour; //加0补充为两位数字
|
|
|
|
|
|
let minute = t_date.getMinutes();
|
|
|
|
|
|
minute=minute>9?minute:"0"+minute; //如果分钟小于10,则在前面加0补充为两位数字
|
|
|
|
|
|
if(minTime!==null && maxTime!==null){
|
|
|
|
|
|
let diffSec = (maxTime-minTime)/1000;
|
|
|
|
|
|
let secOneDay = 24*60*60;//1天的秒数
|
|
|
|
|
|
let secOneMonth = secOneDay*30;//30天的秒数
|
|
|
|
|
|
if(diffSec<=secOneDay) {//同一天
|
|
|
|
|
|
return [hour,minute ].join(':');
|
|
|
|
|
|
}else if(diffSec<secOneMonth){//大于1天,小于30天
|
|
|
|
|
|
return [t_date.getMonth() + 1, t_date.getDate()].join('/') +" "+ [hour, minute].join(':');
|
|
|
|
|
|
}else {//大于等于30天
|
|
|
|
|
|
return [t_date.getMonth() + 1, t_date.getDate()].join('/');
|
|
|
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
|
|
|
return [t_date.getFullYear(), t_date.getMonth() + 1, t_date.getDate()].join('/') + "\n"
|
|
|
|
|
|
+ [hour, minute].join(':');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
axisPointer: {//y轴上显示指针对应的值
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
splitLine:{
|
2020-06-03 18:58:07 +08:00
|
|
|
|
show:true,
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
color: "#d9d9d9",
|
|
|
|
|
|
opacity: 0.8,
|
|
|
|
|
|
width: 1
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-06-03 19:20:46 +08:00
|
|
|
|
axisLine: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
},
|
2020-06-03 18:58:07 +08:00
|
|
|
|
axisTick: {
|
|
|
|
|
|
show: false
|
2020-04-17 21:50:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
//boundaryGap:['20%', '0'],
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
yAxis: {
|
|
|
|
|
|
type: 'value',
|
|
|
|
|
|
splitLine:{
|
2020-06-03 18:58:07 +08:00
|
|
|
|
show:true,
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
color: "#d9d9d9",
|
|
|
|
|
|
opacity: 0.8,
|
|
|
|
|
|
width: 1
|
|
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
2020-09-22 09:41:17 +08:00
|
|
|
|
// maxInterval:{},
|
2020-04-17 21:50:26 +08:00
|
|
|
|
//去掉y轴--start
|
|
|
|
|
|
axisLine:{
|
|
|
|
|
|
show:false
|
|
|
|
|
|
},
|
2020-09-22 17:06:13 +08:00
|
|
|
|
minInterval: chartDataFormat.Interval(maxValue,copies,unit.type,'min'),
|
2020-10-13 13:41:54 +08:00
|
|
|
|
maxInterval: chartDataFormat.Interval(maxValue,copies,unit.type,'max')*Math.ceil(dataArg.length/5),
|
2020-04-17 21:50:26 +08:00
|
|
|
|
axisTick: {
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
},
|
|
|
|
|
|
//去掉y轴--end
|
2020-02-14 17:57:15 +08:00
|
|
|
|
axisLabel: {
|
2020-06-04 11:58:20 +08:00
|
|
|
|
show:true,
|
|
|
|
|
|
fontSize: 10,
|
2020-11-16 19:09:00 +08:00
|
|
|
|
formatter: function(val,index){
|
|
|
|
|
|
let value = val;
|
|
|
|
|
|
if (val !== 0) {
|
|
|
|
|
|
value = parseFloat(Number(val).toFixed(2));
|
|
|
|
|
|
if(value === 0){
|
|
|
|
|
|
value = Number(val).toExponential(2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-03-10 22:40:45 +08:00
|
|
|
|
let chartUnit=chartInfo.unit;
|
2020-03-12 14:10:37 +08:00
|
|
|
|
chartUnit=chartUnit?chartUnit:2;
|
2020-03-10 22:40:45 +08:00
|
|
|
|
let unit=chartDataFormat.getUnit(chartUnit);
|
2020-09-22 14:18:42 +08:00
|
|
|
|
let flag=JSON.stringify(value).length>JSON.stringify(chartDataFormat.Interval(maxValue,copies,unit.type)).length;
|
2020-09-29 11:32:55 +08:00
|
|
|
|
if(chartDataFormat.Interval(maxValue,copies,unit.type,'min')<1&&dot<2){
|
|
|
|
|
|
dot=2;
|
2020-09-28 10:10:14 +08:00
|
|
|
|
}
|
2020-10-15 14:46:12 +08:00
|
|
|
|
if(flag || dot==0){
|
2020-09-22 14:18:42 +08:00
|
|
|
|
dot=1;
|
|
|
|
|
|
}
|
2020-09-22 09:41:17 +08:00
|
|
|
|
return unit.compute(value,index,-1,dot);
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
2020-01-14 21:20:30 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
//boundaryGap:[0,0.2]
|
2020-01-14 21:20:30 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
useUTC: false,//使用本地时间
|
|
|
|
|
|
series: dataArg
|
|
|
|
|
|
};
|
2020-10-16 16:44:41 +08:00
|
|
|
|
if(unit.type=='Time'){
|
|
|
|
|
|
delete option.yAxis.maxInterval;
|
|
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// params.series = dataArg;
|
|
|
|
|
|
if (chartSite === 'local') { // 本地显示
|
2020-02-21 17:32:59 +08:00
|
|
|
|
if(legend){
|
2020-02-14 17:57:15 +08:00
|
|
|
|
this.legendList = [];
|
2020-10-12 18:26:27 +08:00
|
|
|
|
this.isGrey=[];
|
2020-02-14 17:57:15 +08:00
|
|
|
|
legend.forEach((item, i) => {
|
|
|
|
|
|
const legend = {
|
2020-03-04 09:58:19 +08:00
|
|
|
|
name:item.name,
|
|
|
|
|
|
alias:item.alias,
|
2020-09-18 10:53:09 +08:00
|
|
|
|
color:item.color,
|
2020-03-04 09:58:19 +08:00
|
|
|
|
showText:this.formatLegend(chartWidth,item.name)
|
2020-02-14 17:57:15 +08:00
|
|
|
|
};
|
|
|
|
|
|
this.legendList.push(legend);
|
|
|
|
|
|
this.isGrey.push(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-06-23 18:48:40 +08:00
|
|
|
|
this.legendListMore=this.legendList.filter((item,index)=>index<this.seriesLength);
|
2020-09-18 10:53:09 +08:00
|
|
|
|
if(this.hasLegendOptions){
|
|
|
|
|
|
this.computeLegendData(this.legendListMore,dataArg,'local');
|
|
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
this.$nextTick(() => {
|
2020-05-12 09:27:38 +08:00
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
let divHeight = self.$refs.legendArea.offsetHeight;
|
|
|
|
|
|
if(!chartInfo.height){
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(self.chartIndex).resize({height:(400-divHeight-self.$chartResizeTool.titleHeight-self.$chartResizeTool.chartBlankHeight)});
|
2020-05-12 09:27:38 +08:00
|
|
|
|
}else {
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(self.chartIndex).resize({height:(chartInfo.height-divHeight-self.$chartResizeTool.titleHeight-self.$chartResizeTool.chartBlankHeight)});
|
2020-05-12 09:27:38 +08:00
|
|
|
|
}
|
2020-06-03 18:58:07 +08:00
|
|
|
|
if(dataArg&&dataArg.length>0){
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(self.chartIndex).clear();
|
|
|
|
|
|
getChart(self.chartIndex).setOption(option);//创建图表
|
2020-06-03 18:58:07 +08:00
|
|
|
|
self.noData=false;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
self.noData=true;
|
|
|
|
|
|
option=chartConfig.getOption('noData')
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(self.chartIndex).clear();
|
|
|
|
|
|
getChart(self.chartIndex).setOption(option);//创建图表
|
2020-06-03 18:58:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-12 09:27:38 +08:00
|
|
|
|
self.$refs['localLoading'+self.chartIndex].endLoading();
|
|
|
|
|
|
self.firstShow = true; // 展示操作按键
|
2020-05-31 13:44:47 +08:00
|
|
|
|
}, 100);
|
2020-04-29 16:35:58 +08:00
|
|
|
|
|
2020-11-20 13:57:46 +08:00
|
|
|
|
window.addEventListener('resize', this.chartResize);
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(this.chartIndex).on('magictypechanged', function (params) {
|
2020-04-29 16:35:58 +08:00
|
|
|
|
self.isStackArea = !self.isStackArea;
|
|
|
|
|
|
if(self.isStackArea){
|
|
|
|
|
|
this.setOption({
|
|
|
|
|
|
toolbox:{
|
|
|
|
|
|
feature:{
|
2020-07-21 11:43:33 +08:00
|
|
|
|
dataZoom:{
|
|
|
|
|
|
yAxisIndex:false,
|
|
|
|
|
|
title:{
|
|
|
|
|
|
zoom:self.$t('overall.toolBox.zoom'),
|
|
|
|
|
|
back:self.$t('overall.toolBox.back'),
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-04-29 16:35:58 +08:00
|
|
|
|
magicType:{
|
2020-07-21 11:43:33 +08:00
|
|
|
|
type:['stack'],
|
|
|
|
|
|
title:{
|
|
|
|
|
|
stack:self.$t('overall.toolBox.stack')
|
|
|
|
|
|
},
|
2020-04-29 16:35:58 +08:00
|
|
|
|
iconStyle:{
|
|
|
|
|
|
borderColor:'#7e7e7e',
|
|
|
|
|
|
},
|
2020-07-21 11:43:33 +08:00
|
|
|
|
emphasis:{
|
|
|
|
|
|
borderColor:stackIconChooseBorderColor,
|
|
|
|
|
|
}
|
2020-04-29 16:35:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
formatter:function(params){
|
|
|
|
|
|
let str = `<div>`;
|
|
|
|
|
|
let sum = 0;
|
|
|
|
|
|
params.forEach((item, i) => {let tip=legend[item.seriesIndex];
|
|
|
|
|
|
let color = self.bgColorList[item.seriesIndex];
|
|
|
|
|
|
if(i===0){
|
2020-09-02 18:36:34 +08:00
|
|
|
|
let value=item.data[0];
|
2020-04-29 16:35:58 +08:00
|
|
|
|
let t_date = new Date(value);
|
|
|
|
|
|
str += [t_date.getFullYear(), t_date.getMonth() + 1, t_date.getDate()].join('-') + " "
|
|
|
|
|
|
+ [t_date.getHours(), t_date.getMinutes(),t_date.getSeconds()].join(':');
|
|
|
|
|
|
str +=`<br/>`;
|
|
|
|
|
|
}
|
|
|
|
|
|
let val = parseFloat(Number(item.data[1]).toFixed(2));
|
|
|
|
|
|
if(val===0){
|
2020-11-16 19:09:00 +08:00
|
|
|
|
val = Number(item.data[1]).toExponential(2);
|
2020-04-29 16:35:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
sum +=val;
|
|
|
|
|
|
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
|
|
|
|
|
|
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
|
|
|
|
|
|
str += `<div style="padding-left: 10px;">`;
|
|
|
|
|
|
str += chartDataFormat.getUnit(chartInfo.unit?chartInfo.unit:2).compute(val,null,2);
|
|
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
});
|
|
|
|
|
|
if(self.data.type==='stackArea' || self.isStackArea){
|
|
|
|
|
|
sum = parseFloat(Number(sum).toFixed(2));
|
|
|
|
|
|
str +=`<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
|
|
|
|
|
|
str +=`<div style="line-height: 18px; font-size: 12px;padding-left:20px;">`
|
|
|
|
|
|
str +=self.$t("dashboard.panel.chartTotal");
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
str +=`<div style="padding-left: 10px;">`;
|
|
|
|
|
|
str +=chartDataFormat.getUnit(chartInfo.unit?chartInfo.unit:2).compute(sum,null,2);
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
return str;
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-02-14 17:57:15 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else if (chartSite === 'screen') { // 全屏显示
|
|
|
|
|
|
// eslint-disable-next-line
|
2020-02-21 17:32:59 +08:00
|
|
|
|
if(legend){
|
2020-02-14 17:57:15 +08:00
|
|
|
|
this.screenLegendList = [];
|
2020-10-12 18:26:27 +08:00
|
|
|
|
this.isGreyScreen=[]
|
2020-02-14 17:57:15 +08:00
|
|
|
|
legend.forEach((item, i) => {
|
|
|
|
|
|
const legend = {
|
2020-03-04 09:58:19 +08:00
|
|
|
|
name:item.name,
|
|
|
|
|
|
alias:item.alias,
|
2020-09-18 10:53:09 +08:00
|
|
|
|
color:item.color,
|
2020-04-17 08:15:13 +08:00
|
|
|
|
showText:this.formatLegend(chartWidth,item.name)
|
2020-02-14 17:57:15 +08:00
|
|
|
|
};
|
|
|
|
|
|
this.screenLegendList.push(legend);
|
|
|
|
|
|
this.isGreyScreen.push(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-06-23 18:48:40 +08:00
|
|
|
|
if(this.screenLegendListMore.length!==this.screenLegendList.length){
|
|
|
|
|
|
this.screenLegendListMore=this.screenLegendList.filter((item,index)=>index<this.seriesLength);
|
|
|
|
|
|
}
|
2020-09-18 10:53:09 +08:00
|
|
|
|
if(this.hasLegendOptions){
|
|
|
|
|
|
this.computeLegendData(this.screenLegendListMore,dataArg,'screen');
|
|
|
|
|
|
}
|
2020-05-12 09:27:38 +08:00
|
|
|
|
if(self.echartModalStore){
|
|
|
|
|
|
self.echartModalStore.clear();
|
|
|
|
|
|
option.title = {};
|
|
|
|
|
|
self.showLegend = true;
|
|
|
|
|
|
self.$refs['localLoadingScreen'+self.chartIndex].endLoading();
|
2020-04-17 08:15:13 +08:00
|
|
|
|
}
|
2020-05-12 09:27:38 +08:00
|
|
|
|
this.$nextTick(() => {
|
2020-06-23 18:48:40 +08:00
|
|
|
|
let legendDiv = document.getElementById('screenLegendArea'+self.chartIndex);
|
|
|
|
|
|
let divHeight = legendDiv.offsetHeight;
|
|
|
|
|
|
let screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
|
|
|
|
|
let sumHeight = Math.floor(screenHeight*0.99*0.8);//margin-top:1vh; dailog:80%
|
|
|
|
|
|
self.$refs.screenShowArea.style.height = `${sumHeight - divHeight - self.screenTitleHeight}px`;
|
|
|
|
|
|
self.echartModalStore.resize({height: (sumHeight - divHeight - self.screenTitleHeight)});//图表的高度
|
2020-05-12 09:27:38 +08:00
|
|
|
|
setTimeout(function () {
|
2020-06-23 18:48:40 +08:00
|
|
|
|
if(self.screenLegendListMore.length!==self.screenLegendList.length){
|
|
|
|
|
|
self.seriesItemArrScreen=self.seriesItemScreen.filter((item,index)=>index<self.seriesLength);
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
self.seriesItemArrScreen=self.seriesItemScreen
|
|
|
|
|
|
}
|
|
|
|
|
|
option.series=self.seriesItemArrScreen;
|
2020-06-03 18:58:07 +08:00
|
|
|
|
if(dataArg&&dataArg.length>0){
|
|
|
|
|
|
self.echartModalStore.setOption(option);//显示全屏界面
|
|
|
|
|
|
self.noData=false;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
self.noData=true;
|
|
|
|
|
|
option=chartConfig.getOption('noData')
|
|
|
|
|
|
self.echartModalStore.setOption(option);//显示全屏界面
|
|
|
|
|
|
}
|
2020-06-23 18:48:40 +08:00
|
|
|
|
self.echartModalStore.on('finished', function () {
|
|
|
|
|
|
let legendDiv = document.getElementById('screenLegendArea'+self.chartIndex);
|
|
|
|
|
|
let divHeight = legendDiv.offsetHeight;
|
|
|
|
|
|
let screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
|
|
|
|
|
let sumHeight = Math.floor(screenHeight*0.99*0.8);//margin-top:1vh; dailog:80%
|
|
|
|
|
|
self.$refs.screenShowArea.style.height = `${sumHeight - divHeight - self.screenTitleHeight}px`;
|
2020-06-24 10:31:19 +08:00
|
|
|
|
self.echartModalStore.resize({height: (sumHeight - divHeight - self.screenTitleHeight)});//图表的高度
|
2020-06-23 18:48:40 +08:00
|
|
|
|
self.echartModalStore.off('finished');
|
|
|
|
|
|
})
|
|
|
|
|
|
}, 100);
|
2020-05-12 09:27:38 +08:00
|
|
|
|
|
|
|
|
|
|
this.echartModalStore.on('magictypechanged', function (params) {
|
|
|
|
|
|
self.isStackArea = !self.isStackArea;
|
|
|
|
|
|
if(self.isStackArea){
|
|
|
|
|
|
this.setOption({
|
|
|
|
|
|
toolbox:{
|
|
|
|
|
|
feature:{
|
2020-07-21 11:43:33 +08:00
|
|
|
|
dataZoom:{
|
|
|
|
|
|
yAxisIndex:false,
|
|
|
|
|
|
title:{
|
|
|
|
|
|
zoom:self.$t('overall.toolBox.zoom'),
|
|
|
|
|
|
back:self.$t('overall.toolBox.back'),
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-05-12 09:27:38 +08:00
|
|
|
|
magicType:{
|
2020-07-21 11:43:33 +08:00
|
|
|
|
type:['stack'],
|
|
|
|
|
|
title:{
|
|
|
|
|
|
stack:self.$t('overall.toolBox.stack')
|
|
|
|
|
|
},
|
2020-05-12 09:27:38 +08:00
|
|
|
|
iconStyle:{
|
|
|
|
|
|
borderColor:'#7e7e7e',
|
|
|
|
|
|
},
|
2020-07-21 11:43:33 +08:00
|
|
|
|
emphasis:{
|
|
|
|
|
|
borderColor:stackIconChooseBorderColor,
|
|
|
|
|
|
}
|
2020-04-29 16:35:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
}
|
2020-07-21 11:43:33 +08:00
|
|
|
|
|
2020-04-29 16:35:58 +08:00
|
|
|
|
},
|
2020-05-12 09:27:38 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
|
formatter:function(params){
|
|
|
|
|
|
let str = `<div>`;
|
|
|
|
|
|
let sum = 0;
|
|
|
|
|
|
params.forEach((item, i) => {let tip=legend[item.seriesIndex];
|
|
|
|
|
|
let color = self.bgColorList[item.seriesIndex];
|
|
|
|
|
|
if(i===0){
|
2020-09-02 18:36:34 +08:00
|
|
|
|
let value=item.data[0];
|
2020-05-12 09:27:38 +08:00
|
|
|
|
let t_date = new Date(value);
|
|
|
|
|
|
str += [t_date.getFullYear(), t_date.getMonth() + 1, t_date.getDate()].join('-') + " "
|
|
|
|
|
|
+ [t_date.getHours(), t_date.getMinutes(),t_date.getSeconds()].join(':');
|
|
|
|
|
|
str +=`<br/>`;
|
|
|
|
|
|
}
|
|
|
|
|
|
let val = parseFloat(Number(item.data[1]).toFixed(2));
|
|
|
|
|
|
if(val===0){
|
2020-11-16 19:09:00 +08:00
|
|
|
|
val = Number(item.data[1]).toExponential(2);
|
2020-05-12 09:27:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
sum +=val;
|
|
|
|
|
|
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
|
|
|
|
|
|
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
|
|
|
|
|
|
str += `<div style="padding-left: 10px;">`;
|
|
|
|
|
|
str += chartDataFormat.getUnit(chartInfo.unit?chartInfo.unit:2).compute(val,null,2);
|
|
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
});
|
|
|
|
|
|
if(self.data.type==='stackArea' || self.isStackArea){
|
|
|
|
|
|
sum = parseFloat(Number(sum).toFixed(2));
|
|
|
|
|
|
str +=`<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
|
|
|
|
|
|
str +=`<div style="line-height: 18px; font-size: 12px;padding-left:20px;">`
|
|
|
|
|
|
str +=self.$t("dashboard.panel.chartTotal");
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
str +=`<div style="padding-left: 10px;">`;
|
|
|
|
|
|
str +=chartDataFormat.getUnit(chartInfo.unit?chartInfo.unit:2).compute(sum,null,2);
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
return str;
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-04-29 16:35:58 +08:00
|
|
|
|
});
|
2020-02-11 17:46:09 +08:00
|
|
|
|
}
|
2020-11-21 18:39:44 +08:00
|
|
|
|
maxValueCopies = null;
|
|
|
|
|
|
setTimeout(() => {option = null}, 1000);
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
handleLineFeed(str,chartWidth){
|
|
|
|
|
|
let rlt='';
|
|
|
|
|
|
if(!str){
|
|
|
|
|
|
return '';
|
|
|
|
|
|
}
|
|
|
|
|
|
//计算宽度
|
2020-09-25 20:17:29 +08:00
|
|
|
|
let span = document.querySelector(".temp-dom");
|
|
|
|
|
|
span.textContent = name;
|
|
|
|
|
|
let txtWidth = parseFloat(window.getComputedStyle(span).width) - this.tempDom.width;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if(txtWidth < chartWidth){
|
|
|
|
|
|
return str;
|
2020-01-16 16:56:28 +08:00
|
|
|
|
}else {
|
2020-02-14 17:57:15 +08:00
|
|
|
|
var charNum = `${(chartWidth-100)/(txtWidth/str.length)}`;
|
|
|
|
|
|
return str.slice(0,charNum)+'...';
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-04-17 21:50:26 +08:00
|
|
|
|
setColor(colorNum){
|
2020-11-10 18:09:51 +08:00
|
|
|
|
this.bgColorList = [
|
|
|
|
|
|
'#FF5200','#3685FF','#FF8D00','#00DCA2',
|
|
|
|
|
|
'#954Eff','#FFCB01','#f65A96','#00BFD0',
|
|
|
|
|
|
'#FF8BEA','#4D7693','#72577C','#99D750',
|
|
|
|
|
|
'#DD8270','#C475EE','#7E83FB','#7EB090',
|
|
|
|
|
|
'#FF9094','#00CCF5','#CF6684','#4E55FF'
|
|
|
|
|
|
];
|
|
|
|
|
|
for(let i=0;i<colorNum-19;i++) {
|
2020-04-21 20:59:58 +08:00
|
|
|
|
this.bgColorList.push(randomcolor())
|
2020-04-17 21:50:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// 设置数据, filter区分
|
2020-04-22 18:45:22 +08:00
|
|
|
|
setData(chartItem, seriesItem, panelId, filter,legend,area,errorMsg) {
|
2020-04-21 20:59:58 +08:00
|
|
|
|
this.setColor(legend.length);
|
2020-09-28 10:10:14 +08:00
|
|
|
|
legend.forEach((t,i)=>{t.color = this.bgColorList[i]});
|
2020-06-07 21:39:07 +08:00
|
|
|
|
this.filter.from = filter.from;
|
2020-04-22 18:45:22 +08:00
|
|
|
|
if(errorMsg && errorMsg!==''){
|
|
|
|
|
|
this.isError = true;
|
|
|
|
|
|
this.errorContent = errorMsg;
|
|
|
|
|
|
}else {
|
|
|
|
|
|
this.isError = false;
|
|
|
|
|
|
this.errorContent = '';
|
|
|
|
|
|
}
|
2020-02-19 21:33:54 +08:00
|
|
|
|
if(area==='showFullScreen'){//全屏按时间查询
|
|
|
|
|
|
/*
|
|
|
|
|
|
this.legend = legend;
|
|
|
|
|
|
this.data = chartItem;
|
|
|
|
|
|
this.searchTime[0] = filter.start_time;//将列表的查询时间复制给全屏的查询时间
|
|
|
|
|
|
this.searchTime[1] = filter.end_time;
|
|
|
|
|
|
this.seriesItemScreen = seriesItem;
|
|
|
|
|
|
//this.$refs['localLoadingScreen'+this.chartIndex].endLoading();
|
|
|
|
|
|
this.initChart(chartItem, seriesItem, this.$refs.lineChartArea, 'screen',legend);
|
|
|
|
|
|
*/
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.legend = legend;
|
|
|
|
|
|
this.$refs['localLoading'+this.chartIndex].startLoading();
|
|
|
|
|
|
this.divFirstShow = true;
|
|
|
|
|
|
this.firstShow = true; // 展示操作按键
|
|
|
|
|
|
this.panelIdInner = panelId;
|
|
|
|
|
|
this.data = chartItem;
|
|
|
|
|
|
this.seriesItem = seriesItem;
|
|
|
|
|
|
this.seriesItemScreen = seriesItem;
|
|
|
|
|
|
|
2020-09-18 10:53:09 +08:00
|
|
|
|
this.hasLegendOptions=this.findLegendOptions()
|
|
|
|
|
|
if(this.hasLegendOptions){
|
|
|
|
|
|
let sortedOptionKeys=['min','max','avg','last','total']
|
|
|
|
|
|
this.legendOptions=sortedOptionKeys.map(item=>{ return {option:item,sort:'',value:chartItem.param.legendValue[item]}})
|
|
|
|
|
|
this.screenLegendOptions=sortedOptionKeys.map(item=>{ return {option:item,sort:'',value:chartItem.param.legendValue[item]}})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-19 21:33:54 +08:00
|
|
|
|
if (filter) { // 保存数据,用于同步时间
|
|
|
|
|
|
this.stableFilter = filter;
|
|
|
|
|
|
this.searchTime[0] = filter.start_time;
|
|
|
|
|
|
this.searchTime[1] = filter.end_time;
|
|
|
|
|
|
this.oldSearchTime[0] = this.searchTime[0];
|
|
|
|
|
|
this.oldSearchTime[1] = this.searchTime[1];
|
|
|
|
|
|
}
|
2020-06-23 18:48:40 +08:00
|
|
|
|
this.seriesItem=seriesItem;
|
|
|
|
|
|
let seriesItemArr=seriesItem;
|
|
|
|
|
|
if(seriesItem.length>this.seriesLength){
|
|
|
|
|
|
seriesItemArr=seriesItem.filter((item,index)=>index<this.seriesLength); // 只查看前seriesLength条
|
|
|
|
|
|
this.seriesItemArr=seriesItemArr;
|
|
|
|
|
|
this.seriesItemArrScreen=seriesItemArr;
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.seriesItemArr=seriesItem
|
|
|
|
|
|
}
|
2020-09-18 10:53:09 +08:00
|
|
|
|
|
2020-06-23 18:48:40 +08:00
|
|
|
|
this.initChart(chartItem, seriesItemArr, this.$refs.lineChartArea, 'local',legend);
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
2020-02-19 21:33:54 +08:00
|
|
|
|
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
2020-05-31 13:44:47 +08:00
|
|
|
|
resize(chartItem) {
|
|
|
|
|
|
let chartBox = document.getElementById('lineChartDiv'+this.chartIndex);
|
|
|
|
|
|
chartBox.style.height = `${this.$chartResizeTool.calculateHeight(chartItem.height)}px`;
|
|
|
|
|
|
},
|
2020-03-11 18:48:05 +08:00
|
|
|
|
clearChart(){
|
2020-09-25 11:48:54 +08:00
|
|
|
|
if(getChart(this.chartIndex)){
|
|
|
|
|
|
getChart(this.chartIndex).clear();
|
2020-03-11 18:48:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(this.echartModalStore){
|
|
|
|
|
|
this.echartModalStore.clear();
|
|
|
|
|
|
}
|
2020-04-27 22:17:31 +08:00
|
|
|
|
this.data = {};
|
2020-03-11 18:48:05 +08:00
|
|
|
|
},
|
2020-03-17 19:30:27 +08:00
|
|
|
|
clickos() {
|
|
|
|
|
|
this.dropdownMenuShow=false;
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// 删除该图表
|
|
|
|
|
|
removeChart() {
|
2020-03-17 19:30:27 +08:00
|
|
|
|
this.dropdownMenuShow=false;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
this.$emit('on-remove-chart-block', this.data.id);
|
|
|
|
|
|
},
|
|
|
|
|
|
// 编辑图表
|
|
|
|
|
|
editChart() {
|
2020-03-17 19:30:27 +08:00
|
|
|
|
this.dropdownMenuShow=false;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
this.$emit('on-edit-chart-block', this.data.id);
|
|
|
|
|
|
},
|
|
|
|
|
|
// 重新请求数据 刷新操作
|
|
|
|
|
|
refreshChart() {
|
2020-03-17 19:30:27 +08:00
|
|
|
|
this.dropdownMenuShow=false;
|
2020-04-29 16:35:58 +08:00
|
|
|
|
let id = this.data.id;
|
2020-03-11 18:48:05 +08:00
|
|
|
|
this.clearChart();
|
2020-02-19 21:33:54 +08:00
|
|
|
|
this.$refs['localLoading'+this.chartIndex].startLoading();
|
2020-04-29 16:35:58 +08:00
|
|
|
|
this.firstShow = false;
|
|
|
|
|
|
this.$emit('on-refresh-data', id);
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
initDialog(){
|
|
|
|
|
|
//此时初始化,才能获得screenShowArea对象,否则此对象为undefined,无法初始化图表
|
|
|
|
|
|
this.initChart(this.data, this.seriesItem, this.$refs.screenShowArea, 'screen',this.legend);
|
|
|
|
|
|
// 日期组件同步时间
|
|
|
|
|
|
/*
|
|
|
|
|
|
this.$refs.calendar.initTime({
|
|
|
|
|
|
start: this.stableFilter.start_time,
|
|
|
|
|
|
end: this.stableFilter.end_time,
|
|
|
|
|
|
});
|
|
|
|
|
|
*/
|
|
|
|
|
|
},
|
|
|
|
|
|
changeDate(st){
|
|
|
|
|
|
this.oldSearchTime=st;
|
|
|
|
|
|
this.searchTime = st;
|
|
|
|
|
|
this.filter.start_time = st[0];
|
|
|
|
|
|
this.filter.end_time = st[1];
|
|
|
|
|
|
},
|
|
|
|
|
|
// 全屏查看
|
|
|
|
|
|
showAllScreen() {
|
2020-03-17 19:30:27 +08:00
|
|
|
|
this.dropdownMenuShow=false;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// 初始化同步时间
|
|
|
|
|
|
this.filter.start_time = this.stableFilter.start_time;
|
|
|
|
|
|
this.filter.end_time = this.stableFilter.end_time;
|
2020-04-24 17:00:56 +08:00
|
|
|
|
//this.searchTime = this.oldSearchTime;
|
|
|
|
|
|
this.$set(this.searchTime, 0, this.oldSearchTime[0]);
|
|
|
|
|
|
this.$set(this.searchTime, 1, this.oldSearchTime[1]);
|
|
|
|
|
|
this.$refs.calendarPanel.setCustomTime(this.searchTime);
|
2020-02-14 17:57:15 +08:00
|
|
|
|
this.screenModal = true;
|
|
|
|
|
|
this.isGreyScreen=[];
|
2020-02-19 21:33:54 +08:00
|
|
|
|
|
|
|
|
|
|
this.seriesItemScreen = this.seriesItem;
|
2020-06-23 18:48:40 +08:00
|
|
|
|
// this.seriesItemScreen = this.seriesItem;
|
2020-04-17 08:15:13 +08:00
|
|
|
|
/*
|
|
|
|
|
|
this.searchTime = [];
|
|
|
|
|
|
this.searchTime[0] = this.oldSearchTime[0];//将列表的查询时间复制给全屏的查询时间
|
|
|
|
|
|
this.searchTime[1] = this.oldSearchTime[1];
|
|
|
|
|
|
this.seriesItemScreen = this.seriesItem;
|
|
|
|
|
|
this.screenModal = true;
|
|
|
|
|
|
*/
|
2020-02-14 17:57:15 +08:00
|
|
|
|
//this.dateChange();
|
|
|
|
|
|
},
|
2020-05-18 14:28:14 +08:00
|
|
|
|
duplicate(){
|
|
|
|
|
|
this.dropdownMenuShow=false;
|
|
|
|
|
|
const param = {id:this.data.id};
|
|
|
|
|
|
this.$post('panel/'+ this.data.panelId+'/charts/duplicate',(param)).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
duration: 2000,
|
|
|
|
|
|
type: 'success',
|
|
|
|
|
|
message: this.$t("tip.duplicateSuccess")
|
|
|
|
|
|
});
|
|
|
|
|
|
this.$emit('on-duplicate-chart-block', this.data.id,response.data);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
if(response.msg){
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}else if(response.error){
|
|
|
|
|
|
this.$message.error(response.error);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
this.$message.error(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
dateChange(time) {
|
2020-04-24 17:00:56 +08:00
|
|
|
|
this.searchTime = [...time];
|
2020-02-14 17:57:15 +08:00
|
|
|
|
this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss');
|
|
|
|
|
|
this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss');
|
2020-02-19 21:33:54 +08:00
|
|
|
|
this.echartModalStore.clear();
|
|
|
|
|
|
this.showLegend = false;
|
|
|
|
|
|
this.$refs['localLoadingScreen'+this.chartIndex].startLoading();
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if (this.showSetting) {
|
|
|
|
|
|
this.getQueryChart('list');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.getQueryChart('dashboard');
|
2020-01-14 21:20:30 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 查询数据,修改日期查询全屏数据
|
|
|
|
|
|
getQueryChart(type) {
|
2020-02-19 21:33:54 +08:00
|
|
|
|
/*
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if (this.echartModalStore) {
|
|
|
|
|
|
this.echartModalStore.showLoading();
|
2020-01-10 17:13:41 +08:00
|
|
|
|
}
|
2020-02-19 21:33:54 +08:00
|
|
|
|
*/
|
2020-02-14 17:57:15 +08:00
|
|
|
|
let axiosArr = [];
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
let startTime = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss');
|
|
|
|
|
|
let endTime = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss');
|
|
|
|
|
|
if(!startTime || !endTime){//如果时间为空,则默认取最近1小时
|
|
|
|
|
|
let now = new Date();
|
|
|
|
|
|
startTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss');
|
|
|
|
|
|
endTime = bus.timeFormate(now.setHours(now.getHours()-1), 'yyyy-MM-dd hh:mm:ss');
|
|
|
|
|
|
this.searchTime[0] = startTime;
|
|
|
|
|
|
this.searchTime[1] = endTime;
|
|
|
|
|
|
}
|
|
|
|
|
|
let step = bus.getStep(startTime,endTime);
|
|
|
|
|
|
if (type === 'list') { // 普通模式,主控台使用
|
|
|
|
|
|
axiosArr = this.data.elements.map((ele) => {
|
|
|
|
|
|
const filterItem = ele;
|
2020-04-17 10:14:36 +08:00
|
|
|
|
let query = encodeURIComponent(filterItem.expression);
|
2020-09-29 09:45:49 +08:00
|
|
|
|
if(this.chartInfo.type==='line'||this.chartInfo.type==='bar'||this.chartInfo.type==='stackArea'){//如果是这三个 默认给connected
|
|
|
|
|
|
this.chartInfo.param.nullType=this.chartInfo.param.nullType||'connected';
|
|
|
|
|
|
query+='&nullType='+this.chartInfo.param.nullType;
|
|
|
|
|
|
}
|
2020-05-15 14:54:51 +08:00
|
|
|
|
return this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step);
|
2020-02-14 17:57:15 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else if (type === 'dashboard') { // 概览模式,指标概览中使用
|
|
|
|
|
|
// 概览模式,需要区分单独一个和多个
|
|
|
|
|
|
if (this.stableFilter.chartCount === 'multiple') {
|
2020-04-17 10:14:36 +08:00
|
|
|
|
let query = encodeURIComponent(this.data.title);
|
2020-09-29 09:45:49 +08:00
|
|
|
|
if(this.chartInfo.type==='line'||this.chartInfo.type==='bar'||this.chartInfo.type==='stackArea'){//如果是这三个 默认给connected
|
|
|
|
|
|
this.chartInfo.param.nullType=this.chartInfo.param.nullType||'connected';
|
|
|
|
|
|
query+='&nullType='+this.chartInfo.param.nullType;
|
|
|
|
|
|
}
|
2020-05-15 14:54:51 +08:00
|
|
|
|
axiosArr = [this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step)];
|
2020-02-14 17:57:15 +08:00
|
|
|
|
} else {
|
2020-04-17 10:14:36 +08:00
|
|
|
|
let query = encodeURIComponent(this.data.elements[0].expression);
|
2020-09-29 09:45:49 +08:00
|
|
|
|
if(this.chartInfo.type==='line'||this.chartInfo.type==='bar'||this.chartInfo.type==='stackArea'){//如果是这三个 默认给connected
|
|
|
|
|
|
this.chartInfo.param.nullType=this.chartInfo.param.nullType||'connected';
|
|
|
|
|
|
query+='&nullType='+this.chartInfo.param.nullType;
|
|
|
|
|
|
}
|
2020-05-15 14:54:51 +08:00
|
|
|
|
axiosArr = [this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step)];
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 一个图表
|
|
|
|
|
|
axios.all(axiosArr).then((res) => {
|
|
|
|
|
|
if (res.length > 0) {
|
|
|
|
|
|
const series = [];
|
|
|
|
|
|
const legend = [];
|
|
|
|
|
|
const sumData = {
|
|
|
|
|
|
name: 'sum',
|
|
|
|
|
|
data: [],
|
|
|
|
|
|
visible: true,
|
|
|
|
|
|
threshold: null,
|
|
|
|
|
|
};
|
2020-02-21 17:32:59 +08:00
|
|
|
|
if(!this.data.type){
|
|
|
|
|
|
this.data.type='line';
|
|
|
|
|
|
}
|
2020-03-12 14:10:37 +08:00
|
|
|
|
res.forEach((response,pos) => {
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if (response.status === 'success') {
|
2020-04-24 17:00:56 +08:00
|
|
|
|
this.isError = false;
|
|
|
|
|
|
this.errorContent = "";
|
2020-02-14 17:57:15 +08:00
|
|
|
|
if (response.data.result) {
|
|
|
|
|
|
// 循环处理每个elements下获取的数据列
|
|
|
|
|
|
response.data.result.forEach((queryItem,innerPos) => {
|
|
|
|
|
|
const seriesItem = {
|
|
|
|
|
|
theData: {
|
|
|
|
|
|
name: '',
|
2020-04-29 17:59:25 +08:00
|
|
|
|
symbol:'emptyCircle', //去掉点
|
|
|
|
|
|
symbolSize:[2,2],
|
2020-05-25 16:01:20 +08:00
|
|
|
|
smooth:0.2, //曲线变平滑
|
2020-04-29 17:59:25 +08:00
|
|
|
|
showSymbol:false,
|
2020-02-14 17:57:15 +08:00
|
|
|
|
data: [],
|
|
|
|
|
|
type:this.data.type,
|
2020-06-04 16:42:27 +08:00
|
|
|
|
lineStyle: {
|
|
|
|
|
|
width: 1,
|
|
|
|
|
|
opacity: 0.9
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
//visible: true,
|
|
|
|
|
|
//threshold: null,
|
|
|
|
|
|
},
|
|
|
|
|
|
metric_name: '',
|
|
|
|
|
|
};
|
2020-03-12 17:41:04 +08:00
|
|
|
|
if(this.data.type === 'stackArea'){
|
|
|
|
|
|
seriesItem.theData.type='line';
|
2020-04-17 10:14:36 +08:00
|
|
|
|
seriesItem.theData.stack=this.data.title;
|
2020-04-21 20:59:58 +08:00
|
|
|
|
seriesItem.theData.areaStyle={"opacity": 0.3};
|
2020-03-12 17:41:04 +08:00
|
|
|
|
}
|
2020-05-26 18:29:53 +08:00
|
|
|
|
|
|
|
|
|
|
if((this.data.type === 'line'||this.data.type === 'stackArea'||this.data.type === 'bar')&& this.data.param && this.data.param.threshold){
|
|
|
|
|
|
seriesItem.theData.markLine={
|
|
|
|
|
|
silent: true,
|
|
|
|
|
|
symbol:['circle','circle'],
|
|
|
|
|
|
label:{
|
|
|
|
|
|
distance:this.computeDistance(chartDataFormat.getUnit(this.data.unit?this.data.unit:2).compute(this.data.param.threshold)),
|
|
|
|
|
|
formatter:function(params){
|
|
|
|
|
|
return chartDataFormat.getUnit(this.data.unit?this.data.unit:2).compute(params.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
lineStyle:{
|
2020-06-05 17:45:31 +08:00
|
|
|
|
color:'#d64f40',
|
2020-05-26 18:29:53 +08:00
|
|
|
|
width:2,
|
|
|
|
|
|
type:'dotted'
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [{
|
|
|
|
|
|
yAxis: Number(this.data.param.threshold)
|
|
|
|
|
|
}, ]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// 图表中每条线的名字,后半部分
|
|
|
|
|
|
// let host = `${queryItem.metric.__name__}{`;//up,
|
|
|
|
|
|
let host = '';//up,
|
|
|
|
|
|
if(queryItem.metric.__name__){
|
|
|
|
|
|
host = `${queryItem.metric.__name__}{`;//up,
|
|
|
|
|
|
}
|
|
|
|
|
|
const tagsArr = Object.keys(queryItem.metric);//["__name__","asset","idc","instance","job","module","project"]
|
|
|
|
|
|
// 设置时间-数据格式对
|
|
|
|
|
|
const dpsArr = Object.entries(queryItem.values);//[ ["0",[1577959830.781,"0"]], ["1",[1577959845.781,"0"]] ]
|
2020-04-17 08:15:13 +08:00
|
|
|
|
// 判断是否有数据,&& tagsArr.length > 0
|
|
|
|
|
|
if (dpsArr.length > 0 ) {
|
2020-02-14 17:57:15 +08:00
|
|
|
|
tagsArr.forEach((tag, i) => {
|
|
|
|
|
|
if (tag !== '__name__') {
|
|
|
|
|
|
host += `${tag}="${queryItem.metric[tag]}",`;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if(host.endsWith(',')){host = host.substr(0,host.length-1);}
|
2020-04-17 08:15:13 +08:00
|
|
|
|
if(queryItem.metric.__name__){
|
|
|
|
|
|
host +="}";
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!host || host===''){
|
|
|
|
|
|
host = this.data.elements[pos].expression;
|
|
|
|
|
|
}
|
2020-03-12 14:10:37 +08:00
|
|
|
|
let alias=this.dealLegendAlias(host,this.data.elements[pos].legend);
|
2020-04-17 08:15:13 +08:00
|
|
|
|
if(!alias || alias===''){
|
2020-05-21 14:23:52 +08:00
|
|
|
|
alias = host;
|
2020-04-17 22:43:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
legend.push({name:host+innerPos,alias:alias});
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// 图表中每条线的名字,去掉最后的逗号与空格:metric名称, 标签1=a,标签2=c
|
2020-04-17 22:43:28 +08:00
|
|
|
|
seriesItem.theData.name = host+innerPos;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
seriesItem.metric_name = seriesItem.theData.name;
|
|
|
|
|
|
// 将秒改为毫秒
|
|
|
|
|
|
//alert('table=='+JSON.stringify(queryItem))
|
|
|
|
|
|
seriesItem.theData.data = queryItem.values.map((dpsItem, dpsIndex) => {
|
|
|
|
|
|
/*曲线汇总暂不需要
|
|
|
|
|
|
if (sumData.data[dpsIndex]) {
|
|
|
|
|
|
const sumNum = sumData.data[dpsIndex][1] || 0;
|
|
|
|
|
|
sumData.data[dpsIndex][1] = sumNum + dpsItem[1];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
sumData.data[dpsIndex] = [dpsItem[0] * 1000, dpsItem[1]];
|
|
|
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
return [dpsItem[0] * 1000, dpsItem[1]];
|
|
|
|
|
|
});
|
|
|
|
|
|
series.push(seriesItem.theData);
|
2020-01-10 17:13:41 +08:00
|
|
|
|
|
2020-02-14 17:57:15 +08:00
|
|
|
|
} else if (this.data.elements && this.data.elements[innerPos]) {
|
|
|
|
|
|
// 无数据提示
|
|
|
|
|
|
/*
|
|
|
|
|
|
const currentInfo = chartItem.elements[innerPos];
|
|
|
|
|
|
const errorMsg = `图表 ${chartItem.title} 中 ${currentInfo.metric},${currentInfo.tags} 无数据`;
|
|
|
|
|
|
this.$message.warning({
|
|
|
|
|
|
duration: 15,
|
|
|
|
|
|
content: errorMsg,
|
|
|
|
|
|
closable: true,
|
|
|
|
|
|
});
|
|
|
|
|
|
*/
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-04-24 17:00:56 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
this.isError = true;
|
|
|
|
|
|
if(response.msg){
|
|
|
|
|
|
this.errorContent = response.msg;
|
|
|
|
|
|
}else if(response.error){
|
|
|
|
|
|
this.errorContent = response.error;
|
|
|
|
|
|
}else {
|
|
|
|
|
|
this.errorContent = response;
|
|
|
|
|
|
}
|
2020-01-10 17:13:41 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
});
|
2020-05-12 09:27:38 +08:00
|
|
|
|
this.setColor(legend.length);
|
2020-06-23 18:48:40 +08:00
|
|
|
|
this.seriesItemScreen=series;
|
|
|
|
|
|
// this.seriesItemArrScreen=series.filter((item,index)=>index<this.seriesLength);
|
|
|
|
|
|
this.initChart(this.data,series, this.$refs.screenShowArea, 'screen',legend);
|
2020-01-10 17:13:41 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}).catch((error) => {
|
|
|
|
|
|
if (error) {
|
2020-02-21 17:32:59 +08:00
|
|
|
|
this.$message.error(error.toString());
|
2020-02-14 17:57:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-01-10 17:13:41 +08:00
|
|
|
|
});
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
2020-06-05 17:45:31 +08:00
|
|
|
|
computeDistance:function(str){
|
2020-09-25 20:17:29 +08:00
|
|
|
|
let span = document.querySelector(".temp-dom");
|
|
|
|
|
|
span.textContent = str;
|
|
|
|
|
|
let txtWidth = parseFloat(window.getComputedStyle(span).width);
|
|
|
|
|
|
return Number('-'+(txtWidth+5));
|
2020-05-26 18:29:53 +08:00
|
|
|
|
},
|
2020-02-19 21:33:54 +08:00
|
|
|
|
showLoad(chartItem) {
|
|
|
|
|
|
//设置高度
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
const chartBox = document.getElementById('lineChartDiv'+this.chartIndex);
|
2020-06-04 18:33:56 +08:00
|
|
|
|
let height = Math.floor(chartItem.height/this.$chartResizeTool.stepHeight)*this.$chartResizeTool.stepHeight;//图表高度四舍五入
|
2020-05-31 13:44:47 +08:00
|
|
|
|
if(height<this.$chartResizeTool.minHeight){
|
|
|
|
|
|
height = this.$chartResizeTool.minHeight;
|
2020-02-19 21:33:54 +08:00
|
|
|
|
}
|
2020-05-31 13:44:47 +08:00
|
|
|
|
chartBox.style.height = `${height-this.$chartResizeTool.chartBlankHeight}px`;
|
2020-02-19 21:33:54 +08:00
|
|
|
|
});
|
2020-02-21 17:32:59 +08:00
|
|
|
|
this.clearData();
|
|
|
|
|
|
this.firstShow = false;
|
2020-02-19 21:33:54 +08:00
|
|
|
|
this.$refs['localLoading'+this.chartIndex].startLoading();
|
|
|
|
|
|
this.divFirstShow = true;
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
2020-03-12 14:10:37 +08:00
|
|
|
|
dealLegendAlias:function(legend,expression){
|
|
|
|
|
|
if(/\{\{.+\}\}/.test(expression)){
|
|
|
|
|
|
let labelValue=expression.replace(/(\{\{.+?\}\})/g,function(i){
|
2020-04-17 10:14:36 +08:00
|
|
|
|
let label=i.substr(i.indexOf('{{')+2,i.indexOf('}}')-i.indexOf('{{')-2);
|
|
|
|
|
|
let reg=new RegExp(label+'=".+?"');
|
2020-03-12 14:10:37 +08:00
|
|
|
|
let value=null;
|
|
|
|
|
|
if(reg.test(legend)){
|
|
|
|
|
|
let find=legend.match(reg)[0];
|
|
|
|
|
|
value=find.substr(find.indexOf('"')+1,find.lastIndexOf('"')-find.indexOf('"')-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
return value?value:label;
|
2020-04-17 10:14:36 +08:00
|
|
|
|
});
|
2020-03-12 14:10:37 +08:00
|
|
|
|
return labelValue
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return expression;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
// 获取格式
|
|
|
|
|
|
getNumStr(num) {
|
|
|
|
|
|
if (num >= 1000) {
|
|
|
|
|
|
const kbNum = num / 1000;
|
|
|
|
|
|
if (kbNum >= 1000) {
|
|
|
|
|
|
const mbNum = kbNum / 1000;
|
|
|
|
|
|
if (mbNum > 1000) {
|
|
|
|
|
|
const gbNum = mbNum / 1000;
|
|
|
|
|
|
return `${gbNum.toFixed(2)}B`;
|
|
|
|
|
|
}
|
|
|
|
|
|
return `${mbNum.toFixed(2)}M`;
|
2020-01-14 21:20:30 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
return `${kbNum.toFixed(2)}K`;
|
2020-01-14 21:20:30 +08:00
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
return num.toFixed(2);
|
|
|
|
|
|
},
|
|
|
|
|
|
handleClose(){},
|
2020-06-23 18:48:40 +08:00
|
|
|
|
// 加载更多
|
|
|
|
|
|
loadMore(){
|
|
|
|
|
|
this.seriesItemArr=this.seriesItem;
|
|
|
|
|
|
this.legendListMore=this.legendList;
|
2020-09-24 14:14:21 +08:00
|
|
|
|
let chartInfo=this.data;
|
|
|
|
|
|
let dataArg=this.seriesItem;
|
|
|
|
|
|
let maxValueCopies = this.getMaxValue(dataArg,chartInfo);
|
|
|
|
|
|
let maxValue=maxValueCopies.maxValue;
|
|
|
|
|
|
let minValue=maxValueCopies.minValue;
|
|
|
|
|
|
let dot=maxValueCopies.dot;
|
|
|
|
|
|
let copies=maxValueCopies.copies;
|
|
|
|
|
|
let unit=maxValueCopies.unit;
|
|
|
|
|
|
let oldDot=maxValueCopies.oldDot;
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(this.chartIndex).setOption({
|
2020-09-24 14:14:21 +08:00
|
|
|
|
series:this.seriesItem,
|
|
|
|
|
|
yAxis:{
|
|
|
|
|
|
minInterval: chartDataFormat.Interval(maxValue,copies,unit.type,'min'),
|
2020-10-13 13:41:54 +08:00
|
|
|
|
maxInterval: chartDataFormat.Interval(maxValue,copies,unit.type,'max')*Math.ceil(dataArg.length/5),
|
2020-09-24 14:14:21 +08:00
|
|
|
|
}
|
2020-06-23 18:48:40 +08:00
|
|
|
|
});
|
2020-09-18 10:53:09 +08:00
|
|
|
|
if(this.hasLegendOptions){
|
|
|
|
|
|
this.computeLegendData(this.legendListMore,this.seriesItemArr,'local')
|
|
|
|
|
|
}
|
2020-06-23 18:48:40 +08:00
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
|
let divHeight = this.$refs.legendArea.offsetHeight;
|
|
|
|
|
|
if(!this.chartInfo.height){
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(this.chartIndex).resize({height:(400-divHeight-this.$chartResizeTool.titleHeight-this.$chartResizeTool.chartBlankHeight)});
|
2020-06-23 18:48:40 +08:00
|
|
|
|
}else {
|
2020-09-25 11:48:54 +08:00
|
|
|
|
getChart(this.chartIndex).resize({height:(this.chartInfo.height-divHeight-this.$chartResizeTool.titleHeight-this.$chartResizeTool.chartBlankHeight)});
|
2020-06-23 18:48:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 加载更多
|
|
|
|
|
|
loadScreenMore(){
|
|
|
|
|
|
this.seriesItemArrScreen=this.seriesItemScreen;
|
|
|
|
|
|
this.screenLegendListMore=this.screenLegendList;
|
2020-09-24 14:14:21 +08:00
|
|
|
|
let chartInfo=this.data;
|
|
|
|
|
|
let dataArg=this.seriesItem;
|
|
|
|
|
|
|
|
|
|
|
|
let maxValueCopies = this.getMaxValue(dataArg,chartInfo);
|
|
|
|
|
|
let maxValue=maxValueCopies.maxValue;
|
|
|
|
|
|
let minValue=maxValueCopies.minValue;
|
|
|
|
|
|
let dot=maxValueCopies.dot;
|
|
|
|
|
|
let copies=maxValueCopies.copies;
|
|
|
|
|
|
let unit=maxValueCopies.unit;
|
|
|
|
|
|
let oldDot=maxValueCopies.oldDot;
|
2020-06-23 18:48:40 +08:00
|
|
|
|
this.echartModalStore.setOption({
|
2020-09-24 14:14:21 +08:00
|
|
|
|
series:this.seriesItemScreen,
|
|
|
|
|
|
yAxis:{
|
|
|
|
|
|
minInterval: chartDataFormat.Interval(maxValue,copies,unit.type,'min'),
|
2020-10-13 13:41:54 +08:00
|
|
|
|
maxInterval: chartDataFormat.Interval(maxValue,copies,unit.type,'max')*Math.ceil(dataArg.length/5),
|
2020-09-24 14:14:21 +08:00
|
|
|
|
}
|
2020-06-23 18:48:40 +08:00
|
|
|
|
});
|
2020-09-18 10:53:09 +08:00
|
|
|
|
if(this.hasLegendOptions){
|
|
|
|
|
|
this.computeLegendData(this.screenLegendListMore,this.seriesItemArrScreen,'screen')
|
|
|
|
|
|
}
|
2020-06-23 18:48:40 +08:00
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
|
let legendDiv = document.getElementById('screenLegendArea'+this.chartIndex);
|
|
|
|
|
|
let divHeight = legendDiv.offsetHeight;
|
|
|
|
|
|
let screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
|
|
|
|
|
let sumHeight = Math.floor(screenHeight*0.99*0.8);//margin-top:1vh; dailog:80%
|
|
|
|
|
|
this.$refs.screenShowArea.style.height = `${sumHeight - divHeight - this.screenTitleHeight}px`;
|
|
|
|
|
|
this.echartModalStore.resize({height: (sumHeight - divHeight - this.screenTitleHeight)});//图表的高度
|
|
|
|
|
|
})
|
2020-09-18 10:53:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
findLegendOptions:function(){
|
2020-09-22 11:54:25 +08:00
|
|
|
|
if(!this.data.param||!this.data.param.legendValue || Object.keys(this.data.param.legendValue)<1) return false;
|
2020-09-18 10:53:09 +08:00
|
|
|
|
let legendOptions= this.data.param.legendValue;
|
|
|
|
|
|
let onVal=Object.keys(legendOptions).find(item=>{return legendOptions[item] == 'on'});
|
|
|
|
|
|
|
|
|
|
|
|
return onVal;
|
|
|
|
|
|
},
|
|
|
|
|
|
computeLegendData:function(legend,dataArr,where){
|
|
|
|
|
|
let options=where =='local'?this.legendOptions:this.screenLegendOptions;
|
|
|
|
|
|
let keys=options.filter(item=>{return item.value == 'on'}).map(item=>{return item.option});
|
|
|
|
|
|
let $self=this;
|
|
|
|
|
|
keys.forEach(item=>{
|
|
|
|
|
|
switch (item) {
|
|
|
|
|
|
case 'min':
|
|
|
|
|
|
$self.legendMinValue(legend,dataArr);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'max':
|
|
|
|
|
|
$self.legendMaxValue(legend,dataArr);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'avg':
|
|
|
|
|
|
$self.legendAvgValue(legend,dataArr);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'last':
|
|
|
|
|
|
$self.legendLastValue(legend,dataArr);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'total':
|
|
|
|
|
|
$self.legendTotalValue(legend,dataArr);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
legendMinValue:function(legend,dataArr){
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
legend.forEach(item=>{
|
|
|
|
|
|
let data=dataArr.find(t=>t.name == item.name)
|
|
|
|
|
|
if(data&&data.data){
|
|
|
|
|
|
let copy=JSON.parse(JSON.stringify(data.data));
|
|
|
|
|
|
let min =copy.sort((x,y)=>{return parseFloat(x[1]) - parseFloat(y[1])})[0][1]
|
|
|
|
|
|
item['min']=parseFloat(min)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
legendMaxValue:function(legend,dataArr){
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
legend.forEach(item=>{
|
|
|
|
|
|
let data=dataArr.find(t=>t.name == item.name)
|
|
|
|
|
|
if(data&&data.data){
|
|
|
|
|
|
let copy=JSON.parse(JSON.stringify(data.data));
|
|
|
|
|
|
let max =copy.sort((x,y)=>{return parseFloat(y[1]) - parseFloat(x[1])})[0][1]
|
|
|
|
|
|
item['max']=parseFloat(max)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
legendAvgValue:function(legend,dataArr){
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
legend.forEach(item=>{
|
|
|
|
|
|
let data=dataArr.find(t=>t.name == item.name)
|
|
|
|
|
|
if(data&&data.data){
|
|
|
|
|
|
let copy=JSON.parse(JSON.stringify(data.data));
|
|
|
|
|
|
copy = copy.map(t=>parseFloat(t[1]))
|
|
|
|
|
|
let sum = eval(copy.join('+'));
|
|
|
|
|
|
let avg = sum / copy.length;
|
|
|
|
|
|
|
|
|
|
|
|
item['avg'] = avg;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
legendLastValue:function(legend,dataArr){
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
legend.forEach(item=>{
|
|
|
|
|
|
let data=dataArr.find(t=>t.name == item.name)
|
|
|
|
|
|
if(data&&data.data){
|
|
|
|
|
|
let copy=JSON.parse(JSON.stringify(data.data));
|
|
|
|
|
|
let last =copy.sort((x,y)=>{return parseFloat(y[0]) - parseFloat(x[0])})[0][1]
|
|
|
|
|
|
item['last']=parseFloat(last)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
legendTotalValue:function(legend,dataArr){
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
legend.forEach(item=>{
|
|
|
|
|
|
let data=dataArr.find(t=>t.name == item.name)
|
|
|
|
|
|
if(data&&data.data){
|
|
|
|
|
|
let copy=JSON.parse(JSON.stringify(data.data));
|
|
|
|
|
|
copy = copy.map(t=>parseFloat(t[1]))
|
|
|
|
|
|
let sum = eval(copy.join('+'));
|
|
|
|
|
|
|
|
|
|
|
|
item['total'] = sum;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
formatLegendData:function(data){
|
|
|
|
|
|
return chartDataFormat.getUnit(this.chartInfo.unit).compute(data,null,2)
|
|
|
|
|
|
},
|
|
|
|
|
|
legendValueSort:function(option,legend,options){
|
|
|
|
|
|
options.forEach(item=>{
|
|
|
|
|
|
if(item.option != option.option){
|
|
|
|
|
|
item.sort='';
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if(!option.sort || option.sort == 'asc'){
|
|
|
|
|
|
legend.sort((x,y)=>x[option.option] - y[option.option])
|
|
|
|
|
|
option.sort = 'desc'
|
|
|
|
|
|
}else{
|
|
|
|
|
|
legend.sort((x,y)=>y[option.option] - x[option.option])
|
|
|
|
|
|
option.sort = 'asc'
|
|
|
|
|
|
}
|
2020-09-24 14:14:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
getMaxValue(dataArg,chartInfo){
|
|
|
|
|
|
let maxValue=0;
|
|
|
|
|
|
let minValue=0;
|
|
|
|
|
|
if(chartInfo.unit &&dataArg.length>0){
|
2020-10-13 10:57:12 +08:00
|
|
|
|
maxValue=0;
|
|
|
|
|
|
minValue=0;
|
2020-09-24 14:14:21 +08:00
|
|
|
|
for(let j = 0; j < dataArg.length ; j++){
|
|
|
|
|
|
for (let i = 0; i < dataArg[j].data.length - 1; i++) {
|
2020-10-13 10:57:12 +08:00
|
|
|
|
if(dataArg[j].data[i+1][1]!=='NaN'){
|
|
|
|
|
|
maxValue = (maxValue < Number(dataArg[j].data[i+1][1]) ? Number(dataArg[j].data[i+1][1]) : maxValue);
|
|
|
|
|
|
minValue = (minValue > Number(dataArg[j].data[i+1][1]) ? Number(dataArg[j].data[i+1][1]) : minValue);
|
|
|
|
|
|
}
|
2020-09-24 14:14:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
let chartUnit=chartInfo.unit?chartInfo.unit:2;
|
|
|
|
|
|
let unit=chartDataFormat.getUnit(chartUnit);
|
2020-10-13 10:57:12 +08:00
|
|
|
|
minValue=minValue>0?0:minValue;
|
|
|
|
|
|
maxValue=maxValue-minValue;
|
2020-09-24 14:14:21 +08:00
|
|
|
|
maxValue=chartDataFormat.formatDatas(maxValue,unit.type,'ceil',unit.ascii);
|
|
|
|
|
|
let oldValue=maxValue;
|
|
|
|
|
|
let dot=0;
|
|
|
|
|
|
if(maxValue==1){
|
|
|
|
|
|
dot++;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(oldValue>10){
|
|
|
|
|
|
while(oldValue>10){
|
|
|
|
|
|
oldValue=oldValue/10;
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(oldValue<1&&maxValue!==0){
|
|
|
|
|
|
while(oldValue<1&&oldValue>0){
|
|
|
|
|
|
oldValue=oldValue*10;
|
|
|
|
|
|
dot++;
|
|
|
|
|
|
}
|
2020-09-24 14:49:37 +08:00
|
|
|
|
maxValue=Math.floor(oldValue)/Math.pow(10,dot);
|
2020-09-24 14:14:21 +08:00
|
|
|
|
dot++;
|
|
|
|
|
|
}
|
|
|
|
|
|
let copies=chartDataFormat.copies(oldValue,unit.type);
|
|
|
|
|
|
let oldDot=2;
|
|
|
|
|
|
if(maxValue<=1){
|
|
|
|
|
|
oldDot=dot>6?6:dot;
|
|
|
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
|
|
|
maxValue,
|
|
|
|
|
|
dot,
|
|
|
|
|
|
copies,
|
|
|
|
|
|
minValue,
|
|
|
|
|
|
unit,
|
|
|
|
|
|
oldDot
|
|
|
|
|
|
}
|
2020-09-29 09:45:49 +08:00
|
|
|
|
},
|
2020-11-20 13:57:46 +08:00
|
|
|
|
chartResize() {
|
|
|
|
|
|
getChart(this.chartIndex).resize();
|
|
|
|
|
|
}
|
2020-02-14 17:57:15 +08:00
|
|
|
|
},
|
2020-11-21 18:39:44 +08:00
|
|
|
|
created() {
|
|
|
|
|
|
this.legendListMore = [];
|
|
|
|
|
|
this.screenLegendListMore = [];
|
|
|
|
|
|
this.chartInfo = {};
|
|
|
|
|
|
this.seriesItem = []; // 保存信息
|
|
|
|
|
|
this.seriesItemArr = [];// 初次加载的数据
|
|
|
|
|
|
this.seriesLength = 20;
|
|
|
|
|
|
this.seriesItemScreen = [];
|
|
|
|
|
|
this.seriesItemArrScreen = [];
|
|
|
|
|
|
this.legend = [];
|
|
|
|
|
|
this.legendList = [];
|
|
|
|
|
|
this.screenLegendList = [];
|
|
|
|
|
|
this.legendOptions = [];
|
|
|
|
|
|
this.screenLegendOptions = [];
|
|
|
|
|
|
|
|
|
|
|
|
this.highchartStore = null, // 保存图表数据
|
|
|
|
|
|
this.echartStore = null,// 保存图表数据
|
|
|
|
|
|
this.echartModalStore = null, // 全屏查看时数据
|
|
|
|
|
|
|
|
|
|
|
|
this.bgColorList = ['#7bbfea', '#b3424a', '#f05b72', '#596032', '#bd6758',
|
|
|
|
|
|
'#cd9a5b', '#918597', '#70a19f', '#005344', '#FF00FF',
|
|
|
|
|
|
'#f7acbc', '#5f5d46', '#66ffff', '#ccFF66', '#f47920',
|
|
|
|
|
|
'#769149', '#1d953f', '#abc88b', '#7f7522', '#9b95c9',
|
|
|
|
|
|
'#f3715c', '#ea66a6', '#d1c7b7', '#9d9087', '#77787b',
|
|
|
|
|
|
'#f58220', '#c37e00', '#00ae9d', '#f26522', '#76becc',
|
|
|
|
|
|
'#76624c', '#d71345', '#2468a2', '#ca8687', '#1b315e',
|
|
|
|
|
|
];
|
|
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
mounted() {
|
|
|
|
|
|
this.firstLoad = false;
|
2020-09-29 09:25:43 +08:00
|
|
|
|
if(!document.onmousemove){// 添加鼠标移动事件监听
|
|
|
|
|
|
document.onmousemove=lineChartMove
|
|
|
|
|
|
}
|
2020-01-03 17:17:09 +08:00
|
|
|
|
},
|
2020-03-10 22:40:45 +08:00
|
|
|
|
beforeDestroy() {
|
2020-03-11 18:48:05 +08:00
|
|
|
|
this.clearChart();
|
2020-09-30 17:50:35 +08:00
|
|
|
|
if(getChart(this.chartIndex)){
|
|
|
|
|
|
getChart(this.chartIndex).dispose();
|
|
|
|
|
|
}
|
2020-09-29 09:25:43 +08:00
|
|
|
|
if(!document.onmousemove){// 移除鼠标移动事件监听
|
|
|
|
|
|
document.onmousemove=null;
|
|
|
|
|
|
}
|
2020-11-20 13:57:46 +08:00
|
|
|
|
setChart(this.chartIndex, null);
|
|
|
|
|
|
window.removeEventListener('resize', this.chartResize);
|
2020-11-20 14:38:40 +08:00
|
|
|
|
this.$refs.legendArea._ps_.destroy();
|
2020-03-10 22:40:45 +08:00
|
|
|
|
},
|
2020-02-14 17:57:15 +08:00
|
|
|
|
};
|
2020-01-03 17:17:09 +08:00
|
|
|
|
|
|
|
|
|
|
</script>
|