|
|
@@ -1,5 +1,4 @@
|
|
|
function converter(data) {
|
|
|
- console.log(data);
|
|
|
let { content } = data;
|
|
|
let { title, items } = content;
|
|
|
let itemsarr = items ? (items instanceof Array ? items : [items]) : [];
|
|
|
@@ -43,27 +42,27 @@ function formConfig(model) {
|
|
|
data = data.map((d) => {
|
|
|
d.field = {
|
|
|
text: d.field.text,
|
|
|
- style: parseStyleStr(d.field.style),
|
|
|
+ style: parseObjectStr(d.field.style),
|
|
|
width: d.field.width
|
|
|
};
|
|
|
d.value = {
|
|
|
text: d.value.text,
|
|
|
- style: parseStyleStr(d.value.style),
|
|
|
+ style: parseObjectStr(d.value.style),
|
|
|
width: d.value.width
|
|
|
};
|
|
|
d.render = renderFunction(d.render);
|
|
|
return d;
|
|
|
});
|
|
|
if(header) {
|
|
|
- header.style = parseStyleStr(header.style || '{}');
|
|
|
+ header.style = parseObjectStr(header.style || '{}');
|
|
|
}
|
|
|
let c = {
|
|
|
type: 'form',
|
|
|
config: {
|
|
|
fontSize: fontSize || getFontSize(),
|
|
|
header: header,
|
|
|
- fieldStyle: parseStyleStr(fieldStyle),
|
|
|
- valueStyle: parseStyleStr(valueStyle),
|
|
|
+ fieldStyle: parseObjectStr(fieldStyle),
|
|
|
+ valueStyle: parseObjectStr(valueStyle),
|
|
|
columns,
|
|
|
data
|
|
|
},
|
|
|
@@ -80,7 +79,7 @@ function tableConfig(model) {
|
|
|
columns.map((c, i) => allWidth += (c.width || 100));
|
|
|
data = data ? ( ( data instanceof Array ) ? data : [data] ) : [];
|
|
|
if(title) {
|
|
|
- title.style = parseStyleStr(title.style || '{}');
|
|
|
+ title.style = parseObjectStr(title.style || '{}');
|
|
|
}
|
|
|
return {
|
|
|
type: 'table',
|
|
|
@@ -94,8 +93,8 @@ function tableConfig(model) {
|
|
|
v.key = i;
|
|
|
v.width ? v.width = getScreenSize().width * (layout.w/100) * (v.width/ allWidth) : '';
|
|
|
v.render = renderFunction(v.render);
|
|
|
- v.headerRowStyle = parseStyleStr(v.headerrowstyle);
|
|
|
- v.rowStyle = parseStyleStr(v.rowstyle);
|
|
|
+ v.headerRowStyle = parseObjectStr(v.headerrowstyle);
|
|
|
+ v.rowStyle = parseObjectStr(v.rowstyle);
|
|
|
return v;
|
|
|
}),
|
|
|
data: data.map( (v, i) => {
|
|
|
@@ -104,8 +103,8 @@ function tableConfig(model) {
|
|
|
}
|
|
|
return v || {};
|
|
|
} ),
|
|
|
- headerRowsStyle: parseStyleStr(headerrowsstyle),
|
|
|
- rowsStyle: parseStyleStr(rowsstyle),
|
|
|
+ headerRowsStyle: parseObjectStr(headerrowsstyle),
|
|
|
+ rowsStyle: parseObjectStr(rowsstyle),
|
|
|
},
|
|
|
layout: getLayout(layout)
|
|
|
}
|
|
|
@@ -113,10 +112,19 @@ function tableConfig(model) {
|
|
|
|
|
|
function barConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
- let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series } = config;
|
|
|
+ let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series, legendconfig, color } = config;
|
|
|
+
|
|
|
+ legendconfig = parseObjectStr(legendconfig);
|
|
|
+ color = eval(color);
|
|
|
series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
|
- let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(','));
|
|
|
- return {
|
|
|
+ let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(',')),
|
|
|
+ legendTop = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
|
+ legendRight = legendconfig.left ? (100 - legendconfig.left)+'%' : null,
|
|
|
+ itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
+ itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
|
+ itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
|
+
|
|
|
+ let o = {
|
|
|
type: 'charts',
|
|
|
config: {
|
|
|
option: {
|
|
|
@@ -132,11 +140,18 @@ function barConfig(model) {
|
|
|
bottom: layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%',
|
|
|
},
|
|
|
legend: {
|
|
|
- top: layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%',
|
|
|
- right: '5%',
|
|
|
+ show: legendconfig.hide ? (legendconfig.hide == 'false') : true,
|
|
|
+ top_: legendTop,
|
|
|
+ top: (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
+ right: legendRight || '5%',
|
|
|
padding: 0,
|
|
|
- orient: 'horizontal',
|
|
|
- itemGap: layout.w,
|
|
|
+ orient: legendconfig.orient || 'horizontal',
|
|
|
+ itemGap: itemGap,
|
|
|
+ itemWidth: itemWidth,
|
|
|
+ itemHeight: itemHeight,
|
|
|
+ textStyle: {
|
|
|
+ fontSize: getFontSize() * 0.7
|
|
|
+ },
|
|
|
data: series.map((v, i) => {
|
|
|
return v.name
|
|
|
})
|
|
|
@@ -148,29 +163,56 @@ function barConfig(model) {
|
|
|
nameGap: 5,
|
|
|
nameRotate: 270,
|
|
|
nameLocation: 'end',
|
|
|
+ nameTextStyle: {
|
|
|
+ fontSize: getFontSize() * .7
|
|
|
+ },
|
|
|
axisLabel: {
|
|
|
rotate: getScreenSize().width * layout.w / xf.length / 100 < 80 ? 45 : 0,
|
|
|
- interval: 0
|
|
|
+ interval: 0,
|
|
|
+ textStyle: {
|
|
|
+ fontSize: getFontSize() * .7
|
|
|
+ }
|
|
|
}
|
|
|
}],
|
|
|
yAxis: [{
|
|
|
name: ytitle,
|
|
|
nameRotate: .1,
|
|
|
type: ytype == 'numeric' ? 'value' : ytype,
|
|
|
+ nameTextStyle: {
|
|
|
+ fontSize: getFontSize() * .7
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ textStyle: {
|
|
|
+ fontSize: getFontSize() * .7
|
|
|
+ }
|
|
|
+ }
|
|
|
}],
|
|
|
series: getBarSeries(fontSize, layout, series)
|
|
|
}
|
|
|
},
|
|
|
layout: getLayout(layout)
|
|
|
}
|
|
|
+ if(color && color.length > 0) {
|
|
|
+ o.config.option.color = color;
|
|
|
+ }
|
|
|
+ return o;
|
|
|
}
|
|
|
|
|
|
function lineConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
- let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series } = config;
|
|
|
+ let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series, legendconfig, color } = config;
|
|
|
+
|
|
|
+ legendconfig = parseObjectStr(legendconfig);
|
|
|
+ color = eval(color);
|
|
|
series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
|
- let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(','));
|
|
|
- return {
|
|
|
+ let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(',')),
|
|
|
+ legendTop = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
|
+ legendRight = legendconfig.left ? (100 - legendconfig.left)+'%' : null,
|
|
|
+ itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
+ itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
|
+ itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
|
+
|
|
|
+ let o = {
|
|
|
type: 'charts',
|
|
|
config: {
|
|
|
option: {
|
|
|
@@ -183,11 +225,18 @@ function lineConfig(model) {
|
|
|
bottom: layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%',
|
|
|
},
|
|
|
legend: {
|
|
|
- top: layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%',
|
|
|
- right: '5%',
|
|
|
+ show: legendconfig.hide ? (legendconfig.hide == 'false') : true,
|
|
|
+ top_: legendTop,
|
|
|
+ top: (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
+ right: legendRight || '5%',
|
|
|
padding: 0,
|
|
|
- orient: 'horizontal',
|
|
|
- itemGap: layout.w,
|
|
|
+ orient: legendconfig.orient || 'horizontal',
|
|
|
+ itemGap: itemGap,
|
|
|
+ itemWidth: itemWidth,
|
|
|
+ itemHeight: itemHeight,
|
|
|
+ textStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * 0.7
|
|
|
+ },
|
|
|
data: series.map((v, i) => {
|
|
|
return v.name
|
|
|
})
|
|
|
@@ -199,15 +248,29 @@ function lineConfig(model) {
|
|
|
nameRotate: 270,
|
|
|
nameLocation: 'end',
|
|
|
nameGap: 5,
|
|
|
+ nameTextStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * .7
|
|
|
+ },
|
|
|
axisLabel: {
|
|
|
rotate: getScreenSize().width * layout.w / xf.length / 100 < 80 ? 45 : 0,
|
|
|
- interval: 0
|
|
|
+ interval: 0,
|
|
|
+ textStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * .7
|
|
|
+ }
|
|
|
}
|
|
|
}],
|
|
|
yAxis: [{
|
|
|
name: ytitle,
|
|
|
nameRotate: .1,
|
|
|
- type: ytype == 'numeric' ? 'value' : ytype
|
|
|
+ type: ytype == 'numeric' ? 'value' : ytype,
|
|
|
+ nameTextStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * .7
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ textStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * .7
|
|
|
+ }
|
|
|
+ }
|
|
|
}],
|
|
|
series: getLineSeries(fontSize, series),
|
|
|
dataZoom: series.length > 0 ? [
|
|
|
@@ -223,17 +286,24 @@ function lineConfig(model) {
|
|
|
},
|
|
|
layout: getLayout(layout)
|
|
|
}
|
|
|
+ if(color && color.length > 0) {
|
|
|
+ o.config.option.color = color;
|
|
|
+ }
|
|
|
+ return o;
|
|
|
}
|
|
|
|
|
|
function pieConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
- let { fontSize, title, subtitle, series } = config;
|
|
|
+ let { fontSize, title, subtitle, series, color, legendconfig, pieconfig } = config;
|
|
|
+ color = eval(color);
|
|
|
+ legendconfig = parseObjectStr(legendconfig);
|
|
|
+ pieconfig = parseObjectStr(pieconfig);
|
|
|
series = series ? ((series instanceof Array) ? series : [series]) : [];
|
|
|
series = series.map((v, i) => {
|
|
|
v.value = v.data;
|
|
|
return v;
|
|
|
});
|
|
|
- return {
|
|
|
+ let o = {
|
|
|
type: 'charts',
|
|
|
config: {
|
|
|
option: {
|
|
|
@@ -242,12 +312,17 @@ function pieConfig(model) {
|
|
|
trigger: 'item',
|
|
|
formatter: '{b} : {c} ({d}%)'
|
|
|
},
|
|
|
- legend: getPieLegend(fontSize, layout, series),
|
|
|
- series: getPieSeries(fontSize, layout, series)
|
|
|
+ legend: getPieLegend(fontSize, layout, series, legendconfig),
|
|
|
+ series: getPieSeries(fontSize, layout, series, pieconfig),
|
|
|
+ animation: !pieconfig.centerx && !pieconfig.centery
|
|
|
}
|
|
|
},
|
|
|
layout: getLayout(layout)
|
|
|
}
|
|
|
+ if(color && color.length > 0) {
|
|
|
+ o.config.option.color = color;
|
|
|
+ }
|
|
|
+ return o;
|
|
|
}
|
|
|
|
|
|
function renderFunction(funcStr) {
|
|
|
@@ -263,10 +338,12 @@ function getChartsTitle(fontSize, layout, title, subtitle) {
|
|
|
subtext: layout.h * getScreenSize().height / 100 < 300 ? '' : subtitle,
|
|
|
textAlign: 'center',
|
|
|
textStyle: {
|
|
|
- verticalAlign: 'top'
|
|
|
+ verticalAlign: 'top',
|
|
|
+ fontSize: fontSize || getFontSize() * 1
|
|
|
},
|
|
|
subtextStyle: {
|
|
|
- verticalAlign: 'top'
|
|
|
+ verticalAlign: 'top',
|
|
|
+ fontSize: fontSize || getFontSize() * 0.75
|
|
|
},
|
|
|
left: '50%',
|
|
|
right: '50%',
|
|
|
@@ -285,6 +362,9 @@ function getBarSeries(fontSize, layout, series) {
|
|
|
show: true,
|
|
|
position: 'top',
|
|
|
formatter: '{c}',
|
|
|
+ textStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * .7
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
barGap: '10%'
|
|
|
@@ -320,7 +400,10 @@ function getLineSeries(fontSize, series) {
|
|
|
normal: {
|
|
|
show: true,
|
|
|
position: 'inside',
|
|
|
- formatter: '{c}'
|
|
|
+ formatter: '{c}',
|
|
|
+ textStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * .7
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -333,15 +416,22 @@ function getLineSeries(fontSize, series) {
|
|
|
return s;
|
|
|
}
|
|
|
|
|
|
-function getPieSeries(fontSize, layout, series) {
|
|
|
+function getPieSeries(fontSize, layout, series, pieconfig) {
|
|
|
let data = series.length > 0 ? series : [{name: '无数据', value: 0}];
|
|
|
+
|
|
|
+
|
|
|
const model = {
|
|
|
type: 'pie',
|
|
|
- markPoint: {
|
|
|
- symbol: 'circle'
|
|
|
- },
|
|
|
+ centerx: pieconfig.centerx,
|
|
|
+ centery: pieconfig.centery,
|
|
|
+ radius1: pieconfig.radius1,
|
|
|
+ radius2: pieconfig.radius2,
|
|
|
label: {
|
|
|
normal: {
|
|
|
+ show: !pieconfig.hideLabel,
|
|
|
+ textStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * 0.7
|
|
|
+ },
|
|
|
formatter: '{b}: {c} \n {d}%'
|
|
|
}
|
|
|
}
|
|
|
@@ -370,11 +460,28 @@ function getPieSeries(fontSize, layout, series) {
|
|
|
return [s];
|
|
|
}
|
|
|
|
|
|
-function getPieLegend(fontSize, layout, series) {
|
|
|
+function getPieLegend(fontSize, layout, series, legendconfig) {
|
|
|
+ let hide = legendconfig.hide == 'true',
|
|
|
+ top = legendconfig.top ? (legendconfig.top)+'%' : null,
|
|
|
+ right = legendconfig.left ? (100 - legendconfig.left)+'%' : null,
|
|
|
+ itemGap = legendconfig.itemGap ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
+ itemWidth = legendconfig.itemWidth ? Number(legendconfig.itemWidth) : 25,
|
|
|
+ itemHeight = legendconfig.itemHeight ? Number(legendconfig.itemHeight) : 14;
|
|
|
+
|
|
|
let legend = {
|
|
|
+ hide_: hide,
|
|
|
+ top_: top,
|
|
|
+ right_: right,
|
|
|
+ width: legendconfig.width,
|
|
|
+ height: legendconfig.height,
|
|
|
+ orient_: legendconfig.orient,
|
|
|
+ itemGap: itemGap,
|
|
|
+ itemWidth: itemWidth,
|
|
|
+ itemHeight : itemHeight,
|
|
|
padding: 0,
|
|
|
- type: 'scroll',
|
|
|
- itemGap: layout.w / 10,
|
|
|
+ textStyle: {
|
|
|
+ fontSize: fontSize || getFontSize() * 0.7
|
|
|
+ },
|
|
|
data: series.map((v, i) => {
|
|
|
return v.name || 'Unkonw';
|
|
|
})
|
|
|
@@ -393,7 +500,7 @@ function getLayout(layout) {
|
|
|
return l;
|
|
|
}
|
|
|
|
|
|
-function parseStyleStr(str) {
|
|
|
+function parseObjectStr(str) {
|
|
|
if (!str) {
|
|
|
return {};
|
|
|
}
|