echarts 表数据

qianlishi 3 years ago
parent 17517b162a
commit 155546a91c

@ -1,104 +1,120 @@
<template> <template>
<div :style="styleObj"> <div :style="styleObj">
<v-chart :options="options" <v-chart :options="options" autoresize />
autoresize />
</div> </div>
</template> </template>
<script> <script>
import echarts from 'echarts'; import echarts from "echarts";
export default { export default {
name: 'WidgetGradientColorBarchart', //https://www.makeapie.com/editor.html?c=x0oZWoncE name: "WidgetGradientColorBarchart", //https://www.makeapie.com/editor.html?c=x0oZWoncE
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data () { data() {
return { return {
options: { options: {
// backgroundColor: '#00265f', // backgroundColor: '#00265f',
"title": { title: {
"text": "政策补贴额度", text: "政策补贴额度",
x: "center", x: "center",
y: "4%", y: "4%",
textStyle: { textStyle: {
color: '#fff', color: "#fff",
fontSize: '22' fontSize: "22"
}, },
subtextStyle: { subtextStyle: {
color: '#90979c', color: "#90979c",
fontSize: '16', fontSize: "16"
}
},
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: "axis",
axisPointer: { axisPointer: {
type: 'shadow' type: "shadow"
} }
}, },
grid: { grid: {
top: '15%', top: "15%",
right: '3%', right: "3%",
left: '5%', left: "5%",
bottom: '12%' bottom: "12%"
}, },
legend: { legend: {
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
data: ['制造业', '建筑业', '农林牧渔', '房地产', '金融业', '居民服务及其他'], data: [
"制造业",
"建筑业",
"农林牧渔",
"房地产",
"金融业",
"居民服务及其他"
],
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: 'rgba(255,255,255,0.12)' color: "rgba(255,255,255,0.12)"
} }
}, },
axisLabel: { axisLabel: {
margin: 10, margin: 10,
color: '#e2e9ff', color: "#e2e9ff",
textStyle: { textStyle: {
fontSize: 14 fontSize: 14
}, }
}, }
}, },
yAxis: { yAxis: {
name: '单位:万元', name: "单位:万元",
axisLabel: { axisLabel: {
formatter: '{value}', formatter: "{value}",
color: '#e2e9ff', color: "#e2e9ff"
}, },
axisLine: { axisLine: {
show: false, show: false,
lineStyle: { lineStyle: {
color: 'rgba(255,255,255,0)' color: "rgba(255,255,255,0)"
} }
}, },
splitLine: { splitLine: {
lineStyle: { lineStyle: {
color: 'rgba(255,255,255,0.12)' color: "rgba(255,255,255,0.12)"
} }
} }
}, },
series: [{ series: [
type: 'bar', {
type: "bar",
data: [5000, 2600, 1300, 1300, 1250, 1500], data: [5000, 2600, 1300, 1300, 1250, 1500],
barWidth: '20px', barWidth: "20px",
itemStyle: { itemStyle: {
normal: { normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0, offset: 0,
color: 'rgba(0,244,255,1)' // 0% color: "rgba(0,244,255,1)" // 0%
}, { },
{
offset: 1, offset: 1,
color: 'rgba(0,77,167,1)' // 100% color: "rgba(0,77,167,1)" // 100%
}], false), }
],
false
),
barBorderRadius: [30, 30, 30, 30], barBorderRadius: [30, 30, 30, 30],
shadowColor: 'rgba(0,160,221,1)', shadowColor: "rgba(0,160,221,1)",
shadowBlur: 4, shadowBlur: 4
} }
}, },
label: { label: {
@ -107,116 +123,115 @@ export default {
lineHeight: 30, lineHeight: 30,
width: 80, width: 80,
height: 30, height: 30,
backgroundColor: 'rgba(0,160,221,0.1)', backgroundColor: "rgba(0,160,221,0.1)",
borderRadius: 200, borderRadius: 200,
position: ['-8', '-60'], position: ["-8", "-60"],
distance: 1, distance: 1,
formatter: [ formatter: [" {d|●}", " {a|{c}} \n", " {b|}"].join(
' {d|●}', ","
' {a|{c}} \n', ),
' {b|}'
].join(','),
rich: { rich: {
d: { d: {
color: '#3CDDCF', color: "#3CDDCF"
}, },
a: { a: {
color: '#fff', color: "#fff",
align: 'center', align: "center"
}, },
b: { b: {
width: 1, width: 1,
height: 30, height: 30,
borderWidth: 1, borderWidth: 1,
borderColor: '#234e6c', borderColor: "#234e6c",
align: 'left' align: "left"
}, }
} }
} }
} }
}] }
]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj () { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
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: {
handler (val) { handler(val) {
console.log(val) console.log(val);
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.setup this.optionsCollapse = val.setup;
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;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.setup this.optionsCollapse = this.value.setup;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions () { editorOptions() {
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsX() this.setOptionsX();
this.setOptionsY() this.setOptionsY();
// this.setOptionsTop() // this.setOptionsTop()
// this.setOptionsTooltip() // this.setOptionsTooltip()
this.setOptionsMargin() this.setOptionsMargin();
// this.setOptionsLegend() // this.setOptionsLegend()
this.setOptionsColor() this.setOptionsColor();
this.setOptionsData() this.setOptionsData();
}, },
// //
setOptionsTitle () { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// X // X
setOptionsX () { setOptionsX() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const xAxis = { const xAxis = {
type: 'category', type: "category",
show: optionsCollapse.hideX, // show: optionsCollapse.hideX, //
name: optionsCollapse.xName, // name: optionsCollapse.xName, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.xNameColor, color: optionsCollapse.xNameColor,
fontSize: optionsCollapse.xNameFontSize, fontSize: optionsCollapse.xNameFontSize
}, },
nameRotate: optionsCollapse.textAngle, // nameRotate: optionsCollapse.textAngle, //
inverse: optionsCollapse.reversalX, // inverse: optionsCollapse.reversalX, //
@ -226,194 +241,213 @@ export default {
rotate: optionsCollapse.textAngle, // rotate: optionsCollapse.textAngle, //
textStyle: { textStyle: {
color: optionsCollapse.Xcolor, // x color: optionsCollapse.Xcolor, // x
fontSize: optionsCollapse.fontSizeX, fontSize: optionsCollapse.fontSizeX
}, }
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.lineColorX, color: optionsCollapse.lineColorX
}, }
}, },
splitLine: { splitLine: {
show: optionsCollapse.isShowSplitLineX, show: optionsCollapse.isShowSplitLineX,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorX color: optionsCollapse.splitLineColorX
},
},
} }
this.options.xAxis = xAxis }
};
this.options.xAxis = xAxis;
}, },
// Y // Y
setOptionsY () { setOptionsY() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const yAxis = { const yAxis = {
type: 'value', type: "value",
show: optionsCollapse.isShowY, // show: optionsCollapse.isShowY, //
name: optionsCollapse.textNameY, // name: optionsCollapse.textNameY, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.NameColorY, color: optionsCollapse.NameColorY,
fontSize: optionsCollapse.NameFontSizeY, fontSize: optionsCollapse.NameFontSizeY
}, },
inverse: optionsCollapse.reversalY, // inverse: optionsCollapse.reversalY, //
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.colorY, // x color: optionsCollapse.colorY, // x
fontSize: optionsCollapse.fontSizeY, fontSize: optionsCollapse.fontSizeY
}, }
}, },
splitLine: { splitLine: {
show: false, show: false
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.lineColorY, color: optionsCollapse.lineColorY
}, }
}, },
splitLine: { splitLine: {
show: optionsCollapse.isShowSplitLineY, show: optionsCollapse.isShowSplitLineY,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorY color: optionsCollapse.splitLineColorY
},
},
} }
}
};
this.options.yAxis = yAxis this.options.yAxis = yAxis;
}, },
// or // or
setOptionsTop () { setOptionsTop() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'bar') { if (series[key].type == "bar") {
series[key].label = { series[key].label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
position: 'top', position: "top",
distance: 10, distance: 10,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
};
series[key].barWidth = optionsCollapse.maxWidth;
series[key].barMinHeight = optionsCollapse.minHeight;
} }
series[key].barWidth = optionsCollapse.maxWidth
series[key].barMinHeight = optionsCollapse.minHeight
} }
} this.options.series = series;
this.options.series = series
}, },
// tooltip // tooltip
setOptionsTooltip () { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
},
} }
this.options.tooltip = tooltip };
this.options.tooltip = tooltip;
}, },
// //
setOptionsMargin () { setOptionsMargin() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const grid = { const grid = {
left: optionsCollapse.marginLeft, left: optionsCollapse.marginLeft,
right: optionsCollapse.marginRight, right: optionsCollapse.marginRight,
bottom: optionsCollapse.marginBottom, bottom: optionsCollapse.marginBottom,
top: optionsCollapse.marginTop, top: optionsCollapse.marginTop,
containLabel: true, containLabel: true
} };
this.options.grid = grid this.options.grid = grid;
}, },
// legend // legend
setOptionsLegend () { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor () { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const barStart = {} const barStart = {};
barStart['offset'] = 0 barStart["offset"] = 0;
barStart['color'] = optionsCollapse.barStart barStart["color"] = optionsCollapse.barStart;
const barEnd = {} const barEnd = {};
barStart['offset'] = 1 barStart["offset"] = 1;
barStart['color'] = optionsCollapse.barEnd barStart["color"] = optionsCollapse.barEnd;
// this.options.series[0].itemStyle.normal.color = new echarts.graphic.LinearGradient(0, 0, 0, 1,[ barStart, barEnd], false) // this.options.series[0].itemStyle.normal.color = new echarts.graphic.LinearGradient(0, 0, 0, 1,[ barStart, barEnd], false)
}, },
// //
setOptionsData () { setOptionsData() {
const optionsSetup = this.optionsSetup const optionsSetup = this.optionsSetup;
console.log(optionsSetup) const optionsData = this.optionsData; // or
const optionsData = this.optionsData // or optionsData.dataType == "staticData"
console.log(optionsData) ? this.staticDataFn(optionsData.staticData, optionsSetup)
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData, optionsSetup) : this.dynamicDataFn(optionsData.dynamicData, optionsSetup) : this.dynamicDataFn(
optionsData.dynamicData,
optionsData.refreshTime,
optionsSetup
);
}, },
// //
staticDataFn (val, optionsSetup) { staticDataFn(val, optionsSetup) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
// x // x
if (optionsSetup.verticalShow) { if (optionsSetup.verticalShow) {
this.options.xAxis.data = [] this.options.xAxis.data = [];
this.options.yAxis.data = staticData.categories this.options.yAxis.data = staticData.categories;
this.options.xAxis.type = 'value' this.options.xAxis.type = "value";
this.options.yAxis.type = 'category' this.options.yAxis.type = "category";
} else { } else {
this.options.xAxis.data = staticData.categories this.options.xAxis.data = staticData.categories;
this.options.yAxis.data = [] this.options.yAxis.data = [];
this.options.xAxis.type = 'category' this.options.xAxis.type = "category";
this.options.yAxis.type = 'value' this.options.yAxis.type = "value";
} }
// series // series
const series = this.options.series const series = this.options.series;
for (const i in series) { for (const i in series) {
if (series[i].type == 'bar') { if (series[i].type == "bar") {
series[i].data = staticData.series[0].data series[i].data = staticData.series[0].data;
} }
} }
}, },
// //
dynamicDataFn (val, optionsSetup) { dynamicDataFn(val, refreshTime, optionsSetup) {
console.log(val) if (!val) return;
if (!val) return if (this.ispreview) {
this.getEchartData(val, optionsSetup);
this.flagInter = setInterval(() => {
this.getEchartData(val, optionsSetup);
}, refreshTime);
} else {
this.getEchartData(val, optionsSetup);
}
},
getEchartData(val, optionsSetup) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(optionsSetup, res);
});
},
renderingFn(optionsSetup, val) {
// x // x
if (optionsSetup.verticalShow) { if (optionsSetup.verticalShow) {
this.options.xAxis.data = [] this.options.xAxis.data = [];
this.options.yAxis.data = val.xAxis this.options.yAxis.data = val.xAxis;
this.options.xAxis.type = 'value' this.options.xAxis.type = "value";
this.options.yAxis.type = 'category' this.options.yAxis.type = "category";
} else { } else {
this.options.xAxis.data = val.xAxis this.options.xAxis.data = val.xAxis;
this.options.yAxis.data = [] this.options.yAxis.data = [];
this.options.xAxis.type = 'category' this.options.xAxis.type = "category";
this.options.yAxis.type = 'value' this.options.yAxis.type = "value";
} }
// series // series
const series = this.options.series const series = this.options.series;
for (const i in series) { for (const i in series) {
if (series[i].type == 'bar') { if (series[i].type == "bar") {
series[i].data = val.series[i].data series[i].data = val.series[i].data;
} }
} }
}, }
}, }
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -1,179 +1,178 @@
<template> <template>
<div :style="styleObj"> <div :style="styleObj">
<v-chart :options="options" <v-chart :options="options" autoresize />
autoresize />
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'WidgetBarlinechart', name: "WidgetBarlinechart",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data () { data() {
return { return {
options: { options: {
color: [], color: [],
grid: {}, grid: {},
title: { title: {
text: '', text: "",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
tooltip: { tooltip: {
trigger: 'item', trigger: "item",
formatter: '{a} <br/>{b} : {c}%', formatter: "{a} <br/>{b} : {c}%"
}, },
legend: { legend: {
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, },
data: ['货运量', '货运总量'], data: ["货运量", "货运总量"]
}, },
xAxis: [ xAxis: [
{ {
type: 'category', type: "category",
data: [], data: [],
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, }
}, }
], ],
yAxis: [ yAxis: [
{ {
type: 'value', type: "value",
name: '', name: "",
min: 0, min: 0,
max: 250, max: 250,
interval: 50, interval: 50,
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, }
}, },
{ {
type: 'value', type: "value",
name: '', name: "",
min: 0, min: 0,
max: 25, max: 25,
interval: 5, interval: 5,
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, }
}, }
], ],
series: [ series: [
{ {
name: '', name: "",
type: 'bar', type: "bar",
data: [], data: [],
itemStyle: { itemStyle: {
barBorderRadius: null, barBorderRadius: null
}, }
}, },
{ {
name: '', name: "",
type: 'line', type: "line",
yAxisIndex: 1, yAxisIndex: 1,
data: [], data: [],
itemStyle: {}, itemStyle: {}
}, }
], ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj () { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
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: {
handler (val) { handler(val) {
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.collapse this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
}, },
deep: true, deep: true
}, }
}, },
created () { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions () { editorOptions() {
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsX() this.setOptionsX();
this.setOptionsY() this.setOptionsY();
this.setOptionsTop() this.setOptionsTop();
this.setOptionsBar() this.setOptionsBar();
this.setOptionsTooltip() this.setOptionsTooltip();
this.setOptionsData() this.setOptionsData();
this.setOptionsMargin() this.setOptionsMargin();
this.setOptionsLegend() this.setOptionsLegend();
this.setOptionsColor() this.setOptionsColor();
}, },
// //
setOptionsTitle () { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// X // X
setOptionsX () { setOptionsX() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const xAxis = { const xAxis = {
type: 'category', type: "category",
show: optionsCollapse.hideX, // show: optionsCollapse.hideX, //
name: optionsCollapse.xName, // name: optionsCollapse.xName, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.xNameColor, color: optionsCollapse.xNameColor,
fontSize: optionsCollapse.xNameFontSize, fontSize: optionsCollapse.xNameFontSize
}, },
nameRotate: optionsCollapse.textAngle, // nameRotate: optionsCollapse.textAngle, //
inverse: optionsCollapse.reversalX, // inverse: optionsCollapse.reversalX, //
@ -183,238 +182,257 @@ export default {
rotate: optionsCollapse.textAngle, // rotate: optionsCollapse.textAngle, //
textStyle: { textStyle: {
color: optionsCollapse.Xcolor, // x color: optionsCollapse.Xcolor, // x
fontSize: optionsCollapse.fontSizeX, fontSize: optionsCollapse.fontSizeX
}, }
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.lineColorX, color: optionsCollapse.lineColorX
}, }
}, },
splitLine: { splitLine: {
show: optionsCollapse.isShowSplitLineX, show: optionsCollapse.isShowSplitLineX,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorX color: optionsCollapse.splitLineColorX
},
},
} }
this.options.xAxis = xAxis }
};
this.options.xAxis = xAxis;
}, },
// Y // Y
setOptionsY () { setOptionsY() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const yAxis = [ const yAxis = [
{ {
type: 'value', type: "value",
show: optionsCollapse.isShowY, // show: optionsCollapse.isShowY, //
name: optionsCollapse.textNameY, // name: optionsCollapse.textNameY, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.NameColorY, color: optionsCollapse.NameColorY,
fontSize: optionsCollapse.NameFontSizeY, fontSize: optionsCollapse.NameFontSizeY
}, },
inverse: optionsCollapse.reversalY, // inverse: optionsCollapse.reversalY, //
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.colorY, // x color: optionsCollapse.colorY, // x
fontSize: optionsCollapse.fontSizeY, fontSize: optionsCollapse.fontSizeY
}, }
}, },
splitLine: { splitLine: {
show: false, show: false
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: '#fff', color: "#fff"
}, }
}, },
splitLine: { splitLine: {
show: optionsCollapse.isShowSplitLineY, show: optionsCollapse.isShowSplitLineY,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorY color: optionsCollapse.splitLineColorY
}, }
}, }
}, },
{ {
type: 'value', type: "value",
show: optionsCollapse.isShowY, // show: optionsCollapse.isShowY, //
name: optionsCollapse.textNameY, // name: optionsCollapse.textNameY, //
nameTextStyle: { nameTextStyle: {
color: optionsCollapse.NameColorY, color: optionsCollapse.NameColorY,
fontSize: optionsCollapse.NameFontSizeY, fontSize: optionsCollapse.NameFontSizeY
}, },
inverse: optionsCollapse.reversalY, // inverse: optionsCollapse.reversalY, //
axisLabel: { axisLabel: {
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.colorY, // x color: optionsCollapse.colorY, // x
fontSize: optionsCollapse.fontSizeY, fontSize: optionsCollapse.fontSizeY
}, }
}, },
splitLine: { splitLine: {
show: false, show: false
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.lineColorY, color: optionsCollapse.lineColorY
}, }
}, },
splitLine: { splitLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: optionsCollapse.splitLineColorY color: optionsCollapse.splitLineColorY
}, }
}, }
}, }
] ];
this.options.yAxis = yAxis this.options.yAxis = yAxis;
}, },
// 线 // 线
setOptionsTop () { setOptionsTop() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'line') { if (series[key].type == "line") {
series[key].showSymbol = optionsCollapse.markPoint series[key].showSymbol = optionsCollapse.markPoint;
series[key].symbolSize = optionsCollapse.pointSize series[key].symbolSize = optionsCollapse.pointSize;
series[key].smooth = optionsCollapse.smoothCurve series[key].smooth = optionsCollapse.smoothCurve;
if (optionsCollapse.area) { if (optionsCollapse.area) {
series[key].areaStyle = { series[key].areaStyle = {
opacity: optionsCollapse.areaThickness / 100, opacity: optionsCollapse.areaThickness / 100
} };
} else { } else {
series[key].areaStyle = { series[key].areaStyle = {
opacity: 0, opacity: 0
} };
} }
series[key].lineStyle = { series[key].lineStyle = {
width: optionsCollapse.lineWidth, width: optionsCollapse.lineWidth
} };
series[key].itemStyle.borderRadius = optionsCollapse.radius series[key].itemStyle.borderRadius = optionsCollapse.radius;
series[key].label = { series[key].label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
position: 'top', position: "top",
distance: 10, distance: 10,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
} };
} }
} }
this.options.series = series this.options.series = series;
}, },
setOptionsBar () { setOptionsBar() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'bar') { if (series[key].type == "bar") {
series[key].label = { series[key].label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
position: 'top', position: "top",
distance: 10, distance: 10,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
} };
series[key].barWidth = optionsCollapse.maxWidth series[key].barWidth = optionsCollapse.maxWidth;
series[key].barMinHeight = optionsCollapse.minHeight series[key].barMinHeight = optionsCollapse.minHeight;
series[key].itemStyle.barBorderRadius = optionsCollapse.radius series[key].itemStyle.barBorderRadius = optionsCollapse.radius;
} }
} }
this.options.series = series this.options.series = series;
}, },
// tooltip // tooltip
setOptionsTooltip () { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
},
} }
this.options.tooltip = tooltip };
this.options.tooltip = tooltip;
}, },
// //
setOptionsMargin () { setOptionsMargin() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const grid = { const grid = {
left: optionsCollapse.marginLeft, left: optionsCollapse.marginLeft,
right: optionsCollapse.marginRight, right: optionsCollapse.marginRight,
bottom: optionsCollapse.marginBottom, bottom: optionsCollapse.marginBottom,
top: optionsCollapse.marginTop, top: optionsCollapse.marginTop,
containLabel: true, containLabel: true
} };
this.options.grid = grid this.options.grid = grid;
}, },
// legend // legend
setOptionsLegend () { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor () { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor const customColor = optionsCollapse.customColor;
if (!customColor) return if (!customColor) return;
const arrColor = [] const arrColor = [];
for (let i = 0; i < customColor.length; i++) { for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color) arrColor.push(customColor[i].color);
} }
this.options.color = arrColor this.options.color = arrColor;
this.options = Object.assign({}, this.options) this.options = Object.assign({}, this.options);
}, },
// //
setOptionsData () { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) console.log(optionsData);
}, optionsData.dataType == "staticData"
staticDataFn (val) { ? this.staticDataFn(optionsData.staticData)
const staticData = JSON.parse(val) : this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
},
staticDataFn(val) {
const staticData = JSON.parse(val);
// x // x
this.options.xAxis.data = staticData.xAxis this.options.xAxis.data = staticData.xAxis;
// series // series
const series = this.options.series const series = this.options.series;
for (const i in series) { for (const i in series) {
for (const j in staticData.series) { for (const j in staticData.series) {
if (series[i].type == staticData.series[j].type) { if (series[i].type == staticData.series[j].type) {
series[i].data = staticData.series[j].data series[i].data = staticData.series[j].data;
} }
} }
} }
}, },
dynamicDataFn (val) { dynamicDataFn(val, refreshTime) {
if (!val) return if (!val) return;
// x if (this.ispreview) {
this.options.xAxis.data = val.xAxis this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
}
},
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
this.options.xAxis.data = val.xAxis;
// series // series
const series = this.options.series const series = this.options.series;
for (const i in series) { for (const i in series) {
for (const j in val.series) { for (const j in val.series) {
if (series[i].type == val.series[j].type) { if (series[i].type == val.series[j].type) {
series[i].data = val.series[j].data series[i].data = val.series[j].data;
} }
} }
} }
}, }
}, }
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -6,218 +6,239 @@
<script> <script>
export default { export default {
name: 'WidgetFunnel', name: "WidgetFunnel",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data() { data() {
return { return {
options: { options: {
color: [], color: [],
title: { title: {
text: '', text: "",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
tooltip: { tooltip: {
trigger: 'item', trigger: "item",
formatter: '{a} <br/>{b} : {c}%', formatter: "{a} <br/>{b} : {c}%"
}, },
legend: { legend: {
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
series: [ series: [
{ {
name: '', name: "",
type: 'funnel', type: "funnel",
left: '10%', left: "10%",
top: 60, top: 60,
// x2: 80, // x2: 80,
bottom: 60, bottom: 60,
width: '80%', width: "80%",
// height: {totalHeight} - y - y2, // height: {totalHeight} - y - y2,
min: 0, min: 0,
max: 100, max: 100,
minSize: '0%', minSize: "0%",
maxSize: '100%', maxSize: "100%",
sort: 'descending', sort: "descending",
gap: 2, gap: 2,
label: { label: {
show: true, show: true,
position: 'inside', position: "inside"
}, },
labelLine: { labelLine: {
length: 10, length: 10,
lineStyle: { lineStyle: {
width: 1, width: 1,
type: 'solid', type: "solid"
}, }
}, },
itemStyle: { itemStyle: {
borderColor: '#fff', borderColor: "#fff",
borderWidth: 1, borderWidth: 1
}, },
emphasis: { emphasis: {
label: { label: {
fontSize: 20, fontSize: 20
}, }
},
data: [],
}, },
], data: []
}
]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj() { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
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: {
handler(val) { handler(val) {
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.collapse this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
},
deep: true,
}, },
deep: true
}
}, },
created() { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions() { editorOptions() {
this.setOptionsText() this.setOptionsText();
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsTooltip() this.setOptionsTooltip();
this.setOptionsLegend() this.setOptionsLegend();
this.setOptionsColor() this.setOptionsColor();
this.setOptionsData() this.setOptionsData();
}, },
// //
setOptionsText() { setOptionsText() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'funnel') { if (series[key].type == "funnel") {
series[key].label.show = optionsCollapse.isShow series[key].label.show = optionsCollapse.isShow;
series[key].label.fontSize = optionsCollapse.fontSize series[key].label.fontSize = optionsCollapse.fontSize;
series[key].label.color = optionsCollapse.color series[key].label.color = optionsCollapse.color;
series[key].label.fontWeight = optionsCollapse.fontWeight series[key].label.fontWeight = optionsCollapse.fontWeight;
series[key].sort = optionsCollapse.reversal ? 'ascending' : 'descending' series[key].sort = optionsCollapse.reversal
? "ascending"
: "descending";
} }
} }
}, },
// //
setOptionsTitle() { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// tooltip // tooltip
setOptionsTooltip() { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
},
} }
this.options.tooltip = tooltip };
this.options.tooltip = tooltip;
}, },
// legend // legend
setOptionsLegend() { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor() { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor const customColor = optionsCollapse.customColor;
if (!customColor) return if (!customColor) return;
const arrColor = [] const arrColor = [];
for (let i = 0; i < customColor.length; i++) { for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color) arrColor.push(customColor[i].color);
} }
this.options.color = arrColor this.options.color = arrColor;
this.options = Object.assign({}, this.options) this.options = Object.assign({}, this.options);
}, },
setOptionsData() { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'funnel') { if (this.options.series[key].type == "funnel") {
this.options.series[key].data = staticData this.options.series[key].data = staticData;
} }
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val, refreshTime) {
if (!val) return if (!val) return;
for (const key in this.options.series) { if (this.ispreview) {
if (this.options.series[key].type == 'funnel') { this.getEchartData(val);
this.options.series[key].data = val this.flagInter = setInterval(() => {
} this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
} }
}, },
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
}, },
} renderingFn(val) {
for (const key in this.options.series) {
if (this.options.series[key].type == "funnel") {
this.options.series[key].data = val;
}
}
}
}
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -6,128 +6,148 @@
<script> <script>
export default { export default {
name: 'WidgetGauge', name: "WidgetGauge",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data() { data() {
return { return {
options: { options: {
series: [ series: [
{ {
name: 'Pressure', name: "Pressure",
type: 'gauge', type: "gauge",
detail: { detail: {
formatter: '{value}', formatter: "{value}",
textStyle: { textStyle: {
fontSize: 12, fontSize: 12
}, }
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
width: 10, width: 10
}, }
}, },
axisLabel: { axisLabel: {
show: true, show: true,
fontSize: 12, fontSize: 12
}, },
axisTick: { axisTick: {
show: true, show: true
}, },
data: [ data: [
{ {
value: 50, value: 50,
name: '', name: ""
}, }
], ]
}, }
], ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj() { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
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: {
handler(val) { handler(val) {
this.optionsStyle = val.position // this.optionsStyle = val.position; //
this.optionsData = val.data // this.optionsData = val.data; //
this.optionsCollapse = val.collapse // this.optionsCollapse = val.collapse; //
this.optionsSetup = val.setup // this.optionsSetup = val.setup; //
this.setOptions() this.setOptions();
this.setOptionsData() this.setOptionsData();
}, },
deep: true, deep: true
}, }
}, },
created() { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.setOptions() this.setOptions();
this.setOptionsData() this.setOptionsData();
}, },
methods: { methods: {
setOptions() { setOptions() {
const optionsSetup = this.optionsSetup const optionsSetup = this.optionsSetup;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
if (series[key].type == 'gauge') { if (series[key].type == "gauge") {
series[key].axisLine.lineStyle.width = optionsSetup.tickMarkWeight series[key].axisLine.lineStyle.width = optionsSetup.tickMarkWeight;
series[key].axisLabel.show = optionsSetup.showScaleValue series[key].axisLabel.show = optionsSetup.showScaleValue;
series[key].axisLabel.fontSize = optionsSetup.scaleFontSize series[key].axisLabel.fontSize = optionsSetup.scaleFontSize;
series[key].axisTick.show = optionsSetup.showTickMarks series[key].axisTick.show = optionsSetup.showTickMarks;
series[key].detail.textStyle.fontSize = optionsSetup.targetFontSize series[key].detail.textStyle.fontSize = optionsSetup.targetFontSize;
} }
} }
}, },
setOptionsData() { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) console.log(optionsData);
optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const unit = JSON.parse(val).unit const unit = JSON.parse(val).unit;
const series = this.options.series const series = this.options.series;
for (const key in series) { for (const key in series) {
series[key].detail.formatter = `{value}${unit}` series[key].detail.formatter = `{value}${unit}`;
series[key].data[0] = { series[key].data[0] = {
value: JSON.parse(val).value, value: JSON.parse(val).value,
name: JSON.parse(val).name, name: JSON.parse(val).name
};
} }
},
dynamicDataFn(val, refreshTime) {
console.log(val);
if (!val) return;
if (this.ispreview) {
this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
} }
}, },
dynamicDataFn(val) { getEchartData(val) {
if (!val) return const data = this.queryEchartsData(val);
const series = this.options.series data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
const series = this.options.series;
for (const key in series) { for (const key in series) {
series[key].detail.formatter = `{value}${val.unit}` series[key].detail.formatter = `{value}${val.unit}`;
series[key].data[0] = { series[key].data[0] = {
value: val.value, value: val.value,
name: val.name || '', name: val.name || ""
};
} }
} }
}, }
}, };
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -6,123 +6,123 @@
<script> <script>
export default { export default {
name: 'WidgetHollowPiechart', name: "WidgetHollowPiechart",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data() { data() {
return { return {
options: { options: {
color: [], color: [],
tooltip: { tooltip: {
trigger: 'item', trigger: "item"
}, },
legend: { legend: {
top: '5%', top: "5%",
left: 'center', left: "center",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
series: [ series: [
{ {
type: 'pie', type: "pie",
radius: ['40%', '70%'], radius: ["40%", "70%"],
avoidLabelOverlap: true, avoidLabelOverlap: true,
label: { label: {
show: false, show: false,
position: 'center', position: "center"
}, },
emphasis: { emphasis: {
label: { label: {
show: true, show: true,
fontSize: '40', fontSize: "40",
fontWeight: 'bold', fontWeight: "bold"
}, }
}, },
labelLine: { labelLine: {
show: true, show: true
},
data: [],
}, },
], data: []
}
]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj() { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
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: {
handler(val) { handler(val) {
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.collapse this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
},
deep: true,
}, },
deep: true
}
}, },
created() { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions() { editorOptions() {
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsValue() this.setOptionsValue();
this.setOptionsTooltip() this.setOptionsTooltip();
this.setOptionsLegend() this.setOptionsLegend();
this.setOptionsColor() this.setOptionsColor();
this.setOptionsData() this.setOptionsData();
}, },
// //
setOptionsTitle() { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// //
setOptionsValue() { setOptionsValue() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
const numberValue = optionsCollapse.numberValue ? '{c}' : '' const numberValue = optionsCollapse.numberValue ? "{c}" : "";
const percentage = optionsCollapse.percentage ? '({d})%' : '' const percentage = optionsCollapse.percentage ? "({d})%" : "";
const label = { const label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
formatter: `{a|{b}${numberValue} ${percentage}}`, formatter: `{a|{b}${numberValue} ${percentage}}`,
@ -131,83 +131,102 @@ export default {
padding: [-30, 15, -20, 15], padding: [-30, 15, -20, 15],
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
}, }
}, },
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.optionsCollapse, fontWeight: optionsCollapse.optionsCollapse
} };
for (const key in series) { for (const key in series) {
if (series[key].type == 'pie') { if (series[key].type == "pie") {
series[key].label = label series[key].label = label;
series[key].labelLine.show = optionsCollapse.isShow series[key].labelLine.show = optionsCollapse.isShow;
} }
} }
}, },
// tooltip // tooltip
setOptionsTooltip() { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
},
} }
this.options.tooltip = tooltip };
this.options.tooltip = tooltip;
}, },
// legend // legend
setOptionsLegend() { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor() { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor const customColor = optionsCollapse.customColor;
if (!customColor) return if (!customColor) return;
const arrColor = [] const arrColor = [];
for (let i = 0; i < customColor.length; i++) { for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color) arrColor.push(customColor[i].color);
} }
this.options.color = arrColor this.options.color = arrColor;
this.options = Object.assign({}, this.options) this.options = Object.assign({}, this.options);
}, },
setOptionsData() { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'pie') { if (this.options.series[key].type == "pie") {
this.options.series[key].data = staticData this.options.series[key].data = staticData;
} }
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val) {
if (!val) return if (!val) return;
for (const key in this.options.series) { if (this.ispreview) {
if (this.options.series[key].type == 'pie') { this.getEchartData(val);
this.options.series[key].data = val this.flagInter = setInterval(() => {
} this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
} }
}, },
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
}, },
} renderingFn(val) {
for (const key in this.options.series) {
if (this.options.series[key].type == "pie") {
this.options.series[key].data = val;
}
}
}
}
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

