|
|
@@ -114,7 +114,7 @@ function tableConfig(model) {
|
|
|
function barConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series } = config;
|
|
|
- series = (series instanceof Array) ? series : [series];
|
|
|
+ series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
|
let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(','));
|
|
|
return {
|
|
|
type: 'charts',
|
|
|
@@ -168,7 +168,7 @@ function barConfig(model) {
|
|
|
function lineConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series } = config;
|
|
|
- series = (series instanceof Array) ? series : [series];
|
|
|
+ series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
|
let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(','));
|
|
|
return {
|
|
|
type: 'charts',
|
|
|
@@ -210,7 +210,7 @@ function lineConfig(model) {
|
|
|
type: ytype == 'numeric' ? 'value' : ytype
|
|
|
}],
|
|
|
series: getLineSeries(fontSize, series),
|
|
|
- dataZoom: [
|
|
|
+ dataZoom: series.length > 0 ? [
|
|
|
{
|
|
|
type: 'slider',
|
|
|
show: false,
|
|
|
@@ -218,7 +218,7 @@ function lineConfig(model) {
|
|
|
start: 0,
|
|
|
endValue: Math.round(getScreenSize().width * layout.w / 100 / 60) >= series[0].data.length ? series[0].data.length - 1 : Math.round(getScreenSize().width * layout.w / 100 / 60),
|
|
|
}
|
|
|
- ],
|
|
|
+ ] : null,
|
|
|
}
|
|
|
},
|
|
|
layout: getLayout(layout)
|
|
|
@@ -228,7 +228,7 @@ function lineConfig(model) {
|
|
|
function pieConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
let { fontSize, title, subtitle, series } = config;
|
|
|
- series = (series instanceof Array) ? series : [series];
|
|
|
+ series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
|
series = series.map((v, i) => {
|
|
|
v.value = v.data;
|
|
|
return v;
|
|
|
@@ -334,9 +334,12 @@ function getLineSeries(fontSize, series) {
|
|
|
}
|
|
|
|
|
|
function getPieSeries(fontSize, layout, series) {
|
|
|
- let data = series instanceof Array ? series : [series];
|
|
|
+ let data = series.length > 0 ? series : [{name: '无数据', value: 0}];
|
|
|
const model = {
|
|
|
type: 'pie',
|
|
|
+ markPoint: {
|
|
|
+ symbol: 'circle'
|
|
|
+ },
|
|
|
label: {
|
|
|
normal: {
|
|
|
formatter: '{b}: {c} \n {d}%'
|
|
|
@@ -346,17 +349,39 @@ function getPieSeries(fontSize, layout, series) {
|
|
|
let s = Object.assign({}, model);
|
|
|
s.name = '';
|
|
|
s.data = data.map((d, i) => { d.name = d.name || 'Unkonw'; return d; });
|
|
|
+ if(series.length == 0) {
|
|
|
+ s.itemStyle = {
|
|
|
+ normal: {
|
|
|
+ color: '#b0a494',
|
|
|
+ }
|
|
|
+ };
|
|
|
+ s.label = {
|
|
|
+ normal: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ s.labelLine = {
|
|
|
+ normal: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ s.silent = true;
|
|
|
+ }
|
|
|
return [s];
|
|
|
}
|
|
|
|
|
|
function getPieLegend(fontSize, layout, series) {
|
|
|
let legend = {
|
|
|
padding: 0,
|
|
|
+ type: 'scroll',
|
|
|
itemGap: layout.w / 10,
|
|
|
data: series.map((v, i) => {
|
|
|
return v.name || 'Unkonw';
|
|
|
})
|
|
|
}
|
|
|
+ if(series.length == 0) {
|
|
|
+ legend.data = ['无数据']
|
|
|
+ }
|
|
|
return legend;
|
|
|
}
|
|
|
|