|
@@ -112,14 +112,14 @@ function tableConfig(model) {
|
|
|
|
|
|
|
|
function barConfig(model) {
|
|
function barConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
let { type, config, layout } = model;
|
|
|
- let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series, legendconfig, color } = config;
|
|
|
|
|
|
|
+ let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series, legendconfig, areaconfig, color } = config;
|
|
|
|
|
|
|
|
legendconfig = parseObjectStr(legendconfig);
|
|
legendconfig = parseObjectStr(legendconfig);
|
|
|
|
|
+ areaconfig = parseObjectStr(areaconfig);
|
|
|
color = eval(color);
|
|
color = eval(color);
|
|
|
series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
|
let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(',')),
|
|
let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(',')),
|
|
|
legendTop = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
legendTop = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
|
- legendRight = legendconfig.left ? (100 - legendconfig.left)+'%' : null,
|
|
|
|
|
itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
|
itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
@@ -136,14 +136,18 @@ function barConfig(model) {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
grid: {
|
|
grid: {
|
|
|
|
|
+ containLabel: true,
|
|
|
|
|
+ top_: areaconfig.top ? areaconfig.top+'%' : null,
|
|
|
|
|
+ bottom_: areaconfig.bottom ? areaconfig.bottom+'%' : null,
|
|
|
|
|
+ left_: areaconfig.left ? areaconfig.left+'%' : null,
|
|
|
|
|
+ right_: areaconfig.right ? areaconfig.right+'%' : null,
|
|
|
top: layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%',
|
|
top: layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%',
|
|
|
bottom: layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%',
|
|
bottom: layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%',
|
|
|
},
|
|
},
|
|
|
legend: {
|
|
legend: {
|
|
|
- show: legendconfig.hide ? (legendconfig.hide == 'false') : true,
|
|
|
|
|
|
|
+ show: !legendconfig.hide,
|
|
|
top_: legendTop,
|
|
top_: legendTop,
|
|
|
top: (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
top: (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
- right: legendRight || '5%',
|
|
|
|
|
padding: 0,
|
|
padding: 0,
|
|
|
orient: legendconfig.orient || 'horizontal',
|
|
orient: legendconfig.orient || 'horizontal',
|
|
|
itemGap: itemGap,
|
|
itemGap: itemGap,
|
|
@@ -187,7 +191,7 @@ function barConfig(model) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}],
|
|
}],
|
|
|
- series: getBarSeries(fontSize, layout, series)
|
|
|
|
|
|
|
+ series: getBarSeries(fontSize, layout, series, areaconfig)
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
layout: getLayout(layout)
|
|
layout: getLayout(layout)
|
|
@@ -195,19 +199,24 @@ function barConfig(model) {
|
|
|
if(color && color.length > 0) {
|
|
if(color && color.length > 0) {
|
|
|
o.config.option.color = color;
|
|
o.config.option.color = color;
|
|
|
}
|
|
}
|
|
|
|
|
+ if(Number(legendconfig.left) >= 0) {
|
|
|
|
|
+ o.config.option.legend.left = Number(legendconfig.left)+'%';
|
|
|
|
|
+ }else {
|
|
|
|
|
+ o.config.option.legend.right = '5%';
|
|
|
|
|
+ }
|
|
|
return o;
|
|
return o;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function lineConfig(model) {
|
|
function lineConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
let { type, config, layout } = model;
|
|
|
- let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series, legendconfig, color } = config;
|
|
|
|
|
|
|
+ let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series, legendconfig, areaconfig, color } = config;
|
|
|
|
|
|
|
|
legendconfig = parseObjectStr(legendconfig);
|
|
legendconfig = parseObjectStr(legendconfig);
|
|
|
|
|
+ areaconfig = parseObjectStr(areaconfig);
|
|
|
color = eval(color);
|
|
color = eval(color);
|
|
|
series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
|
let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(',')),
|
|
let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(',')),
|
|
|
legendTop = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
legendTop = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
|
- legendRight = legendconfig.left ? (100 - legendconfig.left)+'%' : null,
|
|
|
|
|
itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
|
itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
@@ -221,14 +230,18 @@ function lineConfig(model) {
|
|
|
trigger: 'axis'
|
|
trigger: 'axis'
|
|
|
},
|
|
},
|
|
|
grid: {
|
|
grid: {
|
|
|
|
|
+ containLabel: true,
|
|
|
|
|
+ top_: areaconfig.top ? areaconfig.top+'%' : null,
|
|
|
|
|
+ bottom_: areaconfig.bottom ? areaconfig.bottom+'%' : null,
|
|
|
|
|
+ left_: areaconfig.left ? areaconfig.left+'%' : null,
|
|
|
|
|
+ right_: areaconfig.right ? areaconfig.right+'%' : null,
|
|
|
top: layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%',
|
|
top: layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%',
|
|
|
bottom: layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%',
|
|
bottom: layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%',
|
|
|
},
|
|
},
|
|
|
legend: {
|
|
legend: {
|
|
|
- show: legendconfig.hide ? (legendconfig.hide == 'false') : true,
|
|
|
|
|
|
|
+ show: !legendconfig.hide,
|
|
|
top_: legendTop,
|
|
top_: legendTop,
|
|
|
top: (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
top: (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
- right: legendRight || '5%',
|
|
|
|
|
padding: 0,
|
|
padding: 0,
|
|
|
orient: legendconfig.orient || 'horizontal',
|
|
orient: legendconfig.orient || 'horizontal',
|
|
|
itemGap: itemGap,
|
|
itemGap: itemGap,
|
|
@@ -272,7 +285,7 @@ function lineConfig(model) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}],
|
|
}],
|
|
|
- series: getLineSeries(fontSize, series),
|
|
|
|
|
|
|
+ series: getLineSeries(fontSize, series, areaconfig),
|
|
|
dataZoom: series.length > 0 ? [
|
|
dataZoom: series.length > 0 ? [
|
|
|
{
|
|
{
|
|
|
type: 'slider',
|
|
type: 'slider',
|
|
@@ -289,6 +302,11 @@ function lineConfig(model) {
|
|
|
if(color && color.length > 0) {
|
|
if(color && color.length > 0) {
|
|
|
o.config.option.color = color;
|
|
o.config.option.color = color;
|
|
|
}
|
|
}
|
|
|
|
|
+ if(Number(legendconfig.left) >= 0) {
|
|
|
|
|
+ o.config.option.legend.left = Number(legendconfig.left)+'%';
|
|
|
|
|
+ }else {
|
|
|
|
|
+ o.config.option.legend.right = '5%';
|
|
|
|
|
+ }
|
|
|
return o;
|
|
return o;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -353,15 +371,16 @@ function getChartsTitle(fontSize, layout, title, subtitle) {
|
|
|
return title;
|
|
return title;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function getBarSeries(fontSize, layout, series) {
|
|
|
|
|
|
|
+function getBarSeries(fontSize, layout, series, areaconfig) {
|
|
|
let s = [];
|
|
let s = [];
|
|
|
const model = {
|
|
const model = {
|
|
|
type: 'bar',
|
|
type: 'bar',
|
|
|
label: {
|
|
label: {
|
|
|
normal: {
|
|
normal: {
|
|
|
- show: true,
|
|
|
|
|
- position: 'top',
|
|
|
|
|
- formatter: '{c}',
|
|
|
|
|
|
|
+ show: !areaconfig.hideLabel,
|
|
|
|
|
+ position: areaconfig.labelPosition || 'top',
|
|
|
|
|
+ distance: areaconfig.labelDistance ? Number(areaconfig.labelDistance) : 5,
|
|
|
|
|
+ formatter: areaconfig.labelFormatter || '{c}',
|
|
|
textStyle: {
|
|
textStyle: {
|
|
|
fontSize: fontSize || getFontSize() * .7
|
|
fontSize: fontSize || getFontSize() * .7
|
|
|
}
|
|
}
|
|
@@ -369,20 +388,39 @@ function getBarSeries(fontSize, layout, series) {
|
|
|
},
|
|
},
|
|
|
barGap: '10%'
|
|
barGap: '10%'
|
|
|
}
|
|
}
|
|
|
|
|
+ if(areaconfig.barMaxWidth) {
|
|
|
|
|
+ model.barMaxWidth = areaconfig.barMaxWidth;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(areaconfig.barWidth) {
|
|
|
|
|
+ model.barWidth = areaconfig.barWidth;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(areaconfig.barMinHeight) {
|
|
|
|
|
+ model.barMinHeight = areaconfig.barMinHeight;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(areaconfig.barGap) {
|
|
|
|
|
+ model.barGap = areaconfig.barGap+"%";
|
|
|
|
|
+ }
|
|
|
s = series.map((v, i) => {
|
|
s = series.map((v, i) => {
|
|
|
let m = Object.assign({}, model);
|
|
let m = Object.assign({}, model);
|
|
|
m.name = v.name;
|
|
m.name = v.name;
|
|
|
m.data = v.data instanceof Array ? v.data : [v.data];
|
|
m.data = v.data instanceof Array ? v.data : [v.data];
|
|
|
return m;
|
|
return m;
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
return s;
|
|
return s;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function getLineSeries(fontSize, series) {
|
|
|
|
|
|
|
+function getLineSeries(fontSize, series, areaconfig) {
|
|
|
let s = [];
|
|
let s = [];
|
|
|
const model = {
|
|
const model = {
|
|
|
type: 'line',
|
|
type: 'line',
|
|
|
- smooth: false,
|
|
|
|
|
|
|
+ smooth: areaconfig.smooth || false,
|
|
|
|
|
+ lineStyle: {
|
|
|
|
|
+ normal: {
|
|
|
|
|
+ width: areaconfig.lineWidth || 2,
|
|
|
|
|
+ type: areaconfig.lineType || 'solid'
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
markLine: {
|
|
markLine: {
|
|
|
symbol: '',
|
|
symbol: '',
|
|
|
label: {
|
|
label: {
|
|
@@ -396,11 +434,15 @@ function getLineSeries(fontSize, series) {
|
|
|
xAxis: ''
|
|
xAxis: ''
|
|
|
}]
|
|
}]
|
|
|
},
|
|
},
|
|
|
|
|
+ symbol: areaconfig.symbol || 'circle',
|
|
|
|
|
+ symbolSize: areaconfig.symbolSize || 4,
|
|
|
|
|
+ showSymbol: !areaconfig.hideSymbol,
|
|
|
label: {
|
|
label: {
|
|
|
normal: {
|
|
normal: {
|
|
|
- show: true,
|
|
|
|
|
- position: 'inside',
|
|
|
|
|
- formatter: '{c}',
|
|
|
|
|
|
|
+ show: !areaconfig.hideLabel,
|
|
|
|
|
+ position: areaconfig.labelPosition || 'top',
|
|
|
|
|
+ distance: areaconfig.labelDistance ? Number(areaconfig.labelDistance) : 5,
|
|
|
|
|
+ formatter: areaconfig.labelFormatter || '{c}',
|
|
|
textStyle: {
|
|
textStyle: {
|
|
|
fontSize: fontSize || getFontSize() * .7
|
|
fontSize: fontSize || getFontSize() * .7
|
|
|
}
|
|
}
|
|
@@ -419,6 +461,7 @@ function getLineSeries(fontSize, series) {
|
|
|
function getPieSeries(fontSize, layout, series, pieconfig) {
|
|
function getPieSeries(fontSize, layout, series, pieconfig) {
|
|
|
let data = series.length > 0 ? series : [{name: '无数据', value: 0}];
|
|
let data = series.length > 0 ? series : [{name: '无数据', value: 0}];
|
|
|
|
|
|
|
|
|
|
+
|
|
|
const model = {
|
|
const model = {
|
|
|
type: 'pie',
|
|
type: 'pie',
|
|
|
centerx: pieconfig.centerx,
|
|
centerx: pieconfig.centerx,
|
|
@@ -462,7 +505,7 @@ function getPieSeries(fontSize, layout, series, pieconfig) {
|
|
|
function getPieLegend(fontSize, layout, series, legendconfig) {
|
|
function getPieLegend(fontSize, layout, series, legendconfig) {
|
|
|
let hide = legendconfig.hide == 'true',
|
|
let hide = legendconfig.hide == 'true',
|
|
|
top = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
top = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
|
- right = legendconfig.left ? (100 - legendconfig.left)+'%' : null,
|
|
|
|
|
|
|
+ left = legendconfig.left ? legendconfig.left+'%' : null,
|
|
|
itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
|
itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
@@ -470,7 +513,7 @@ function getPieLegend(fontSize, layout, series, legendconfig) {
|
|
|
let legend = {
|
|
let legend = {
|
|
|
hide_: hide,
|
|
hide_: hide,
|
|
|
top_: top,
|
|
top_: top,
|
|
|
- right_: right,
|
|
|
|
|
|
|
+ left_: left,
|
|
|
width: legendconfig.width,
|
|
width: legendconfig.width,
|
|
|
height: legendconfig.height,
|
|
height: legendconfig.height,
|
|
|
orient_: legendconfig.orient,
|
|
orient_: legendconfig.orient,
|