@ -298,7 +298,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(optionsData.dynamicData); : this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val); const staticData = JSON.parse(val);
@ -312,8 +312,24 @@ export default {
} }
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val, refreshTime) {
if (!val) return; if (!val) return;
if (this.ispreview) {
this.getEchartData(val);
this.flagInter = setInterval(() => {
this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
}
},
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
},
renderingFn(val) {
// x // x
this.options.xAxis.data = val.xAxis; this.options.xAxis.data = val.xAxis;
// series // series

@ -6,118 +6,118 @@
<script> <script>
export default { export default {
name: 'WidgetPiechart', name: "WidgetPiechart",
components: {}, components: {},
props: { props: {
value: Object, value: Object,
ispreview: Boolean, ispreview: Boolean
}, },
data() { data() {
return { return {
options: { options: {
title: { title: {
text: '某站点用户访问来源', text: "",
left: 'center', left: "center",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
legend: { legend: {
orient: 'vertical', orient: "vertical",
left: 'left', left: "left",
textStyle: { textStyle: {
color: '#fff', color: "#fff"
}, }
}, },
series: [ series: [
{ {
type: 'pie', type: "pie",
radius: '50%', radius: "50%",
data: [], data: [],
emphasis: { emphasis: {
itemStyle: { itemStyle: {
shadowBlur: 10, shadowBlur: 10,
shadowOffsetX: 0, shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)', shadowColor: "rgba(0, 0, 0, 0.5)"
}, }
}, }
}, }
], ]
}, },
optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}, optionsSetup: {}
} };
}, },
computed: { computed: {
styleObj() { styleObj() {
return { return {
position: this.ispreview ? 'absolute' : 'static', position: this.ispreview ? "absolute" : "static",
width: this.optionsStyle.width + 'px', width: this.optionsStyle.width + "px",
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: {
handler(val) { handler(val) {
this.optionsStyle = val.position this.optionsStyle = val.position;
this.optionsData = val.data this.optionsData = val.data;
this.optionsCollapse = val.collapse this.optionsCollapse = val.collapse;
this.optionsSetup = val.setup this.optionsSetup = val.setup;
this.editorOptions() this.editorOptions();
},
deep: true,
}, },
deep: true
}
}, },
created() { created() {
this.optionsStyle = this.value.position this.optionsStyle = this.value.position;
this.optionsData = this.value.data this.optionsData = this.value.data;
this.optionsCollapse = this.value.collapse this.optionsCollapse = this.value.collapse;
this.optionsSetup = this.value.setup this.optionsSetup = this.value.setup;
this.editorOptions() this.editorOptions();
}, },
methods: { methods: {
// options // options
editorOptions() { editorOptions() {
this.setOptionsTitle() this.setOptionsTitle();
this.setOptionsValue() this.setOptionsValue();
this.setOptionsTooltip() this.setOptionsTooltip();
this.setOptionsLegend() this.setOptionsLegend();
this.setOptionsColor() this.setOptionsColor();
this.setOptionsData() this.setOptionsData();
}, },
// //
setOptionsTitle() { setOptionsTitle() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const title = {} const title = {};
title.show = optionsCollapse.isNoTitle title.show = optionsCollapse.isNoTitle;
title.text = optionsCollapse.titleText title.text = optionsCollapse.titleText;
title.left = optionsCollapse.textAlign title.left = optionsCollapse.textAlign;
title.textStyle = { title.textStyle = {
color: optionsCollapse.textColor, color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize, fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight, fontWeight: optionsCollapse.textFontWeight
} };
title.subtext = optionsCollapse.subText title.subtext = optionsCollapse.subText;
title.subtextStyle = { title.subtextStyle = {
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontWeight: optionsCollapse.subTextFontWeight, fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize, fontSize: optionsCollapse.subTextFontSize
} };
this.options.title = title this.options.title = title;
}, },
// //
setOptionsValue() { setOptionsValue() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const series = this.options.series const series = this.options.series;
const numberValue = optionsCollapse.numberValue ? '{c}' : '' const numberValue = optionsCollapse.numberValue ? "{c}" : "";
const percentage = optionsCollapse.percentage ? '({d})%' : '' const percentage = optionsCollapse.percentage ? "({d})%" : "";
const label = { const label = {
show: optionsCollapse.isShow, show: optionsCollapse.isShow,
formatter: `{a|{b}${numberValue} ${percentage}}`, formatter: `{a|{b}${numberValue} ${percentage}}`,
@ -126,83 +126,102 @@ export default {
padding: [-30, 15, -20, 15], padding: [-30, 15, -20, 15],
color: optionsCollapse.subTextColor, color: optionsCollapse.subTextColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.fontWeight, fontWeight: optionsCollapse.fontWeight
}, }
}, },
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.optionsCollapse, fontWeight: optionsCollapse.optionsCollapse
} };
for (const key in series) { for (const key in series) {
if (series[key].type == 'pie') { if (series[key].type == "pie") {
series[key].label = label series[key].label = label;
series[key].labelLine = { show: optionsCollapse.isShow } series[key].labelLine = { show: optionsCollapse.isShow };
} }
} }
}, },
// tooltip // tooltip
setOptionsTooltip() { setOptionsTooltip() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const tooltip = { const tooltip = {
trigger: 'item', trigger: "item",
show: true, show: true,
textStyle: { textStyle: {
color: optionsCollapse.lineColor, color: optionsCollapse.lineColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
},
} }
this.options.tooltip = tooltip };
this.options.tooltip = tooltip;
}, },
// legend // legend
setOptionsLegend() { setOptionsLegend() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const legend = this.options.legend const legend = this.options.legend;
legend.show = optionsCollapse.isShowLegend legend.show = optionsCollapse.isShowLegend;
legend.left = optionsCollapse.lateralPosition == 'left' ? 0 : 'auto' legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto";
legend.right = optionsCollapse.lateralPosition == 'right' ? 0 : 'auto' legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto";
legend.top = optionsCollapse.longitudinalPosition == 'top' ? 0 : 'auto' legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom = optionsCollapse.longitudinalPosition == 'bottom' ? 0 : 'auto' legend.bottom =
legend.orient = optionsCollapse.layoutFront optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsCollapse.layoutFront;
legend.textStyle = { legend.textStyle = {
color: optionsCollapse.lengedColor, color: optionsCollapse.lengedColor,
fontSize: optionsCollapse.fontSize, fontSize: optionsCollapse.fontSize
} };
legend.itemWidth = optionsCollapse.lengedWidth legend.itemWidth = optionsCollapse.lengedWidth;
}, },
// //
setOptionsColor() { setOptionsColor() {
const optionsCollapse = this.optionsSetup const optionsCollapse = this.optionsSetup;
const customColor = optionsCollapse.customColor const customColor = optionsCollapse.customColor;
if (!customColor) return if (!customColor) return;
const arrColor = [] const arrColor = [];
for (let i = 0; i < customColor.length; i++) { for (let i = 0; i < customColor.length; i++) {
arrColor.push(customColor[i].color) arrColor.push(customColor[i].color);
} }
this.options.color = arrColor this.options.color = arrColor;
this.options = Object.assign({}, this.options) this.options = Object.assign({}, this.options);
}, },
setOptionsData() { setOptionsData() {
const optionsData = this.optionsData // or const optionsData = this.optionsData; // or
optionsData.dataType == 'staticData' ? this.staticDataFn(optionsData.staticData) : this.dynamicDataFn(optionsData.dynamicData) optionsData.dataType == "staticData"
? this.staticDataFn(optionsData.staticData)
: this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val) const staticData = JSON.parse(val);
for (const key in this.options.series) { for (const key in this.options.series) {
if (this.options.series[key].type == 'pie') { if (this.options.series[key].type == "pie") {
this.options.series[key].data = staticData this.options.series[key].data = staticData;
} }
} }
}, },
dynamicDataFn(val) { dynamicDataFn(val, refreshTime) {
if (!val) return if (!val) return;
for (const key in this.options.series) { if (this.ispreview) {
if (this.options.series[key].type == 'pie') { this.getEchartData(val);
this.options.series[key].data = val this.flagInter = setInterval(() => {
} this.getEchartData(val);
}, refreshTime);
} else {
this.getEchartData(val);
} }
}, },
getEchartData(val) {
const data = this.queryEchartsData(val);
data.then(res => {
this.renderingFn(res);
});
}, },
} renderingFn(val) {
for (const key in this.options.series) {
if (this.options.series[key].type == "pie") {
this.options.series[key].data = val;
}
}
}
}
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

Loading…
Cancel
Save