|
@@ -215,8 +215,11 @@ function lineConfig(model) {
|
|
|
function pieConfig(model) {
|
|
function pieConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
let { type, config, layout } = model;
|
|
|
let { fontSize, title, subtitle, series} = config;
|
|
let { fontSize, title, subtitle, series} = config;
|
|
|
|
|
+ series = series instanceof Array ? series : [series];
|
|
|
|
|
+ series.map((a,b) => {})
|
|
|
series = series.map((v, i) => {
|
|
series = series.map((v, i) => {
|
|
|
v.value = v.data;
|
|
v.value = v.data;
|
|
|
|
|
+ v.name += `_@_${v.data}`;
|
|
|
return v;
|
|
return v;
|
|
|
});
|
|
});
|
|
|
return {
|
|
return {
|
|
@@ -226,7 +229,11 @@ function pieConfig(model) {
|
|
|
title: getChartsTitle(fontSize, layout, title, subtitle),
|
|
title: getChartsTitle(fontSize, layout, title, subtitle),
|
|
|
tooltip: {
|
|
tooltip: {
|
|
|
trigger: 'item',
|
|
trigger: 'item',
|
|
|
- formatter: '{a} <br/>{b} : {c} ({d}%)'
|
|
|
|
|
|
|
+ // formatter: '{a} <br/>{b} : {c} ({d}%)'
|
|
|
|
|
+ formatter: function(a, b, c, d, e) {
|
|
|
|
|
+ let ns = a.data.name.split('_@_');
|
|
|
|
|
+ return ns[0] + ' : ' + ns[1] + '\n' + a.percent + '%';
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
legend: getPieLegend(fontSize, layout, series),
|
|
legend: getPieLegend(fontSize, layout, series),
|
|
|
series: getPieSeries(fontSize, layout, series)
|
|
series: getPieSeries(fontSize, layout, series)
|
|
@@ -305,17 +312,19 @@ function getLineSeries(fontSize, series) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getPieSeries(fontSize, layout, series) {
|
|
function getPieSeries(fontSize, layout, series) {
|
|
|
- let data = series instanceof Array ? series : [series];
|
|
|
|
|
|
|
+ let data = series;
|
|
|
const model = {
|
|
const model = {
|
|
|
type: 'pie',
|
|
type: 'pie',
|
|
|
- radius: `${layout.w * .7}%`,
|
|
|
|
|
- center: [`${layout.w >= 35 ? (layout.w >= 60 ? 50 : (layout.w / 100 * 50 / 35 + 35)) : 50}%`,`${layout.w >= 35 ? 50 : 60}%`],
|
|
|
|
|
|
|
+ radius: '45%',
|
|
|
|
|
+ center: ['30%','50%'],
|
|
|
label: {
|
|
label: {
|
|
|
normal: {
|
|
normal: {
|
|
|
|
|
+ show: data.length > 7 ? false : true,
|
|
|
|
|
+ position: 'inside',
|
|
|
textStyle: {
|
|
textStyle: {
|
|
|
fontSize: fontSize || getFontSize() * 0.7
|
|
fontSize: fontSize || getFontSize() * 0.7
|
|
|
},
|
|
},
|
|
|
- formatter: '{b}: {c} \n {d}%'
|
|
|
|
|
|
|
+ formatter: '{d}%'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -326,14 +335,19 @@ function getPieSeries(fontSize, layout, series) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getPieLegend(fontSize, layout, series) {
|
|
function getPieLegend(fontSize, layout, series) {
|
|
|
|
|
+ series.sort((a,b) => b.data - a.data);
|
|
|
|
|
|
|
|
let legend = {
|
|
let legend = {
|
|
|
- show: !(layout.w < 35 && series.length > 7),
|
|
|
|
|
- right: (series.length <= 7 && layout.w < 35) ? 'auto' : `${layout.w/30}%`,
|
|
|
|
|
- orient: (series.length <= 7 && layout.w < 35) ? 'horizontal' : 'vertical',
|
|
|
|
|
- padding: 0,
|
|
|
|
|
|
|
+ width: '25%',
|
|
|
|
|
+ right: '5%',
|
|
|
|
|
+ orient: 'vertical',
|
|
|
|
|
+ padding: layout.w / 20,
|
|
|
itemGap: layout.w / 10,
|
|
itemGap: layout.w / 10,
|
|
|
top: '20%',
|
|
top: '20%',
|
|
|
|
|
+ formatter: function (name) {
|
|
|
|
|
+ let s = name.split('_@_');
|
|
|
|
|
+ return s[0] +' : '+ s[1]
|
|
|
|
|
+ },
|
|
|
textStyle: {
|
|
textStyle: {
|
|
|
fontSize: fontSize || getFontSize() * 0.7
|
|
fontSize: fontSize || getFontSize() * 0.7
|
|
|
},
|
|
},
|