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