2020-03-17 18:27:46 +08:00
|
|
|
|
<template>
|
2020-09-11 18:37:14 +08:00
|
|
|
|
<div class="chart-room" @mouseenter="mouseEnterChart" @mouseleave="mouseLeaveChart" ref="chartRoom" :style="{overflow: chartType == 'map' ? 'hidden' : ''}" :id="chartType == 'map' ? 'map' : ''">
|
2020-03-23 18:20:19 +08:00
|
|
|
|
<loading ref="loading"></loading>
|
2020-07-08 19:09:54 +08:00
|
|
|
|
<div class="showMore" v-if="legendAll.length !== legend.length"><i class="nz-icon nz-icon-jinggao"></i>{{$t("dashboard.panel.moreTitle")}} <span class="moreChart" @click="showMore">{{$t("dashboard.panel.showAll")+legendAll.length}}</span></div>
|
2020-03-23 18:20:19 +08:00
|
|
|
|
<div class="chart-header">{{chartTitle}}</div>
|
|
|
|
|
|
|
2020-04-21 19:28:01 +08:00
|
|
|
|
<div class="chart-body" ref="chartBody" :id="chartId" ></div>
|
2020-06-08 15:22:26 +08:00
|
|
|
|
<div class="chart-no-data" v-show="noData">No Data</div>
|
2020-03-17 18:27:46 +08:00
|
|
|
|
|
2020-05-18 14:12:56 +08:00
|
|
|
|
<div class="legend-container legend-container-screen" id="legendArea" ref="legendArea" v-show="legend.length>0" v-scrollBar:legend>
|
2020-04-21 19:28:01 +08:00
|
|
|
|
<div v-for="(item, index) in legend" :title="item.alias?item.alias:item.name" @click="clickLegend(item.name,index)" class="legend-item" :class="{'ft-gr':item.isGray}" :key="'legend_' + item.name+'_'+index">
|
|
|
|
|
|
<span class="legend-shape" :style="{background:(item.isGray?'#D3D3D3':getBgColor(index))}"></span>{{item.alias?item.alias:item.name}}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-03-17 18:27:46 +08:00
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import echarts from 'echarts';
|
|
|
|
|
|
import chartDataFormat from "../../../charts/chartDataFormat";
|
|
|
|
|
|
import loading from "../../../common/loading";
|
|
|
|
|
|
import chartConfig from './chartConfig'
|
2020-04-21 19:28:01 +08:00
|
|
|
|
import bus from "../../../../libs/bus";
|
|
|
|
|
|
import EleResize from "../../../common/js/divResize";
|
2020-04-24 14:20:46 +08:00
|
|
|
|
import {randomcolor} from "../../../common/js/radomcolor/randomcolor";
|
2020-09-04 19:19:17 +08:00
|
|
|
|
//import * as mapGeoJson from "../../../common/js/world";
|
|
|
|
|
|
|
2020-03-17 18:27:46 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "chart",
|
2020-03-23 18:20:19 +08:00
|
|
|
|
components:{
|
|
|
|
|
|
'loading':loading,
|
|
|
|
|
|
},
|
|
|
|
|
|
props:{
|
2020-04-24 15:49:54 +08:00
|
|
|
|
name: {type: String,default:'chart'},
|
2020-04-28 19:23:48 +08:00
|
|
|
|
unit:{type:Number,default:5},
|
2020-03-24 13:19:18 +08:00
|
|
|
|
chartTitle:{type:String},
|
2020-04-22 19:45:10 +08:00
|
|
|
|
showToolbox:{type:Boolean,default:true},
|
2020-03-24 13:19:18 +08:00
|
|
|
|
chartType:{type:String,default:'line'},
|
2020-04-21 19:28:01 +08:00
|
|
|
|
tooltipFormatter:Function,
|
|
|
|
|
|
yAxisFormatter:Function,
|
2020-04-24 21:43:51 +08:00
|
|
|
|
map:{},
|
|
|
|
|
|
axisTooltip: {type: String}, // x/y
|
2020-03-23 18:20:19 +08:00
|
|
|
|
},
|
2020-03-17 18:27:46 +08:00
|
|
|
|
data(){
|
|
|
|
|
|
return {
|
2020-03-23 18:20:19 +08:00
|
|
|
|
chart:null,
|
2020-04-24 14:20:46 +08:00
|
|
|
|
option:null,
|
2020-07-08 19:09:54 +08:00
|
|
|
|
optionSeriesAll:null,
|
2020-04-24 14:20:46 +08:00
|
|
|
|
chartId: this.name + '-'+this.guid()+'-'+new Date().getTime(),
|
2020-04-21 19:28:01 +08:00
|
|
|
|
legend:[],
|
2020-07-08 19:09:54 +08:00
|
|
|
|
legendAll:[],
|
2020-04-24 14:20:46 +08:00
|
|
|
|
colors:chartConfig.getBgColorList(),
|
2020-06-03 19:20:46 +08:00
|
|
|
|
noData:false,
|
2020-07-08 19:09:54 +08:00
|
|
|
|
dataSize:20,
|
2020-03-17 18:27:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
created() {
|
2020-04-22 19:45:10 +08:00
|
|
|
|
this.option=chartConfig.getOption(this.chartType);
|
|
|
|
|
|
if(this.showToolbox == false){
|
2020-08-28 19:19:04 +08:00
|
|
|
|
//this.option.grid.top = 10;
|
2020-04-22 19:45:10 +08:00
|
|
|
|
}
|
2020-03-17 18:27:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods:{
|
2020-03-31 20:08:33 +08:00
|
|
|
|
modifyOption:function(target,name,obj){
|
2020-04-24 15:49:54 +08:00
|
|
|
|
if(!this.option){
|
2020-03-31 20:08:33 +08:00
|
|
|
|
this.option=chartConfig.getOption(this.chartType);
|
2020-03-23 18:20:19 +08:00
|
|
|
|
}
|
2020-03-31 20:08:33 +08:00
|
|
|
|
this.$set(this.option[target],name,obj)
|
2020-03-23 18:20:19 +08:00
|
|
|
|
},
|
2020-04-21 19:28:01 +08:00
|
|
|
|
setLegend:function(legend){
|
2020-07-08 19:09:54 +08:00
|
|
|
|
this.legendAll=legend;
|
|
|
|
|
|
this.legend=legend.filter((item,index)=>index<this.dataSize);
|
2020-04-21 19:28:01 +08:00
|
|
|
|
this.resize();
|
|
|
|
|
|
},
|
2020-08-27 21:40:39 +08:00
|
|
|
|
setSeries:function(series, legend, legendData){
|
2020-03-23 18:20:19 +08:00
|
|
|
|
if(!this.chart){
|
2020-09-04 19:19:17 +08:00
|
|
|
|
this.chartInit();
|
2020-03-23 18:20:19 +08:00
|
|
|
|
}
|
2020-04-23 22:27:41 +08:00
|
|
|
|
this.series = series;
|
2020-03-24 13:19:18 +08:00
|
|
|
|
if(this.chartType == 'map'){
|
2020-03-30 21:09:34 +08:00
|
|
|
|
if(this.map){
|
2020-09-04 19:19:17 +08:00
|
|
|
|
echarts.registerMap(this.map.name, this.map.geoJson);
|
2020-03-30 21:09:34 +08:00
|
|
|
|
chartConfig.setMap(this.map.name);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
console.error('map chart need map data');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-24 13:19:18 +08:00
|
|
|
|
}
|
2020-04-24 15:49:54 +08:00
|
|
|
|
if(!this.option){
|
2020-08-27 21:40:39 +08:00
|
|
|
|
this.option = chartConfig.getOption(this.chartType);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (legend && legendData) {
|
|
|
|
|
|
legend.formatter = function(name) {
|
|
|
|
|
|
let type = legendData.find(item => {
|
|
|
|
|
|
return item[0] == name;
|
|
|
|
|
|
});
|
|
|
|
|
|
return `${name} (${type[1]}%)`;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$set(this.option, "legend", legend);
|
2020-03-31 20:08:33 +08:00
|
|
|
|
}
|
2020-04-21 19:28:01 +08:00
|
|
|
|
|
2020-07-10 19:00:29 +08:00
|
|
|
|
if(this.chartType == 'map'){
|
2020-09-07 19:50:37 +08:00
|
|
|
|
this.option.geo.regions = [];
|
|
|
|
|
|
|
2020-09-04 19:19:17 +08:00
|
|
|
|
let geoObj = this.map.geoJson.geoJson;
|
2020-09-07 19:50:37 +08:00
|
|
|
|
geoObj.features.forEach(item=>{
|
|
|
|
|
|
if (item.properties.NAME_0 == "Kazakhstan") {
|
|
|
|
|
|
this.option.geo.regions.push({
|
|
|
|
|
|
name: item.properties.NAME_1,
|
|
|
|
|
|
itemStyle: {areaColor: "#eee"},
|
|
|
|
|
|
label: {show: true}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-09-04 19:19:17 +08:00
|
|
|
|
|
2020-09-11 18:37:14 +08:00
|
|
|
|
let mapRoom = document.querySelector("#map");
|
|
|
|
|
|
let roomWidth = mapRoom.offsetWidth;
|
|
|
|
|
|
let roomHeight = mapRoom.offsetHeight;
|
|
|
|
|
|
|
|
|
|
|
|
let windowWidth = window.innerWidth;
|
|
|
|
|
|
let windowHeight = window.innerHeight;
|
|
|
|
|
|
|
|
|
|
|
|
let scaleWidth = roomWidth/1200;
|
|
|
|
|
|
let scaleHeight = roomHeight/700;
|
|
|
|
|
|
|
|
|
|
|
|
let kazCenter = [67.45, 44];
|
|
|
|
|
|
if (windowWidth > 2000) {
|
|
|
|
|
|
this.option.geo.center = kazCenter;
|
|
|
|
|
|
this.option.geo.zoom = 6;
|
|
|
|
|
|
} else if (windowWidth > 1600) {
|
|
|
|
|
|
this.option.geo.center = [kazCenter[0]*1.15, kazCenter[1]*0.93];
|
|
|
|
|
|
this.option.geo.zoom = 5;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.option.geo.center = [kazCenter[0]*1.15*1.15, kazCenter[1]*0.93*0.93];
|
|
|
|
|
|
this.option.geo.zoom = 4;
|
|
|
|
|
|
}
|
2020-07-10 19:00:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-21 19:28:01 +08:00
|
|
|
|
this.modifyOption('tooltip','position',this.defaultTooltipPosition)
|
|
|
|
|
|
|
|
|
|
|
|
if (this.tooltipFormatter) {
|
|
|
|
|
|
this.modifyOption('tooltip', 'formatter', this.tooltipFormatter)
|
|
|
|
|
|
} else {
|
2020-04-24 14:20:46 +08:00
|
|
|
|
this.modifyOption('tooltip', 'formatter', this.defaultTooltipFormatter)
|
2020-04-21 19:28:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(this.chartType == 'line'){
|
|
|
|
|
|
if(this.yAxisFormatter){
|
2020-04-28 19:23:48 +08:00
|
|
|
|
this.option.yAxis.axisLabel.formatter=this.yAxisFormatter;
|
2020-04-21 19:28:01 +08:00
|
|
|
|
}else{
|
2020-04-28 19:23:48 +08:00
|
|
|
|
this.option.yAxis.axisLabel.formatter=this.defaultYAxisFormatter
|
2020-04-21 19:28:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-04-28 19:23:48 +08:00
|
|
|
|
// console.log(this.option)
|
2020-06-08 18:11:17 +08:00
|
|
|
|
if(this.series){
|
2020-06-03 19:20:46 +08:00
|
|
|
|
this.$set(this.option,'series',this.series);
|
|
|
|
|
|
this.noData=false;
|
|
|
|
|
|
this.chart.clear();
|
2020-07-08 19:09:54 +08:00
|
|
|
|
this.optionSeriesAll=[...this.option.series];
|
2020-07-09 10:57:54 +08:00
|
|
|
|
if(this.option.series instanceof Array){
|
|
|
|
|
|
this.option.series=this.option.series.filter((item,index)=>index<this.dataSize);
|
|
|
|
|
|
}
|
2020-06-03 19:20:46 +08:00
|
|
|
|
this.chart.setOption(this.option);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.noData=true;
|
|
|
|
|
|
let option=chartConfig.getOption('noData');
|
|
|
|
|
|
this.chart.clear();
|
|
|
|
|
|
this.chart.setOption(option);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-24 21:43:51 +08:00
|
|
|
|
//坐标轴label鼠标悬浮提示
|
|
|
|
|
|
if (this.axisTooltip) {
|
|
|
|
|
|
let tooltipDom = document.querySelector(".axis-tooltip");
|
|
|
|
|
|
this.chart.on('mouseover', (params) => {
|
|
|
|
|
|
if(params.componentType == this.axisTooltip + "Axis") {
|
|
|
|
|
|
tooltipDom.style.display = "block";
|
|
|
|
|
|
tooltipDom.innerHTML = params.value;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.chartRoom.addEventListener("mousemove", (event) => {
|
|
|
|
|
|
tooltipDom.style.top = event.pageY + "px";
|
|
|
|
|
|
tooltipDom.style.left = event.pageX-15 + "px";
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
this.chart.on('mouseout', (params) => {
|
|
|
|
|
|
if(params.componentType == this.axisTooltip + "Axis") {
|
|
|
|
|
|
tooltipDom.style.display = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-04-21 19:28:01 +08:00
|
|
|
|
this.resize();
|
2020-03-23 18:20:19 +08:00
|
|
|
|
},
|
2020-09-11 18:37:14 +08:00
|
|
|
|
resize() {
|
2020-05-18 14:12:56 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
if(this.chart){
|
2020-09-11 18:37:14 +08:00
|
|
|
|
let height;
|
|
|
|
|
|
let width;
|
|
|
|
|
|
if (this.chartType == "map") {
|
|
|
|
|
|
height = 700;
|
|
|
|
|
|
width = 1200;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
height = this.$el.clientHeight - document.querySelector("#legendArea").offsetHeight;
|
|
|
|
|
|
width=this.$el.clientWidth;
|
2020-05-18 14:12:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.chart.resize({width:width,height:height});
|
2020-04-21 19:28:01 +08:00
|
|
|
|
}
|
2020-05-18 14:12:56 +08:00
|
|
|
|
});
|
2020-04-21 19:28:01 +08:00
|
|
|
|
},
|
2020-04-22 19:45:10 +08:00
|
|
|
|
mouseEnterChart(){
|
|
|
|
|
|
if (this.chart&&this.showToolbox) {
|
|
|
|
|
|
this.chart.setOption({
|
|
|
|
|
|
toolbox: {
|
|
|
|
|
|
show:true,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mouseLeaveChart(){
|
|
|
|
|
|
if (this.chart) {
|
|
|
|
|
|
this.chart.setOption({
|
|
|
|
|
|
toolbox: {
|
|
|
|
|
|
show:false,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-04-21 19:28:01 +08:00
|
|
|
|
getBgColor:function(index){
|
2020-04-24 14:20:46 +08:00
|
|
|
|
let color=this.colors[index];
|
2020-04-21 19:28:01 +08:00
|
|
|
|
return color;
|
|
|
|
|
|
},
|
|
|
|
|
|
clickLegend(legendName,index){
|
|
|
|
|
|
let curIsGrey=this.legend[index].isGray;
|
|
|
|
|
|
if(this.chart){
|
|
|
|
|
|
this.legend.forEach((item,i)=>{
|
|
|
|
|
|
let isGrey = item.isGray;
|
|
|
|
|
|
if(index != i){ //不是当前点击的
|
|
|
|
|
|
if(!curIsGrey && !isGrey){
|
|
|
|
|
|
this.chart.dispatchAction({
|
|
|
|
|
|
type: 'legendUnSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
item.isGray=true;
|
|
|
|
|
|
}else if(!curIsGrey && isGrey){
|
|
|
|
|
|
this.chart.dispatchAction({
|
|
|
|
|
|
type: 'legendSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
item.isGray=false;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.chart.dispatchAction({
|
|
|
|
|
|
type: 'legendUnSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
item.isGray=true
|
|
|
|
|
|
}
|
|
|
|
|
|
}else {//当前点击的
|
|
|
|
|
|
this.chart.dispatchAction({
|
|
|
|
|
|
type: 'legendSelect',
|
|
|
|
|
|
name: item.name
|
|
|
|
|
|
});
|
|
|
|
|
|
if(item.isGray === true){
|
|
|
|
|
|
item.isGray = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
defaultTooltipPosition:function(point,params,dom,rect,size){
|
|
|
|
|
|
dom.style.transform = "translateZ(0)";
|
|
|
|
|
|
//提示框位置
|
|
|
|
|
|
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];
|
|
|
|
|
|
let chartDom = document.getElementById(this.chartId);
|
|
|
|
|
|
if(chartDom){
|
|
|
|
|
|
let parTop = chartDom.offsetTop;
|
|
|
|
|
|
let parLeft = chartDom.offsetLeft;
|
|
|
|
|
|
|
|
|
|
|
|
let parent = chartDom.parentElement;
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
if((parClientHeight-pointY-(parTop-parScrollTop)-20)>=boxHeight){//说明鼠标上面放不下提示框
|
|
|
|
|
|
y = pointY+10;
|
|
|
|
|
|
}else {
|
|
|
|
|
|
y = pointY-boxHeight;
|
|
|
|
|
|
}
|
|
|
|
|
|
return [x,y];
|
|
|
|
|
|
}else {
|
|
|
|
|
|
x = pointX - boxWidth;
|
|
|
|
|
|
y = pointY+10;
|
|
|
|
|
|
return [x,y];
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
defaultTooltipFormatter:function(params){
|
|
|
|
|
|
let str = `<div>`;
|
|
|
|
|
|
params.forEach((item, i) => {
|
|
|
|
|
|
if(i===0){
|
2020-09-07 11:43:45 +08:00
|
|
|
|
let value=item.data[0]
|
2020-04-21 19:28:01 +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/>`;
|
|
|
|
|
|
}
|
2020-04-24 15:49:54 +08:00
|
|
|
|
let alias=this.queryAlias(item.seriesName)
|
2020-04-21 19:28:01 +08:00
|
|
|
|
let val = Number(item.data[1]);
|
|
|
|
|
|
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-24 15:49:54 +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: ${item.color};}'></span>${alias?alias:item.seriesName}: </div>`;
|
2020-04-21 19:28:01 +08:00
|
|
|
|
str += `<div style="padding-left: 10px;">`;
|
2020-04-28 19:23:48 +08:00
|
|
|
|
str += chartDataFormat.getUnit(this.unit).compute(val,null,2);
|
2020-04-21 19:28:01 +08:00
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
str += `</div>`;
|
|
|
|
|
|
});
|
|
|
|
|
|
str +=`</div>`;
|
|
|
|
|
|
return str;
|
|
|
|
|
|
},
|
2020-04-24 15:49:54 +08:00
|
|
|
|
queryAlias:function(seriesName){
|
|
|
|
|
|
let alias=null;
|
|
|
|
|
|
if(this.legend&&this.legend.length>0){
|
|
|
|
|
|
let tempLegend=this.legend.find((item)=>{return item.name == seriesName});
|
|
|
|
|
|
if(tempLegend){
|
|
|
|
|
|
alias=tempLegend.alias;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return alias;
|
|
|
|
|
|
},
|
2020-04-21 19:28:01 +08:00
|
|
|
|
defaultYAxisFormatter:function(value,index){
|
2020-04-28 19:23:48 +08:00
|
|
|
|
let unit=chartDataFormat.getUnit(this.unit);
|
2020-04-21 19:28:01 +08:00
|
|
|
|
return unit.compute(value,index);
|
|
|
|
|
|
},
|
2020-04-24 15:49:54 +08:00
|
|
|
|
setRandomColors:function(num){//当线条过多,默认颜色数量不够时须使用此方法,num 颜色的数量,通常传递series的length即可
|
2020-04-24 14:20:46 +08:00
|
|
|
|
let colors=[];
|
|
|
|
|
|
for(let i=0;i<num;i++){
|
|
|
|
|
|
colors.push(randomcolor())
|
|
|
|
|
|
}
|
|
|
|
|
|
this.colors=Object.assign([],colors)
|
2020-04-24 15:49:54 +08:00
|
|
|
|
this.$set(this.option,'color',colors)
|
2020-04-24 14:20:46 +08:00
|
|
|
|
},
|
2020-03-23 18:20:19 +08:00
|
|
|
|
startLoading:function(){
|
|
|
|
|
|
this.$refs.loading.startLoading();
|
2020-05-07 15:22:03 +08:00
|
|
|
|
this.$emit("is-loading", true);
|
2020-03-23 18:20:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
endLoading:function(){
|
|
|
|
|
|
this.$refs.loading.endLoading();
|
2020-05-07 15:22:03 +08:00
|
|
|
|
this.$emit("is-loading", false);
|
2020-04-24 14:20:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
guid() {
|
|
|
|
|
|
function S4() {
|
|
|
|
|
|
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
|
|
|
|
|
|
},
|
2020-04-27 21:51:02 +08:00
|
|
|
|
clearChart() {
|
|
|
|
|
|
if(this.chart) {
|
|
|
|
|
|
this.chart.clear();
|
|
|
|
|
|
}
|
2020-07-08 19:09:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
showMore(){// 显示更多
|
|
|
|
|
|
this.legend=this.legendAll;
|
|
|
|
|
|
let option={
|
|
|
|
|
|
series:this.optionSeriesAll
|
|
|
|
|
|
};
|
|
|
|
|
|
this.chart.setOption(option);
|
|
|
|
|
|
this.chart.resize()
|
|
|
|
|
|
},
|
2020-09-04 19:19:17 +08:00
|
|
|
|
chartInit() {
|
|
|
|
|
|
this.chart=echarts.init(document.getElementById(this.chartId));
|
|
|
|
|
|
}
|
2020-03-23 18:20:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
2020-09-04 19:19:17 +08:00
|
|
|
|
this.chartInit();
|
2020-09-11 18:37:14 +08:00
|
|
|
|
EleResize.on(this.$el, this.resize, this.chartType);
|
2020-03-17 18:27:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch:{
|
|
|
|
|
|
|
2020-03-23 18:20:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
destroyed() {
|
|
|
|
|
|
if(this.chart){
|
|
|
|
|
|
this.chart.clear();
|
|
|
|
|
|
}
|
2020-03-17 18:27:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
2020-05-18 14:12:56 +08:00
|
|
|
|
<!--<style>
|
2020-05-31 22:33:16 +08:00
|
|
|
|
@import "../../../charts/chart.scss";
|
2020-05-18 14:12:56 +08:00
|
|
|
|
</style>-->
|
2020-03-17 18:27:46 +08:00
|
|
|
|
<style scoped>
|
2020-07-08 19:09:54 +08:00
|
|
|
|
.showMore{
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
.nz-icon-jinggao{
|
|
|
|
|
|
color: rgb(255, 133, 27);
|
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.moreChart{
|
|
|
|
|
|
color: rgb(87, 148, 242);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
2020-04-21 19:28:01 +08:00
|
|
|
|
.chart-room{
|
2020-04-22 19:45:10 +08:00
|
|
|
|
width: 100%;
|
2020-04-21 19:28:01 +08:00
|
|
|
|
height: 100%;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
}
|
|
|
|
|
|
.chart-room .legend-container{
|
|
|
|
|
|
width: calc(100% - 30px);
|
2020-05-18 14:12:56 +08:00
|
|
|
|
max-height:80px;
|
|
|
|
|
|
min-height:25px;
|
|
|
|
|
|
/*height: 80px;*/
|
2020-04-21 19:28:01 +08:00
|
|
|
|
font-size:12px;
|
|
|
|
|
|
text-align:left;
|
2020-05-18 14:12:56 +08:00
|
|
|
|
left: 10px;
|
|
|
|
|
|
bottom: 5px;
|
2020-04-21 19:28:01 +08:00
|
|
|
|
line-height: 18px;
|
2020-05-18 14:12:56 +08:00
|
|
|
|
position: absolute;
|
2020-04-21 19:28:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
.chart-room .legend-container .legend-item{
|
|
|
|
|
|
text-overflow:ellipsis;
|
|
|
|
|
|
white-space:nowrap;
|
|
|
|
|
|
overflow-x:hidden;
|
|
|
|
|
|
cursor:pointer;
|
|
|
|
|
|
display:inline-block;
|
|
|
|
|
|
float:left;
|
|
|
|
|
|
line-height: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.chart-room .ft-gr{
|
|
|
|
|
|
color:lightgray;
|
|
|
|
|
|
}
|
|
|
|
|
|
.chart-room .legend-shape{
|
|
|
|
|
|
display:inline-block;
|
|
|
|
|
|
margin-right:5px;
|
|
|
|
|
|
border-radius:10px;
|
|
|
|
|
|
width:15px;
|
|
|
|
|
|
height:5px;
|
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
|
}
|
2020-03-17 18:27:46 +08:00
|
|
|
|
</style>
|