百分比图支持动态数据

qianming 3 years ago
parent 57ea6700e4
commit 0756eb418c

@ -1048,7 +1048,11 @@ const widgetTools = [
name: 'dynamicAddTable', name: 'dynamicAddTable',
required: false, required: false,
placeholder: '', placeholder: '',
value: [{name: '日期', key: 'date', width: 200},{name: '姓名', key: 'name', width: 200}, {name: '地址', key: 'address', width: '200'}] value: [{name: '日期', key: 'date', width: 200}, {name: '姓名', key: 'name', width: 200}, {
name: '地址',
key: 'address',
width: '200'
}]
} }
], ],
data: [ data: [
@ -5444,6 +5448,59 @@ const widgetTools = [
} }
], ],
}, },
{
name: '圆环设置',
list: [
/* {
type: 'vue-color',
label: '0%处',
name: 'colorStart',
required: false,
placeholder: '',
value: '#4FADFD'
},
{
type: 'vue-color',
label: '100%处',
name: 'colorEnd',
required: false,
placeholder: '',
value: '#28E8FA'
},*/
{
type: 'el-input-number',
label: '刻度数量',
name: 'lineNumber',
required: false,
placeholder: '',
value: 8
},
{
type: 'el-input-number',
label: '刻度长度',
name: 'lineLength',
required: false,
placeholder: '',
value: 15
},
{
type: 'el-input-number',
label: '刻度宽度',
name: 'lineWidth',
required: false,
placeholder: '',
value: 5
},
{
type: 'vue-color',
label: '刻度颜色',
name: 'lineColor',
required: false,
placeholder: '',
value: '#061740'
},
]
},
/*{ /*{
name: '图例操作', name: '图例操作',
list: [ list: [

@ -266,13 +266,13 @@ export default {
center: ['50%', '50%'], center: ['50%', '50%'],
startAngle: 0, startAngle: 0,
endAngle: 359.9, endAngle: 359.9,
splitNumber: -1, splitNumber: 8,
hoverAnimation: true, hoverAnimation: true,
axisTick: { axisTick: {
show: false, show: false,
}, },
splitLine: { splitLine: {
length: 60, length: 15,
lineStyle: { lineStyle: {
width: 5, width: 5,
color: '#061740', color: '#061740',
@ -291,9 +291,6 @@ export default {
}, },
detail: { detail: {
show: false, show: false,
textStyle: {
fontSize: 12
}
}, },
data: [], data: [],
}, },
@ -338,9 +335,9 @@ export default {
}, },
mounted() { mounted() {
/* setInterval(() => { /* setInterval(() => {
//this.angle = this.angle + 3 this.angle = this.angle + 3
//myChart.setOption(option,true) myChart.setOption(option,true)
}, 100);*/ }, 1000);*/
}, },
methods: { methods: {
//point //point
@ -358,6 +355,7 @@ export default {
//this.setOptionsLegend(); //this.setOptionsLegend();
//this.setOptionsColor(); //this.setOptionsColor();
this.setOptionsData(); this.setOptionsData();
this.setOptionLine();
}, },
setOptionsTitle() { setOptionsTitle() {
const optionsCollapse = this.optionsSetup; const optionsCollapse = this.optionsSetup;
@ -392,7 +390,9 @@ export default {
} }
} }
}, },
setOptionPer(val) { //0-100%
/*setOptionPerData(val) {
const optionsSetup = this.optionsSetup;
const data = this.options.series[6]['data']; const data = this.options.series[6]['data'];
data.forEach((ev, index) => { data.forEach((ev, index) => {
if (index == 0) { if (index == 0) {
@ -403,11 +403,11 @@ export default {
colorStops: [ colorStops: [
{ {
offset: 0, offset: 0,
color: '#4FADFD', // 0% color: optionsSetup.colorStart, // 0%
}, },
{ {
offset: 1, offset: 1,
color: '#28E8FA', // 100% color: optionsSetup.colorEnd, // 100%
}, },
] ]
} }
@ -422,15 +422,28 @@ export default {
}, },
}; };
const itemStyle = { const itemStyle = {
normal: { /!*normal: {
color: '#173164', color: '#173164',
}, },*!/
}; };
data['label'] = label; data['label'] = label;
data['itemStyle'] = itemStyle; data['itemStyle'] = itemStyle;
}else{}; } else {
}
;
}) })
console.log(data) },*/
setOptionLine() {
const optionsSetup = this.optionsSetup;
const line = this.options.series[7]['splitLine'];
const num = this.options.series[7];
num.splitNumber = optionsSetup.lineNumber;
line.length = optionsSetup.lineLength;
const lineStyle = {
width: optionsSetup.lineWidth,
color: optionsSetup.lineColor,
};
line['lineStyle'] = lineStyle
}, },
// //
setOptionsData() { setOptionsData() {
@ -445,7 +458,7 @@ export default {
staticDataFn(val) { staticDataFn(val) {
const title = this.options.title; const title = this.options.title;
title.text = '{nums|' + val + '}{percent|%}'; title.text = '{nums|' + val + '}{percent|%}';
this.setOptionPer(val) //this.setOptionPerData(val)
}, },
dynamicDataFn(val, refreshTime) { dynamicDataFn(val, refreshTime) {
if (!val) return; if (!val) return;
@ -461,8 +474,9 @@ export default {
getEchartData(val) { getEchartData(val) {
const data = this.queryEchartsData(val); const data = this.queryEchartsData(val);
data.then(res => { data.then(res => {
this.styleColor.text = res[0].value this.options.title.text = '{nums|' + res[0].value + '}{percent|%}'
this.$forceUpdate(); //this.$forceUpdate();
console.log(res[0].value)
}); });
} }
} }

Loading…
Cancel
Save