|
|
<template>
|
|
|
<div :style="styleObj" >
|
|
|
<div :style="itemStyle" v-for="(item,index) in chartData" :key="index">
|
|
|
{{item.flag}}
|
|
|
<v-chart :ref="item.flag" :options="options[index]" autoresize/>
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {mapGetters} from "vuex";
|
|
|
|
|
|
export default {
|
|
|
name: "customBarlinechart",
|
|
|
components: {},
|
|
|
props: {
|
|
|
value: Object,
|
|
|
ispreview: Boolean
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
kpiUnit:'',
|
|
|
chartData:[
|
|
|
{flag:'cpu'},
|
|
|
],
|
|
|
chartDataItem:[],
|
|
|
options: [{
|
|
|
color: [],
|
|
|
grid: {},
|
|
|
title: {
|
|
|
text: "",
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
},
|
|
|
tooltip: {
|
|
|
trigger: "axis",
|
|
|
formatter: "{a} <br/>{b} : {c} '%'"
|
|
|
},
|
|
|
legend: {
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
},
|
|
|
},
|
|
|
xAxis: [
|
|
|
{
|
|
|
type: "category",
|
|
|
data: [],
|
|
|
axisLabel: {
|
|
|
show: false,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
yAxis: [
|
|
|
{
|
|
|
type: "value",
|
|
|
name: "",
|
|
|
min: 0,
|
|
|
max: 2,
|
|
|
interval: 1,
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
type: "value",
|
|
|
name: "",
|
|
|
min: 0,
|
|
|
max: 100,
|
|
|
interval: 10,
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
series: [
|
|
|
{
|
|
|
name: "",
|
|
|
type: "bar",
|
|
|
data: [],
|
|
|
itemStyle: {
|
|
|
barBorderRadius: null
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
name: "",
|
|
|
type: "line",
|
|
|
yAxisIndex: 1,
|
|
|
data: [],
|
|
|
itemStyle: {}
|
|
|
},
|
|
|
{
|
|
|
name: "",
|
|
|
type: "line",
|
|
|
yAxisIndex: 1,
|
|
|
data: [],
|
|
|
itemStyle: {}
|
|
|
}
|
|
|
]
|
|
|
}],
|
|
|
optionsStyle: {}, // 样式
|
|
|
optionsData: {}, // 数据
|
|
|
optionsCollapse: {}, // 图标属性
|
|
|
optionsSetup: {}
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
//月季度年按钮通过vuex接收值
|
|
|
...mapGetters(['buttonVals']),
|
|
|
buttonVal(){
|
|
|
return this.buttonVals;
|
|
|
},
|
|
|
//进度条flag数据
|
|
|
...mapGetters(['progressDatas']),
|
|
|
progressData(){
|
|
|
return this.progressDatas;
|
|
|
},
|
|
|
styleObj() {
|
|
|
return {
|
|
|
position: this.ispreview ? "absolute" : "static",
|
|
|
width: this.optionsStyle.width + "px",
|
|
|
height: this.optionsStyle.height + "px",
|
|
|
left: this.optionsStyle.left + "px",
|
|
|
top: this.optionsStyle.top + "px",
|
|
|
background: this.optionsSetup.background
|
|
|
};
|
|
|
},
|
|
|
itemStyle(){
|
|
|
return{
|
|
|
height:this.optionsSetup.itemHeight + "px",
|
|
|
width: this.optionsStyle.width + "px",
|
|
|
background:this.optionsSetup.itemBackground,
|
|
|
'margin-bottom':this.optionsSetup.itemMarginBottom+'px'
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
value: {
|
|
|
handler(val) {
|
|
|
this.optionsStyle = val.position;
|
|
|
this.optionsData = val.data;
|
|
|
this.optionsCollapse = val.collapse;
|
|
|
this.optionsSetup = val.setup;
|
|
|
this.editorOptions();
|
|
|
},
|
|
|
deep: true
|
|
|
},
|
|
|
//监听月季度年按钮切换值
|
|
|
buttonVal:{
|
|
|
handler(val){
|
|
|
if(this.optionsSetup.isVuex){
|
|
|
let optionsData=this.optionsData;
|
|
|
if(this.optionsData.dataType=="dynamicData"){
|
|
|
//改变参数值-月季度年,重新加载动态数据--待测
|
|
|
this.optionsData.dynamicData.contextData.time=val;
|
|
|
// this.editorOptions();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},
|
|
|
deep:true
|
|
|
},
|
|
|
//监听进度条数据
|
|
|
progressData:{
|
|
|
handler(val){
|
|
|
console.log("_______",val);
|
|
|
let arr=[];
|
|
|
let newArr=[];
|
|
|
if(val){
|
|
|
arr=val.split(',')
|
|
|
arr.map(item=>{
|
|
|
newArr.push({flag:item})
|
|
|
})
|
|
|
|
|
|
/*
|
|
|
if (this.optionsData.dataType == "dynamicData") {
|
|
|
console.log("(*)(*)",this.optionsData.dynamicData.contextData.flag)
|
|
|
this.optionsData.dynamicData.contextData.flag = val;
|
|
|
}
|
|
|
this.editorOptions();
|
|
|
if(this.chartDataItem.indexOf(val)==-1){
|
|
|
this.chartDataItem.push(val)
|
|
|
}
|
|
|
this.chartDataItem.map(item=>{
|
|
|
newArr.push({flag:item})
|
|
|
})*/
|
|
|
}
|
|
|
this.chartData=newArr;
|
|
|
|
|
|
this.chartData.map((item,index) => {
|
|
|
this.options[index]={
|
|
|
flag:item.flag,
|
|
|
color: [],
|
|
|
grid: {},
|
|
|
title: {
|
|
|
text: "",
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
},
|
|
|
tooltip: {
|
|
|
trigger: "axis",
|
|
|
formatter: "{a} <br/>{b} : {c} '%'"
|
|
|
},
|
|
|
legend: {
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
},
|
|
|
},
|
|
|
xAxis: [
|
|
|
{
|
|
|
type: "category",
|
|
|
data: [],
|
|
|
axisLabel: {
|
|
|
show: false,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
yAxis: [
|
|
|
{
|
|
|
type: "value",
|
|
|
name: "",
|
|
|
min: 0,
|
|
|
max: 2,
|
|
|
interval: 1,
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
type: "value",
|
|
|
name: "",
|
|
|
min: 0,
|
|
|
max: 100,
|
|
|
interval: 10,
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
series: [
|
|
|
{
|
|
|
name: "",
|
|
|
type: "bar",
|
|
|
data: [],
|
|
|
itemStyle: {
|
|
|
barBorderRadius: null
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
name: "",
|
|
|
type: "line",
|
|
|
yAxisIndex: 1,
|
|
|
data: [],
|
|
|
itemStyle: {}
|
|
|
},
|
|
|
{
|
|
|
name: "",
|
|
|
type: "line",
|
|
|
yAxisIndex: 1,
|
|
|
data: [],
|
|
|
itemStyle: {}
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
console.log("_+111_+_+_", this.$refs[item.flag])
|
|
|
if (this.optionsData.dataType == "dynamicData") {
|
|
|
console.log("(*)(*)",this.optionsData.dynamicData.contextData.flag,item.flag)
|
|
|
this.optionsData.dynamicData.contextData.flag = item.flag;
|
|
|
}
|
|
|
this.editorOptions();
|
|
|
|
|
|
})
|
|
|
// this.thenData();
|
|
|
// this.forData();
|
|
|
},
|
|
|
deep:true
|
|
|
},
|
|
|
},
|
|
|
created() {
|
|
|
this.optionsStyle = this.value.position;
|
|
|
this.optionsData = this.value.data;
|
|
|
this.optionsCollapse = this.value.collapse;
|
|
|
this.optionsSetup = this.value.setup;
|
|
|
this.editorOptions();
|
|
|
},
|
|
|
methods: {
|
|
|
// 修改图标options属性
|
|
|
editorOptions() {
|
|
|
// this.forData();
|
|
|
|
|
|
this.setOptionsTitle();
|
|
|
this.setOptionsX();
|
|
|
this.setOptionsY();
|
|
|
this.setOptionsTop();
|
|
|
this.setOptionsBar();
|
|
|
this.setOptionsTooltip();
|
|
|
this.setOptionsData();
|
|
|
this.setOptionsMargin();
|
|
|
this.setOptionsLegend();
|
|
|
this.setOptionsColor();
|
|
|
},
|
|
|
// 标题修改
|
|
|
setOptionsTitle() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
const title = {};
|
|
|
title.text = optionsSetup.titleText;
|
|
|
title.show = optionsSetup.isNoTitle;
|
|
|
title.left = optionsSetup.textAlign;
|
|
|
title.textStyle = {
|
|
|
color: optionsSetup.textColor,
|
|
|
fontSize: optionsSetup.textFontSize,
|
|
|
fontWeight: optionsSetup.textFontWeight
|
|
|
};
|
|
|
title.subtext = optionsSetup.subText;
|
|
|
title.subtextStyle = {
|
|
|
color: optionsSetup.subTextColor,
|
|
|
fontWeight: optionsSetup.subTextFontWeight,
|
|
|
fontSize: optionsSetup.subTextFontSize
|
|
|
};
|
|
|
if(optionsSetup.textAlignVertical=='bottom'){
|
|
|
title.bottom='0';
|
|
|
this.options[this.chartData.length-1].title = title;
|
|
|
|
|
|
}else{
|
|
|
title.top='8px';
|
|
|
this.options[0].title = title;
|
|
|
|
|
|
}
|
|
|
// this.options[0].title = title;
|
|
|
},
|
|
|
// X轴设置
|
|
|
setOptionsX() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
const xAxis = {
|
|
|
type: "category",
|
|
|
show: optionsSetup.hideX, // 坐标轴是否显示
|
|
|
name: optionsSetup.xName, // 坐标轴名称
|
|
|
nameTextStyle: {
|
|
|
color: optionsSetup.nameColorX,
|
|
|
fontSize: optionsSetup.nameFontSizeX
|
|
|
},
|
|
|
nameRotate: optionsSetup.textAngle, // 文字角度
|
|
|
inverse: optionsSetup.reversalX, // 轴反转
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
interval: optionsSetup.textInterval, // 文字间隔
|
|
|
rotate: optionsSetup.textAngle, // 文字角度
|
|
|
textStyle: {
|
|
|
color: optionsSetup.Xcolor, // x轴 坐标文字颜色
|
|
|
fontSize: optionsSetup.fontSizeX
|
|
|
}
|
|
|
},
|
|
|
axisLine: {
|
|
|
show: true,
|
|
|
lineStyle: {
|
|
|
color: optionsSetup.lineColorX
|
|
|
}
|
|
|
},
|
|
|
splitLine: {
|
|
|
show: optionsSetup.isShowSplitLineX,
|
|
|
lineStyle: {
|
|
|
color: optionsSetup.splitLineColorX
|
|
|
}
|
|
|
},
|
|
|
boundaryGap:['1','2']//坐标轴两边留白,为false则从0开始
|
|
|
};
|
|
|
// this.options.xAxis = xAxis;
|
|
|
this.options.map(item=>{
|
|
|
item.xAxis=xAxis;
|
|
|
})
|
|
|
},
|
|
|
// Y轴设置
|
|
|
setOptionsY() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
const yAxis = [
|
|
|
{
|
|
|
type: "value",
|
|
|
splitNumber: optionsSetup.splitNumberLeft,// 均分
|
|
|
show: optionsSetup.isShowYLeft, // 坐标轴是否显示
|
|
|
name: optionsSetup.textNameYLeft, // 坐标轴名称
|
|
|
nameTextStyle: { // 别名
|
|
|
color: optionsSetup.nameColorYLeft,
|
|
|
fontSize: optionsSetup.namefontSizeYLeft
|
|
|
},
|
|
|
inverse: optionsSetup.reversalY, // 轴反转
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: optionsSetup.colorY, // y轴 坐标文字颜色
|
|
|
fontSize: optionsSetup.fontSizeY
|
|
|
}
|
|
|
},
|
|
|
axisLine: {
|
|
|
show: true,
|
|
|
lineStyle: {
|
|
|
color: optionsSetup.lineColorY
|
|
|
}
|
|
|
},
|
|
|
splitLine: {
|
|
|
show: false,
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
type: "value",
|
|
|
splitNumber: optionsSetup.splitNumberRight,// 均分
|
|
|
show: optionsSetup.isShowYRight, // 坐标轴是否显示
|
|
|
name: optionsSetup.textNameYRight, // 坐标轴名称
|
|
|
nameTextStyle: { // 别名
|
|
|
color: optionsSetup.nameColorYRight,
|
|
|
fontSize: optionsSetup.namefontSizeYRight
|
|
|
},
|
|
|
inverse: optionsSetup.reversalY, // 轴反转
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: optionsSetup.colorY, // y轴 坐标文字颜色
|
|
|
fontSize: optionsSetup.fontSizeY
|
|
|
},
|
|
|
formatter: '{value} %'
|
|
|
},
|
|
|
axisLine: {
|
|
|
show: true,
|
|
|
lineStyle: {
|
|
|
color: optionsSetup.lineColorY
|
|
|
}
|
|
|
},
|
|
|
splitLine: {
|
|
|
show: false,
|
|
|
}
|
|
|
}
|
|
|
];
|
|
|
// this.options.yAxis = yAxis;
|
|
|
this.options.map(item=>{
|
|
|
item.yAxis=yAxis;
|
|
|
})
|
|
|
},
|
|
|
// 折线设置 数值设置
|
|
|
setOptionsTop() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
this.options.map(item=>{
|
|
|
// const series = this.options.series;
|
|
|
const series = item.series;
|
|
|
for (const key in series) {
|
|
|
if (series[key].type == "line") {
|
|
|
series[key].showSymbol = optionsSetup.markPoint;
|
|
|
series[key].symbolSize = optionsSetup.pointSize;
|
|
|
series[key].smooth = optionsSetup.smoothCurve;
|
|
|
if (optionsSetup.area) {
|
|
|
series[key].areaStyle = {
|
|
|
opacity: optionsSetup.areaThickness / 100
|
|
|
};
|
|
|
} else {
|
|
|
series[key].areaStyle = {
|
|
|
opacity: 0
|
|
|
};
|
|
|
}
|
|
|
series[key].lineStyle = {
|
|
|
width: optionsSetup.lineWidth
|
|
|
};
|
|
|
series[key].itemStyle.borderRadius = optionsSetup.radius;
|
|
|
series[key].label = {
|
|
|
show: optionsSetup.isShowLine,
|
|
|
position: "top",
|
|
|
distance: optionsSetup.distanceLine,
|
|
|
fontSize: optionsSetup.fontSizeLine,
|
|
|
color: optionsSetup.subTextColorLine,
|
|
|
fontWeight: optionsSetup.fontWeightLine
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
// this.options.series = series;
|
|
|
/*this.options.map(item=>{
|
|
|
item.series=series;
|
|
|
})*/
|
|
|
},
|
|
|
// 柱体设置 数值设置
|
|
|
setOptionsBar() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
this.options.map(item=>{
|
|
|
// const series = this.options.series;
|
|
|
const series = item.series;
|
|
|
for (const key in series) {
|
|
|
if (series[key].type == "bar") {
|
|
|
series[key].label = {
|
|
|
show: optionsSetup.isShowBar,
|
|
|
position: "top",
|
|
|
distance: optionsSetup.distanceBar,
|
|
|
fontSize: optionsSetup.fontSizeBar,
|
|
|
color: optionsSetup.subTextColorBar,
|
|
|
fontWeight: optionsSetup.fontWeightBar
|
|
|
};
|
|
|
series[key].barWidth = optionsSetup.maxWidth;
|
|
|
series[key].barMinHeight = optionsSetup.minHeight;
|
|
|
series[key].itemStyle.barBorderRadius = optionsSetup.radius;
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
// this.options.series = series;
|
|
|
// this.options.map(item=>{
|
|
|
// item.series=series;
|
|
|
// })
|
|
|
},
|
|
|
// tooltip 设置
|
|
|
setOptionsTooltip() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
let that=this;
|
|
|
const tooltip = {
|
|
|
trigger: "axis",
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: optionsSetup.lineColor,
|
|
|
fontSize: optionsSetup.tipFontSize
|
|
|
},
|
|
|
formatter:function (param) {
|
|
|
let kpiName=optionsSetup.titleText;
|
|
|
// 鼠标悬浮线上提示
|
|
|
// 顶部提示
|
|
|
let tips = '<table>';
|
|
|
if (param.length == 1) {
|
|
|
tips += "<tr><td style='text-align:left;' colspan='4'>" + param[0].name + "</td></tr>";
|
|
|
} else {
|
|
|
tips += "<tr><td style='text-align:left;' colspan='4'>" + kpiName + " " + param[0].name + "</td></tr>";
|
|
|
}
|
|
|
// 每一条提示
|
|
|
$.each(param, function (i, v) {
|
|
|
let kpiUnit='';
|
|
|
tips += "<tr><td>" + v.marker + "</td>";
|
|
|
tips += '<td style="text-align: left;">';
|
|
|
if (v.seriesName.indexOf('率') != -1) {
|
|
|
kpiUnit='%';
|
|
|
}else{
|
|
|
kpiUnit=that.kpiUnit
|
|
|
}
|
|
|
tips += (v.seriesName + ' ');
|
|
|
|
|
|
// tips += (v.seriesName && v.seriesName != '1' && !/series[0-9]+/.test(v.seriesName)) ? v.seriesName : '';
|
|
|
tips += '</td>'
|
|
|
tips += "<td>: </td><td>" + v.value;
|
|
|
tips += kpiUnit + "</td></tr>";
|
|
|
});
|
|
|
tips += '</table>'
|
|
|
return tips;
|
|
|
}
|
|
|
};
|
|
|
// this.options.tooltip = tooltip;
|
|
|
this.options.map(item=>{
|
|
|
item.tooltip=tooltip;
|
|
|
})
|
|
|
},
|
|
|
// 边距设置
|
|
|
setOptionsMargin() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
const grid = {
|
|
|
left: optionsSetup.marginLeft,
|
|
|
right: optionsSetup.marginRight,
|
|
|
bottom: optionsSetup.marginBottom,
|
|
|
top: optionsSetup.marginTop,
|
|
|
containLabel: true
|
|
|
};
|
|
|
// this.options.grid = grid;
|
|
|
this.options.map(item=>{
|
|
|
item.grid=grid;
|
|
|
})
|
|
|
},
|
|
|
// 图例操作 legend
|
|
|
setOptionsLegend() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
this.options.map(item=>{
|
|
|
// const legend = this.options.legend;
|
|
|
const legend = item.legend;
|
|
|
legend.show = optionsSetup.isShowLegend;
|
|
|
legend.left = optionsSetup.lateralPosition;
|
|
|
legend.top = optionsSetup.longitudinalPosition == "top" ? 20 : "auto";
|
|
|
legend.bottom =
|
|
|
optionsSetup.longitudinalPosition == "bottom" ? 0 : "auto";
|
|
|
legend.orient = optionsSetup.layoutFront;
|
|
|
legend.textStyle = {
|
|
|
color: optionsSetup.lengedColor,
|
|
|
fontSize: optionsSetup.lengedFontSize
|
|
|
};
|
|
|
legend.itemWidth = optionsSetup.lengedWidth;
|
|
|
if(!optionsSetup.isShowLegendText){
|
|
|
legend.formatter= function (name) {
|
|
|
return '';
|
|
|
}
|
|
|
}else{
|
|
|
legend.formatter= function (name) {
|
|
|
return name;
|
|
|
}
|
|
|
}
|
|
|
legend.itemHeight= 5;
|
|
|
legend.tooltip= {
|
|
|
show: true
|
|
|
}
|
|
|
})
|
|
|
|
|
|
},
|
|
|
// 图例颜色修改
|
|
|
setOptionsColor() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
const customColor = optionsSetup.customColor;
|
|
|
if (!customColor) return;
|
|
|
const arrColor = [];
|
|
|
for (let i = 0; i < customColor.length; i++) {
|
|
|
arrColor.push(customColor[i].color);
|
|
|
}
|
|
|
// this.options.color = arrColor;
|
|
|
this.options.map(item=>{
|
|
|
item.color=arrColor;
|
|
|
})
|
|
|
// this.options = Object.assign({}, this.options);
|
|
|
this.options.map(item=>{
|
|
|
item=Object.assign({}, this.options);
|
|
|
})
|
|
|
},
|
|
|
// 数据处理
|
|
|
setOptionsData() {
|
|
|
const optionsData = this.optionsData; // 数据类型 静态 or 动态
|
|
|
optionsData.dataType == "staticData"
|
|
|
? this.staticDataFn(optionsData.staticData)
|
|
|
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
|
|
|
},
|
|
|
staticDataFn(val) {
|
|
|
// const series = this.options.series;
|
|
|
let axis = [];
|
|
|
let bar = [];
|
|
|
let line = [];
|
|
|
for (const i in val) {
|
|
|
axis[i] = val[i].axis;
|
|
|
bar[i] = val[i].bar;
|
|
|
line[i] = val[i].line;
|
|
|
}
|
|
|
// x轴
|
|
|
// this.options.xAxis.data = axis;
|
|
|
/* this.options.map(item=>{
|
|
|
item.xAxis.data=axis;
|
|
|
})*/
|
|
|
// series
|
|
|
/* for (const i in series) {
|
|
|
if (series[i].type == "bar") {
|
|
|
series[i].data = bar;
|
|
|
} else {
|
|
|
series[i].data = line;
|
|
|
}
|
|
|
}*/
|
|
|
this.options.map(item=>{
|
|
|
console.log(")(()(",item.series)
|
|
|
for (const i in item.series) {
|
|
|
if (item.series[i].type == "bar") {
|
|
|
item.series[i].data = bar;
|
|
|
} else {
|
|
|
item.series[i].data = line;
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
this.chartData.map((item,index)=>{
|
|
|
console.log("))))))",this.options[index])
|
|
|
this.options[index].xAxis.data=axis;
|
|
|
/* for (const i in this.options[index].series) {
|
|
|
if (this.options[index].series[i].type == "bar") {
|
|
|
this.options[index].series[i].data = bar;
|
|
|
} else {
|
|
|
this.options[index].series[i].data = line;
|
|
|
}
|
|
|
}*/
|
|
|
})
|
|
|
},
|
|
|
dynamicDataFn(val, refreshTime) {
|
|
|
if (!val) return;
|
|
|
if (this.ispreview) {
|
|
|
this.getEchartData(val);
|
|
|
this.flagInter = setInterval(() => {
|
|
|
this.getEchartData(val);
|
|
|
}, refreshTime);
|
|
|
} else {
|
|
|
this.getEchartData(val);
|
|
|
}
|
|
|
},
|
|
|
async getEchartData(val) {
|
|
|
const data = this.queryEchartsData(val);
|
|
|
this.chartDataItem.push(data);
|
|
|
console.log("900000",this.optionsData.dynamicData?this.optionsData.dynamicData.contextData.flag:'009')
|
|
|
// return await Promise.all(this.chartDataItem)//.then(data => {console.log("data",data,this.optionsData.dynamicData.contextData.flag )})
|
|
|
/*if(this.chartData.length==this.chartDataItem.length){
|
|
|
let arr=[];
|
|
|
this.chartDataItem.map(item=>{
|
|
|
item.then(res => {
|
|
|
|
|
|
this.renderingFn(res,this.optionsData.dynamicData.contextData.flag);
|
|
|
});
|
|
|
})
|
|
|
}*/
|
|
|
// data.then(res => {
|
|
|
// this.renderingFn(res,this.optionsData.dynamicData.contextData.flag);
|
|
|
// });
|
|
|
},
|
|
|
async thenData(){
|
|
|
const res = await this.getEchartData()
|
|
|
console.log("res",res)
|
|
|
},
|
|
|
renderingFn(val,flag) {
|
|
|
console.log("*************",val,flag)
|
|
|
// this.forData(val);
|
|
|
this.setData(val);
|
|
|
|
|
|
},
|
|
|
setData(val){
|
|
|
let xAxis=val.xAxis;
|
|
|
if(xAxis && xAxis.length>0){
|
|
|
// this.options.xAxis.data =xAxis;
|
|
|
this.options.map(item=>{
|
|
|
item.xAxis.data=xAxis;
|
|
|
})
|
|
|
}else{
|
|
|
if(this.buttonVal=='year'){
|
|
|
// this.options.xAxis.data=['今年'];
|
|
|
this.options.map(item=>{
|
|
|
item.xAxis.data=['今年'];
|
|
|
})
|
|
|
}else if(this.buttonVal=='quarter'){
|
|
|
// this.options.xAxis.data=['1季度','2季度','3季度','4季度'];
|
|
|
this.options.map(item=>{
|
|
|
item.xAxis.data=['1季度','2季度','3季度','4季度'];
|
|
|
})
|
|
|
}else if(this.buttonVal=='month'){
|
|
|
this.options.xAxis.data=['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
|
|
|
this.options.map(item=>{
|
|
|
item.xAxis.data=['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
|
|
|
})
|
|
|
}else{
|
|
|
// this.options.xAxis.data=['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00']
|
|
|
this.options.map(item=>{
|
|
|
item.xAxis.data=['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00'];
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const series = val.series;
|
|
|
if(series && series.length>0){
|
|
|
series.map((item,index)=>{
|
|
|
if(item.name.indexOf('率')!=-1){
|
|
|
item.yAxisIndex= 1;
|
|
|
|
|
|
}else{
|
|
|
item.yAxisIndex=0;
|
|
|
|
|
|
}
|
|
|
// if(index%2==0){
|
|
|
// item.yAxisIndex= 1;
|
|
|
// }else{
|
|
|
// item.yAxisIndex=0;
|
|
|
// }
|
|
|
if(item.type=='bar'){
|
|
|
item.itemStyle= {
|
|
|
barBorderRadius: null
|
|
|
}
|
|
|
item.barMinHeight=2;
|
|
|
}else if(item.type=='line'){
|
|
|
item.itemStyle= {
|
|
|
borderRadius: null
|
|
|
}
|
|
|
item.symbol='line';//设置图列为直线不带空心圆
|
|
|
}
|
|
|
|
|
|
})
|
|
|
}
|
|
|
// this.forData()
|
|
|
// this.chartData.map((item,index)=>{
|
|
|
console.log("66666666666666",this.optionsData.dynamicData.contextData.flag)
|
|
|
let flag=this.optionsData.dynamicData.contextData.flag;
|
|
|
// if(this.optionsData.dynamicData.contextData.flag==item.flag){
|
|
|
if(series){
|
|
|
// this.$refs[flag].options.series=series;
|
|
|
this.options.map((item,index)=>{
|
|
|
if(item.flag==flag){
|
|
|
this.options[index].series=series;
|
|
|
}
|
|
|
})
|
|
|
|
|
|
}else{
|
|
|
/* this.$refs[flag].options.series=[{
|
|
|
name: "",
|
|
|
type:'bar',
|
|
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
}];*/
|
|
|
|
|
|
this.options.map((item,index)=>{
|
|
|
if(item.flag==flag){
|
|
|
this.options[index].series= [{
|
|
|
name: "",
|
|
|
type:'bar',
|
|
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
}];
|
|
|
}
|
|
|
})
|
|
|
|
|
|
|
|
|
}
|
|
|
// }
|
|
|
|
|
|
// })
|
|
|
// console.log("123445",this.options)
|
|
|
// this.options.series=series;
|
|
|
},
|
|
|
forData(val){
|
|
|
let that=this;
|
|
|
let arr=this.chartData;
|
|
|
/*arr.map((item,index) => {
|
|
|
this.options[index]={
|
|
|
flag:item.flag,
|
|
|
color: [],
|
|
|
grid: {},
|
|
|
title: {
|
|
|
text: "",
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
},
|
|
|
tooltip: {
|
|
|
trigger: "axis",
|
|
|
formatter: "{a} <br/>{b} : {c} '%'"
|
|
|
},
|
|
|
legend: {
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
},
|
|
|
},
|
|
|
xAxis: [
|
|
|
{
|
|
|
type: "category",
|
|
|
data: [],
|
|
|
axisLabel: {
|
|
|
show: false,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
yAxis: [
|
|
|
{
|
|
|
type: "value",
|
|
|
name: "",
|
|
|
min: 0,
|
|
|
max: 2,
|
|
|
interval: 1,
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
type: "value",
|
|
|
name: "",
|
|
|
min: 0,
|
|
|
max: 100,
|
|
|
interval: 10,
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
color: "#fff"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
series: [
|
|
|
{
|
|
|
name: "",
|
|
|
type: "bar",
|
|
|
data: [],
|
|
|
itemStyle: {
|
|
|
barBorderRadius: null
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
name: "",
|
|
|
type: "line",
|
|
|
yAxisIndex: 1,
|
|
|
data: [],
|
|
|
itemStyle: {}
|
|
|
},
|
|
|
{
|
|
|
name: "",
|
|
|
type: "line",
|
|
|
yAxisIndex: 1,
|
|
|
data: [],
|
|
|
itemStyle: {}
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
console.log("_+_+_+_", this.$refs[item.flag])
|
|
|
|
|
|
})*/
|
|
|
/*for(let i in arr){
|
|
|
if (this.optionsData.dataType == "dynamicData") {
|
|
|
console.log("(*)(*)",that.optionsData.dynamicData.contextData.flag,arr[i].flag)
|
|
|
that.optionsData.dynamicData.contextData.flag = arr[i].flag;
|
|
|
// that.setOptionsData();
|
|
|
|
|
|
}
|
|
|
}*/
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
.echarts {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
overflow: hidden;
|
|
|
}
|
|
|
</style> |
...
|
...
|
|