百分比图支持静态数据修改,样式调整

qianming 4 years ago
parent 49e6f8a8bb
commit 59cc4ed96a

@ -5324,7 +5324,7 @@ const widgetTools = [
name: 'isNoTitle', name: 'isNoTitle',
required: false, required: false,
placeholder: '', placeholder: '',
value: true value: true,
}, },
{ {
type: 'el-input-text', type: 'el-input-text',
@ -5332,7 +5332,7 @@ const widgetTools = [
name: 'titleText', name: 'titleText',
required: false, required: false,
placeholder: '', placeholder: '',
value: '' value: '',
}, },
{ {
type: 'vue-color', type: 'vue-color',
@ -5340,7 +5340,7 @@ const widgetTools = [
name: 'textColor', name: 'textColor',
required: false, required: false,
placeholder: '', placeholder: '',
value: '#fff' value: '#FFD700'
}, },
{ {
type: 'el-select', type: 'el-select',
@ -5375,28 +5375,33 @@ const widgetTools = [
{ code: 'left', name: '左对齐' }, { code: 'left', name: '左对齐' },
{ code: 'right', name: '右对齐' }, { code: 'right', name: '右对齐' },
], ],
value: 'left' value: 'center'
}, }
],
},
{
name: '数值设置',
list: [
{ {
type: 'el-input-text', type: 'vue-color',
label: '副标题', label: '数值颜色',
name: 'subText', name: 'textColor',
required: false, required: false,
placeholder: '', placeholder: '',
value: '' value: '#fff'
}, },
{ {
type: 'vue-color', type: 'el-input-number',
label: '字体颜色', label: '数值字体',
name: 'subTextColor', name: 'textFontSize',
required: false, required: false,
placeholder: '', placeholder: '',
value: '' value: 60
}, },
{ {
type: 'el-select', type: 'el-select',
label: '字体粗细', label: '字体粗细',
name: 'subTextFontWeight', name: 'textFontWeight',
required: false, required: false,
placeholder: '', placeholder: '',
selectOptions: [ selectOptions: [
@ -5408,62 +5413,25 @@ const widgetTools = [
value: 'normal' value: 'normal'
}, },
{ {
type: 'el-input-number', type: 'vue-color',
label: '字体大小', label: '%号颜色',
name: 'subTextFontSize', name: 'textPerColor',
required: false,
placeholder: '',
value: 12
},
],
},
/* {
name: '数值设定',
list: [
{
type: 'el-switch',
label: '显示',
name: 'isShow',
required: false, required: false,
placeholder: '', placeholder: '',
value: true, value: '#fff'
},
{
type: 'el-switch',
label: '数值',
name: 'numberValue',
require: false,
placeholder: '',
value: true,
},
{
type: 'el-switch',
label: '百分比',
name: 'percentage',
require: false,
placeholder: '',
value: false,
}, },
{ {
type: 'el-input-number', type: 'el-input-number',
label: '字体大小', label: '%号字体',
name: 'fontSize', name: 'textPerFontSize',
required: false, required: false,
placeholder: '', placeholder: '',
value: 14, value: 30
},
{
type: 'vue-color',
label: '字体颜色',
name: 'subTextColor',
required: false,
placeholder: '',
value: ''
}, },
{ {
type: 'el-select', type: 'el-select',
label: '字体粗细', label: '字体粗细',
name: 'fontWeight', name: 'textPerFontWeight',
required: false, required: false,
placeholder: '', placeholder: '',
selectOptions: [ selectOptions: [
@ -5473,28 +5441,7 @@ const widgetTools = [
{ code: 'lighter', name: '细体' } { code: 'lighter', name: '细体' }
], ],
value: 'normal' value: 'normal'
}, }
],
},*/
{
name: '提示语设置',
list: [
{
type: 'el-input-number',
label: '字体大小',
name: 'fontSize',
required: false,
placeholder: '',
value: 12
},
{
type: 'vue-color',
label: '网格线颜色',
name: 'lineColor',
required: false,
placeholder: '',
value: ''
},
], ],
}, },
{ {
@ -5570,18 +5517,6 @@ const widgetTools = [
}, },
], ],
}, },
/* {
name: '自定义配色',
list: [
{
type: 'customColor',
label: '',
name: 'customColor',
required: false,
value: [{ color: '#FF801C' }, { color: '#F5FF46' }, { color: '#00FE65' }, { color: '#00FEFF' }, { color: '#ffa800' }]
},
],
},*/
], ],
], ],
// 数据 // 数据
@ -5621,7 +5556,7 @@ const widgetTools = [
placeholder: 'px', placeholder: 'px',
relactiveDom: 'dataType', relactiveDom: 'dataType',
relactiveDomValue: 'staticData', relactiveDomValue: 'staticData',
value: '[{"value": 1048,"name": "搜索引擎"},{"value": 735, "name": "直接访问"},{"value": 580, "name": "邮件营销"},{"value": 484,"name":"联盟广告"},{"value":300,"name":"视频广告"}]', value: 60,
}, },
{ {
type: 'dycustComponents', type: 'dycustComponents',

@ -18,7 +18,7 @@ export default {
options: { options: {
//backgroundColor: '#061740', //backgroundColor: '#061740',
title: { title: {
text: '{nums|' + this.value2() + '}{percent|%}', text: '{nums|' + 60 + '}{percent|%}',
x: 'center', x: 'center',
y: 'center', y: 'center',
textStyle: { textStyle: {
@ -29,7 +29,7 @@ export default {
}, },
percent: { percent: {
fontSize: 30, fontSize: 30,
color: '#ffffff', color: '#29EEF3',
}, },
}, },
}, },
@ -183,7 +183,7 @@ export default {
data: [0], data: [0],
}, },
{ {
name: 'ring5', //绿 //name: 'ring5', //绿
type: 'custom', type: 'custom',
coordinateSystem: 'none', coordinateSystem: 'none',
renderItem: (params, api) => { renderItem: (params, api) => {
@ -223,7 +223,7 @@ export default {
}, },
data: [ data: [
{ {
value: this.value2(), value: 60,
name: '', name: '',
itemStyle: { itemStyle: {
normal: { normal: {
@ -244,7 +244,7 @@ export default {
}, },
}, },
{ {
value: 100 - this.value2(), value: 40,
name: '', name: '',
label: { label: {
normal: { normal: {
@ -260,13 +260,13 @@ export default {
], ],
}, },
{ {
name: '', name: 'percent',
type: 'gauge', type: 'gauge',
radius: '58%', radius: '58%',
center: ['50%', '50%'], center: ['50%', '50%'],
startAngle: 0, startAngle: 0,
endAngle: 359.9, endAngle: 359.9,
splitNumber: 8, splitNumber: -1,
hoverAnimation: true, hoverAnimation: true,
axisTick: { axisTick: {
show: false, show: false,
@ -291,20 +291,18 @@ export default {
}, },
detail: { detail: {
show: false, show: false,
textStyle: {
fontSize: 12
}
}, },
data: [ data: [],
{
value: 0,
name: '',
},
],
}, },
], ],
}, },
/* optionsStyle: {}, // optionsStyle: {}, //
optionsData: {}, // optionsData: {}, //
optionsCollapse: {}, // optionsCollapse: {}, //
optionsSetup: {}*/ optionsSetup: {}
}; };
}, },
computed: { computed: {
@ -339,22 +337,12 @@ export default {
this.editorOptions(); this.editorOptions();
}, },
mounted() { mounted() {
/* setInterval(() => { /* setInterval(() => {
//this.angle = this.angle + 3 //this.angle = this.angle + 3
//myChart.setOption(option,true) //myChart.setOption(option,true)
}, 100);*/ }, 100);*/
}, },
methods: { methods: {
// options
editorOptions() {
this.setOptionsTitle();
// this.setOptionsValue();
// this.setOptionsTooltip();
// this.setOptionsLegend();
// this.setOptionsColor();
// this.setOptionsData();
},
//point //point
getCirlPoint(x0, y0, r, x) { getCirlPoint(x0, y0, r, x) {
let x1 = x0 + r * Math.cos((x * Math.PI) / 180); let x1 = x0 + r * Math.cos((x * Math.PI) / 180);
@ -364,113 +352,98 @@ export default {
y: y1, y: y1,
}; };
}, },
value2(){ editorOptions() {
return 50; //this.setOptionsTitle();
//this.setOptionsTooltip();
//this.setOptionsLegend();
//this.setOptionsColor();
this.setOptionsData();
}, },
//
setOptionsTitle() { setOptionsTitle() {
const optionsCollapse = this.optionsSetup; const optionsCollapse = this.optionsSetup;
const title = {}; const title = this.options.title;
title.show = optionsCollapse.isNoTitle; title.x = "center";
title.text = optionsCollapse.titleText; title.y = "center";
title.left = optionsCollapse.textAlign; const rich = {
title.textStyle = { nums: {
color: optionsCollapse.textColor, fontSize: optionsCollapse.textFontSize,
fontSize: optionsCollapse.textFontSize, color: optionsCollapse.textColor
fontWeight: optionsCollapse.textFontWeight },
}; percent: {
title.subtext = optionsCollapse.subText; fontSize: optionsCollapse.textPerFontSize,
title.subtextStyle = { color: optionsCollapse.textPerColor
color: optionsCollapse.subTextColor, }
fontWeight: optionsCollapse.subTextFontWeight,
fontSize: optionsCollapse.subTextFontSize
}; };
title.textStyle['rich'] = rich;
this.options.title = title; this.options.title = title;
}, },
// setOptions() {
setOptionsValue() { const optionsSetup = this.optionsSetup;
const optionsCollapse = this.optionsSetup;
const series = this.options.series; const series = this.options.series;
const numberValue = optionsCollapse.numberValue ? "{c}" : "";
const percentage = optionsCollapse.percentage ? "({d})%" : "";
const label = {
show: optionsCollapse.isShow,
formatter: `{a|{b}${numberValue} ${percentage}}`,
rich: {
a: {
padding: [-30, 15, -20, 15],
color: optionsCollapse.subTextColor,
fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.fontWeight
}
},
fontSize: optionsCollapse.fontSize,
fontWeight: optionsCollapse.optionsCollapse
};
for (const key in series) { for (const key in series) {
if (series[key].type == "pie") { if (series[key].type == "gauge") {
series[key].label = label; series[key].axisLine.lineStyle.width = optionsSetup.tickMarkWeight;
series[key].labelLine = {show: optionsCollapse.isShow}; series[key].axisLabel.show = optionsSetup.showScaleValue;
series[key].axisLabel.fontSize = optionsSetup.scaleFontSize;
series[key].axisTick.show = optionsSetup.showTickMarks;
series[key].detail.textStyle.fontSize = optionsSetup.targetFontSize;
} }
} }
}, },
// tooltip setOptionPer(val) {
setOptionsTooltip() { const data = this.options.series[6]['data'];
const optionsCollapse = this.optionsSetup; data.forEach((ev, index) => {
const tooltip = { if (index == 0) {
trigger: "item", ev.value = val
show: true, const itemStyle = {
textStyle: { normal: {
color: optionsCollapse.lineColor, color: {
fontSize: optionsCollapse.fontSize colorStops: [
} {
}; offset: 0,
this.options.tooltip = tooltip; color: '#4FADFD', // 0%
}, },
// legend {
setOptionsLegend() { offset: 1,
const optionsCollapse = this.optionsSetup; color: '#28E8FA', // 100%
const legend = this.options.legend; },
legend.show = optionsCollapse.isShowLegend; ]
legend.left = optionsCollapse.lateralPosition == "left" ? 0 : "auto"; }
legend.right = optionsCollapse.lateralPosition == "right" ? 0 : "auto"; }
legend.top = optionsCollapse.longitudinalPosition == "top" ? 0 : "auto"; };
legend.bottom = data['itemStyle'] = itemStyle
optionsCollapse.longitudinalPosition == "bottom" ? 0 : "auto"; } else if (index == 1){
legend.orient = optionsCollapse.layoutFront; ev.value = (100 - val)
legend.textStyle = { const label = {
color: optionsCollapse.lengedColor, normal: {
fontSize: optionsCollapse.fontSize show: false,
}; },
legend.itemWidth = optionsCollapse.lengedWidth; };
}, const itemStyle = {
// normal: {
setOptionsColor() { color: '#173164',
const optionsCollapse = this.optionsSetup; },
const customColor = optionsCollapse.customColor; };
if (!customColor) return; data['label'] = label;
const arrColor = []; data['itemStyle'] = itemStyle;
for (let i = 0; i < customColor.length; i++) { }else{};
arrColor.push(customColor[i].color); })
} console.log(data)
this.options.color = arrColor;
this.options = Object.assign({}, this.options);
}, },
//
setOptionsData() { setOptionsData() {
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, optionsData.refreshTime); : this.dynamicDataFn(
optionsData.dynamicData,
optionsData.refreshTime
);
}, },
staticDataFn(val) { staticDataFn(val) {
const staticData = JSON.parse(val); const title = this.options.title;
for (const key in this.options.series) { title.text = '{nums|' + val + '}{percent|%}';
if (this.options.series[key].type == "pie") { this.setOptionPer(val)
this.options.series[key].data = staticData;
}
}
}, },
dynamicDataFn(val, refreshTime) { dynamicDataFn(val, refreshTime) {
if (!val) return; if (!val) return;
@ -486,15 +459,9 @@ export default {
getEchartData(val) { getEchartData(val) {
const data = this.queryEchartsData(val); const data = this.queryEchartsData(val);
data.then(res => { data.then(res => {
this.renderingFn(res); this.styleColor.text = res[0].value
this.$forceUpdate();
}); });
},
renderingFn(val) {
for (const key in this.options.series) {
if (this.options.series[key].type == "pie") {
this.options.series[key].data = val;
}
}
} }
} }
}; };

Loading…
Cancel
Save