|
|
@ -1,16 +1,17 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div :style="styleObj">
|
|
|
|
<div :style="styleObj">
|
|
|
|
<v-chart :options="options" autoresize/>
|
|
|
|
<v-chart :options="options" autoresize />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import { eventBus } from "@/utils/eventBus";
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: "WidgetBarchart",
|
|
|
|
name: "WidgetBarchart",
|
|
|
|
components: {},
|
|
|
|
components: {},
|
|
|
|
props: {
|
|
|
|
props: {
|
|
|
|
value: Object,
|
|
|
|
value: Object,
|
|
|
|
ispreview: Boolean
|
|
|
|
ispreview: Boolean,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@ -18,8 +19,8 @@ export default {
|
|
|
|
grid: {},
|
|
|
|
grid: {},
|
|
|
|
legend: {
|
|
|
|
legend: {
|
|
|
|
textStyle: {
|
|
|
|
textStyle: {
|
|
|
|
color: "#fff"
|
|
|
|
color: "#fff",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
xAxis: {
|
|
|
|
xAxis: {
|
|
|
|
type: "category",
|
|
|
|
type: "category",
|
|
|
@ -27,9 +28,9 @@ export default {
|
|
|
|
axisLabel: {
|
|
|
|
axisLabel: {
|
|
|
|
show: true,
|
|
|
|
show: true,
|
|
|
|
textStyle: {
|
|
|
|
textStyle: {
|
|
|
|
color: "#fff"
|
|
|
|
color: "#fff",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
yAxis: {
|
|
|
|
yAxis: {
|
|
|
|
type: "value",
|
|
|
|
type: "value",
|
|
|
@ -37,9 +38,9 @@ export default {
|
|
|
|
axisLabel: {
|
|
|
|
axisLabel: {
|
|
|
|
show: true,
|
|
|
|
show: true,
|
|
|
|
textStyle: {
|
|
|
|
textStyle: {
|
|
|
|
color: "#fff"
|
|
|
|
color: "#fff",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
series: [
|
|
|
|
series: [
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -47,15 +48,15 @@ export default {
|
|
|
|
type: "bar",
|
|
|
|
type: "bar",
|
|
|
|
barGap: "0%",
|
|
|
|
barGap: "0%",
|
|
|
|
itemStyle: {
|
|
|
|
itemStyle: {
|
|
|
|
borderRadius: null
|
|
|
|
borderRadius: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
optionsStyle: {}, // 样式
|
|
|
|
optionsStyle: {}, // 样式
|
|
|
|
optionsData: {}, // 数据
|
|
|
|
optionsData: {}, // 数据
|
|
|
|
optionsSetup: {},
|
|
|
|
optionsSetup: {},
|
|
|
|
flagInter: null
|
|
|
|
flagInter: null,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
computed: {
|
|
|
@ -66,9 +67,9 @@ export default {
|
|
|
|
height: this.optionsStyle.height + "px",
|
|
|
|
height: this.optionsStyle.height + "px",
|
|
|
|
left: this.optionsStyle.left + "px",
|
|
|
|
left: this.optionsStyle.left + "px",
|
|
|
|
top: this.optionsStyle.top + "px",
|
|
|
|
top: this.optionsStyle.top + "px",
|
|
|
|
background: this.optionsSetup.background
|
|
|
|
background: this.optionsSetup.background,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
value: {
|
|
|
|
value: {
|
|
|
@ -79,8 +80,8 @@ export default {
|
|
|
|
this.optionsSetup = val.setup;
|
|
|
|
this.optionsSetup = val.setup;
|
|
|
|
this.editorOptions();
|
|
|
|
this.editorOptions();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
deep: true
|
|
|
|
deep: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.optionsStyle = this.value.position;
|
|
|
|
this.optionsStyle = this.value.position;
|
|
|
@ -88,6 +89,20 @@ export default {
|
|
|
|
this.optionsCollapse = this.value.setup;
|
|
|
|
this.optionsCollapse = this.value.setup;
|
|
|
|
this.optionsSetup = this.value.setup;
|
|
|
|
this.optionsSetup = this.value.setup;
|
|
|
|
this.editorOptions();
|
|
|
|
this.editorOptions();
|
|
|
|
|
|
|
|
eventBus.$on("params", (formParams) => {
|
|
|
|
|
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
|
|
|
|
|
const optionsData = this.optionsData;
|
|
|
|
|
|
|
|
const uuid = optionsSetup.uuid;
|
|
|
|
|
|
|
|
if (formParams.assChart.includes(uuid)) {
|
|
|
|
|
|
|
|
const contextData = optionsData.dynamicData.contextData;
|
|
|
|
|
|
|
|
for (const key in contextData) {
|
|
|
|
|
|
|
|
if (formParams.hasOwnProperty(key)) {
|
|
|
|
|
|
|
|
contextData[key] = formParams[key];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getEchartData(optionsData.dynamicData, optionsSetup);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
// 修改图标options属性
|
|
|
|
// 修改图标options属性
|
|
|
@ -134,7 +149,7 @@ export default {
|
|
|
|
name: optionsSetup.nameX,
|
|
|
|
name: optionsSetup.nameX,
|
|
|
|
nameTextStyle: {
|
|
|
|
nameTextStyle: {
|
|
|
|
color: optionsSetup.nameColorX,
|
|
|
|
color: optionsSetup.nameColorX,
|
|
|
|
fontSize: optionsSetup.nameFontSizeX
|
|
|
|
fontSize: optionsSetup.nameFontSizeX,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 轴反转
|
|
|
|
// 轴反转
|
|
|
|
inverse: optionsSetup.reversalX,
|
|
|
|
inverse: optionsSetup.reversalX,
|
|
|
@ -147,23 +162,23 @@ export default {
|
|
|
|
textStyle: {
|
|
|
|
textStyle: {
|
|
|
|
// 坐标文字颜色
|
|
|
|
// 坐标文字颜色
|
|
|
|
color: optionsSetup.colorX,
|
|
|
|
color: optionsSetup.colorX,
|
|
|
|
fontSize: optionsSetup.fontSizeX
|
|
|
|
fontSize: optionsSetup.fontSizeX,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
axisLine: {
|
|
|
|
axisLine: {
|
|
|
|
show: true,
|
|
|
|
show: true,
|
|
|
|
lineStyle: {
|
|
|
|
lineStyle: {
|
|
|
|
color: optionsSetup.lineColorX,
|
|
|
|
color: optionsSetup.lineColorX,
|
|
|
|
width: optionsSetup.lineWidthX,
|
|
|
|
width: optionsSetup.lineWidthX,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
splitLine: {
|
|
|
|
splitLine: {
|
|
|
|
show: optionsSetup.isShowSplitLineX,
|
|
|
|
show: optionsSetup.isShowSplitLineX,
|
|
|
|
lineStyle: {
|
|
|
|
lineStyle: {
|
|
|
|
color: optionsSetup.splitLineColorX,
|
|
|
|
color: optionsSetup.splitLineColorX,
|
|
|
|
width: optionsSetup.splitLineWidthX,
|
|
|
|
width: optionsSetup.splitLineWidthX,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.options.xAxis = xAxis;
|
|
|
|
this.options.xAxis = xAxis;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -181,7 +196,7 @@ export default {
|
|
|
|
name: optionsSetup.textNameY,
|
|
|
|
name: optionsSetup.textNameY,
|
|
|
|
nameTextStyle: {
|
|
|
|
nameTextStyle: {
|
|
|
|
color: optionsSetup.nameColorY,
|
|
|
|
color: optionsSetup.nameColorY,
|
|
|
|
fontSize: optionsSetup.nameFontSizeY
|
|
|
|
fontSize: optionsSetup.nameFontSizeY,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 轴反转
|
|
|
|
// 轴反转
|
|
|
|
inverse: optionsSetup.reversalY,
|
|
|
|
inverse: optionsSetup.reversalY,
|
|
|
@ -192,23 +207,23 @@ export default {
|
|
|
|
textStyle: {
|
|
|
|
textStyle: {
|
|
|
|
// 坐标文字颜色
|
|
|
|
// 坐标文字颜色
|
|
|
|
color: optionsSetup.colorY,
|
|
|
|
color: optionsSetup.colorY,
|
|
|
|
fontSize: optionsSetup.fontSizeY
|
|
|
|
fontSize: optionsSetup.fontSizeY,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
axisLine: {
|
|
|
|
axisLine: {
|
|
|
|
show: true,
|
|
|
|
show: true,
|
|
|
|
lineStyle: {
|
|
|
|
lineStyle: {
|
|
|
|
color: optionsSetup.lineColorY,
|
|
|
|
color: optionsSetup.lineColorY,
|
|
|
|
width: optionsSetup.lineWidthY,
|
|
|
|
width: optionsSetup.lineWidthY,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
splitLine: {
|
|
|
|
splitLine: {
|
|
|
|
show: optionsSetup.isShowSplitLineY,
|
|
|
|
show: optionsSetup.isShowSplitLineY,
|
|
|
|
lineStyle: {
|
|
|
|
lineStyle: {
|
|
|
|
color: optionsSetup.splitLineColorY,
|
|
|
|
color: optionsSetup.splitLineColorY,
|
|
|
|
width: optionsSetup.splitLineWidthY,
|
|
|
|
width: optionsSetup.splitLineWidthY,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.options.yAxis = yAxis;
|
|
|
|
this.options.yAxis = yAxis;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -220,14 +235,14 @@ export default {
|
|
|
|
if (optionsSetup.verticalShow) {
|
|
|
|
if (optionsSetup.verticalShow) {
|
|
|
|
series[0].label = {
|
|
|
|
series[0].label = {
|
|
|
|
show: optionsSetup.isShow,
|
|
|
|
show: optionsSetup.isShow,
|
|
|
|
position: 'right',
|
|
|
|
position: "right",
|
|
|
|
distance: optionsSetup.distance,
|
|
|
|
distance: optionsSetup.distance,
|
|
|
|
textStyle: {
|
|
|
|
textStyle: {
|
|
|
|
fontSize: optionsSetup.fontSize,
|
|
|
|
fontSize: optionsSetup.fontSize,
|
|
|
|
color: optionsSetup.subTextColor,
|
|
|
|
color: optionsSetup.subTextColor,
|
|
|
|
fontWeight: optionsSetup.fontWeight
|
|
|
|
fontWeight: optionsSetup.fontWeight,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
series[0].label = {
|
|
|
|
series[0].label = {
|
|
|
|
show: optionsSetup.isShow,
|
|
|
|
show: optionsSetup.isShow,
|
|
|
@ -235,8 +250,8 @@ export default {
|
|
|
|
distance: optionsSetup.distance,
|
|
|
|
distance: optionsSetup.distance,
|
|
|
|
fontSize: optionsSetup.fontSize,
|
|
|
|
fontSize: optionsSetup.fontSize,
|
|
|
|
color: optionsSetup.subTextColor,
|
|
|
|
color: optionsSetup.subTextColor,
|
|
|
|
fontWeight: optionsSetup.fontWeight
|
|
|
|
fontWeight: optionsSetup.fontWeight,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
series[0].barWidth = optionsSetup.maxWidth;
|
|
|
|
series[0].barWidth = optionsSetup.maxWidth;
|
|
|
@ -250,8 +265,8 @@ export default {
|
|
|
|
show: true,
|
|
|
|
show: true,
|
|
|
|
textStyle: {
|
|
|
|
textStyle: {
|
|
|
|
color: optionsSetup.tipsColor,
|
|
|
|
color: optionsSetup.tipsColor,
|
|
|
|
fontSize: optionsSetup.tipsFontSize
|
|
|
|
fontSize: optionsSetup.tipsFontSize,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.options.tooltip = tooltip;
|
|
|
|
this.options.tooltip = tooltip;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -263,7 +278,7 @@ export default {
|
|
|
|
right: optionsSetup.marginRight,
|
|
|
|
right: optionsSetup.marginRight,
|
|
|
|
bottom: optionsSetup.marginBottom,
|
|
|
|
bottom: optionsSetup.marginBottom,
|
|
|
|
top: optionsSetup.marginTop,
|
|
|
|
top: optionsSetup.marginTop,
|
|
|
|
containLabel: true
|
|
|
|
containLabel: true,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.options.grid = grid;
|
|
|
|
this.options.grid = grid;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -278,11 +293,11 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const itemStyle = {
|
|
|
|
const itemStyle = {
|
|
|
|
normal: {
|
|
|
|
normal: {
|
|
|
|
color: params => {
|
|
|
|
color: (params) => {
|
|
|
|
return arrColor[params.dataIndex];
|
|
|
|
return arrColor[params.dataIndex];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
barBorderRadius: optionsSetup.radius
|
|
|
|
barBorderRadius: optionsSetup.radius,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
for (const key in this.options.series) {
|
|
|
|
for (const key in this.options.series) {
|
|
|
|
if (this.options.series[key].type == "bar") {
|
|
|
|
if (this.options.series[key].type == "bar") {
|
|
|
@ -297,11 +312,7 @@ export default {
|
|
|
|
const optionsData = this.optionsData; // 数据类型 静态 or 动态
|
|
|
|
const optionsData = this.optionsData; // 数据类型 静态 or 动态
|
|
|
|
optionsData.dataType == "staticData"
|
|
|
|
optionsData.dataType == "staticData"
|
|
|
|
? this.staticDataFn(optionsData.staticData)
|
|
|
|
? this.staticDataFn(optionsData.staticData)
|
|
|
|
: this.dynamicDataFn(
|
|
|
|
: this.dynamicDataFn(optionsData.refreshTime);
|
|
|
|
optionsData.dynamicData,
|
|
|
|
|
|
|
|
optionsData.refreshTime,
|
|
|
|
|
|
|
|
optionsSetup
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 静态数据
|
|
|
|
// 静态数据
|
|
|
|
staticDataFn(val) {
|
|
|
|
staticDataFn(val) {
|
|
|
@ -311,7 +322,7 @@ export default {
|
|
|
|
let data = [];
|
|
|
|
let data = [];
|
|
|
|
for (const i in val) {
|
|
|
|
for (const i in val) {
|
|
|
|
axis[i] = val[i].axis;
|
|
|
|
axis[i] = val[i].axis;
|
|
|
|
data[i] = val[i].data
|
|
|
|
data[i] = val[i].data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// x轴
|
|
|
|
// x轴
|
|
|
|
if (optionsSetup.verticalShow) {
|
|
|
|
if (optionsSetup.verticalShow) {
|
|
|
@ -330,7 +341,10 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 动态数据
|
|
|
|
// 动态数据
|
|
|
|
dynamicDataFn(val, refreshTime, optionsSetup) {
|
|
|
|
dynamicDataFn(refreshTime) {
|
|
|
|
|
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
|
|
|
|
|
const optionsData = this.optionsData;
|
|
|
|
|
|
|
|
const val = optionsData.dynamicData;
|
|
|
|
if (!val) return;
|
|
|
|
if (!val) return;
|
|
|
|
if (this.ispreview) {
|
|
|
|
if (this.ispreview) {
|
|
|
|
this.getEchartData(val, optionsSetup);
|
|
|
|
this.getEchartData(val, optionsSetup);
|
|
|
@ -343,7 +357,7 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getEchartData(val, optionsSetup) {
|
|
|
|
getEchartData(val, optionsSetup) {
|
|
|
|
const data = this.queryEchartsData(val);
|
|
|
|
const data = this.queryEchartsData(val);
|
|
|
|
data.then(res => {
|
|
|
|
data.then((res) => {
|
|
|
|
this.renderingFn(optionsSetup, res);
|
|
|
|
this.renderingFn(optionsSetup, res);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -367,8 +381,8 @@ export default {
|
|
|
|
series[i].data = val.series[i].data;
|
|
|
|
series[i].data = val.series[i].data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|