|
|
@@ -50,11 +50,11 @@ function titleConfig(model) {
|
|
|
|
|
|
function formConfig(model) {
|
|
|
let { type, header, config, layout } = model;
|
|
|
- let { fieldstyle, valuestyle, columns, data} = config;
|
|
|
+ let { fontSize, fieldstyle, valuestyle, columns, data} = config;
|
|
|
let c = {
|
|
|
type: 'form',
|
|
|
config: {
|
|
|
- fontSize: getFontSize(layout),
|
|
|
+ fontSize: fontSize || getFontSize(layout),
|
|
|
header: Renders[header] || header,
|
|
|
fieldStyle: parseStr(fieldstyle),
|
|
|
valueStyle: parseStr(valuestyle),
|
|
|
@@ -68,12 +68,13 @@ function formConfig(model) {
|
|
|
|
|
|
function tableConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
- let { title, cls, render, columns, data} = config;
|
|
|
+ let { fontSize, title, cls, render, columns, data, rowHeight} = config;
|
|
|
|
|
|
return {
|
|
|
type: 'table',
|
|
|
config: {
|
|
|
- fontSize: getFontSize(layout),
|
|
|
+ fontSize: fontSize || getFontSize(layout),
|
|
|
+ rowHeight: rowHeight,
|
|
|
title: Renders[title] || title,
|
|
|
render: Renders[render],
|
|
|
columns: columns.map((v, i) => {
|
|
|
@@ -91,15 +92,13 @@ function tableConfig(model) {
|
|
|
|
|
|
function barConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
- let { title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series} = config;
|
|
|
- let f = xfields.replace(['['],'');
|
|
|
- f = f.replace([']'],'');
|
|
|
- let xf = f.split(',');
|
|
|
+ let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series} = config;
|
|
|
+ let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['],'').replace([']'],'').split(','));
|
|
|
return {
|
|
|
type: 'charts',
|
|
|
config: {
|
|
|
option: {
|
|
|
- title: getChartsTitle(layout, title, subtitle),
|
|
|
+ title: getChartsTitle(fontSize, layout, title, subtitle),
|
|
|
tooltip: {
|
|
|
trigger: 'axis',
|
|
|
axisPointer: {
|
|
|
@@ -151,7 +150,7 @@ function barConfig(model) {
|
|
|
}
|
|
|
}
|
|
|
}],
|
|
|
- series: getBarSeries(layout, series)
|
|
|
+ series: getBarSeries(fontSize, layout, series)
|
|
|
}
|
|
|
},
|
|
|
layout: getLayout(layout)
|
|
|
@@ -160,15 +159,13 @@ function barConfig(model) {
|
|
|
|
|
|
function lineConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
- let { title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series} = config;
|
|
|
- let f = xfields.replace(['['],'');
|
|
|
- f = f.replace([']'],'');
|
|
|
- let xf = f.split(',');
|
|
|
+ let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series} = config;
|
|
|
+ let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['],'').replace([']'],'').split(','));
|
|
|
return {
|
|
|
type: 'charts',
|
|
|
config: {
|
|
|
option: {
|
|
|
- title: getChartsTitle(layout, title, subtitle),
|
|
|
+ title: getChartsTitle(fontSize, layout, title, subtitle),
|
|
|
tooltip: {
|
|
|
trigger: 'axis'
|
|
|
},
|
|
|
@@ -182,7 +179,7 @@ function lineConfig(model) {
|
|
|
orient: 'horizontal',
|
|
|
itemGap: layout.w,
|
|
|
textStyle: {
|
|
|
- fontSize: getFontSize(layout) * 0.7
|
|
|
+ fontSize: fontSize || getFontSize(layout) * 0.7
|
|
|
},
|
|
|
data: series.map((v, i) => {
|
|
|
return v.name
|
|
|
@@ -193,14 +190,15 @@ function lineConfig(model) {
|
|
|
data : xf,
|
|
|
name: xtitle,
|
|
|
nameRotate: 270,
|
|
|
+ nameGap: 0,
|
|
|
nameTextStyle: {
|
|
|
- fontSize: getFontSize(layout) * .7
|
|
|
+ fontSize: fontSize || getFontSize(layout) * .7
|
|
|
},
|
|
|
axisLabel: {
|
|
|
rotate: getScreenSize().screenWidth * layout.w / xf.length / 100 < 60 ? 45 : 0,
|
|
|
interval: 0,
|
|
|
textStyle: {
|
|
|
- fontSize: getFontSize(layout) * .7
|
|
|
+ fontSize: fontSize || getFontSize(layout) * .7
|
|
|
}
|
|
|
}
|
|
|
}],
|
|
|
@@ -208,15 +206,15 @@ function lineConfig(model) {
|
|
|
name: ytitle,
|
|
|
type: ytype == 'numeric' ? 'value' : ytype,
|
|
|
nameTextStyle: {
|
|
|
- fontSize: getFontSize(layout) * .7
|
|
|
+ fontSize: fontSize || getFontSize(layout) * .7
|
|
|
},
|
|
|
axisLabel: {
|
|
|
textStyle: {
|
|
|
- fontSize: getFontSize(layout) * .7
|
|
|
+ fontSize: fontSize || getFontSize(layout) * .7
|
|
|
}
|
|
|
}
|
|
|
}],
|
|
|
- series: getLineSeries(series)
|
|
|
+ series: getLineSeries(fontSize, series)
|
|
|
}
|
|
|
},
|
|
|
layout: getLayout(layout)
|
|
|
@@ -225,7 +223,7 @@ function lineConfig(model) {
|
|
|
|
|
|
function pieConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
- let { title, subtitle, series} = config;
|
|
|
+ let { fontSize, title, subtitle, series} = config;
|
|
|
series = series.map((v, i) => {
|
|
|
v.value = v.data;
|
|
|
return v;
|
|
|
@@ -234,20 +232,20 @@ function pieConfig(model) {
|
|
|
type: 'charts',
|
|
|
config: {
|
|
|
option: {
|
|
|
- title: getChartsTitle(layout, title, subtitle),
|
|
|
+ title: getChartsTitle(fontSize, layout, title, subtitle),
|
|
|
tooltip: {
|
|
|
trigger: 'item',
|
|
|
formatter: '{a} <br/>{b} : {c} ({d}%)'
|
|
|
},
|
|
|
- legend: getPieLegend(layout, series),
|
|
|
- series: getPieSeries(layout, series)
|
|
|
+ legend: getPieLegend(fontSize, layout, series),
|
|
|
+ series: getPieSeries(fontSize, layout, series)
|
|
|
}
|
|
|
},
|
|
|
layout: getLayout(layout)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function getChartsTitle(layout, title, subtitle) {
|
|
|
+function getChartsTitle(fontSize, layout, title, subtitle) {
|
|
|
var title = {
|
|
|
show: true,
|
|
|
text: title,
|
|
|
@@ -255,11 +253,11 @@ function getChartsTitle(layout, title, subtitle) {
|
|
|
textAlign: 'center',
|
|
|
textStyle: {
|
|
|
verticalAlign: 'top',
|
|
|
- fontSize: getFontSize(layout) * 1
|
|
|
+ fontSize: fontSize || getFontSize(layout) * 1
|
|
|
},
|
|
|
subtextStyle: {
|
|
|
verticalAlign: 'top',
|
|
|
- fontSize: getFontSize(layout) * 0.75
|
|
|
+ fontSize: fontSize || getFontSize(layout) * 0.75
|
|
|
},
|
|
|
left: '50%',
|
|
|
right: '50%',
|
|
|
@@ -269,8 +267,8 @@ function getChartsTitle(layout, title, subtitle) {
|
|
|
return title;
|
|
|
}
|
|
|
|
|
|
-function getBarSeries(l, s) {
|
|
|
- let series = [];
|
|
|
+function getBarSeries(fontSize, layout, series) {
|
|
|
+ let s = [];
|
|
|
const model = {
|
|
|
type: 'bar',
|
|
|
label: {
|
|
|
@@ -279,23 +277,23 @@ function getBarSeries(l, s) {
|
|
|
position: 'top',
|
|
|
formatter: '{c}',
|
|
|
textStyle: {
|
|
|
- fontSize: getFontSize(l) * .7
|
|
|
+ fontSize: fontSize || getFontSize(layout) * .7
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
barGap: 0
|
|
|
}
|
|
|
- series = s.map((v, i) => {
|
|
|
+ s = series.map((v, i) => {
|
|
|
let m = Object.assign({},model);
|
|
|
m.name = v.name;
|
|
|
m.data = v.data;
|
|
|
return m;
|
|
|
});
|
|
|
- return series;
|
|
|
+ return s;
|
|
|
}
|
|
|
|
|
|
-function getLineSeries(s) {
|
|
|
- let series = [];
|
|
|
+function getLineSeries(fontSize, series) {
|
|
|
+ let s = [];
|
|
|
const model = {
|
|
|
type: 'line',
|
|
|
label: {
|
|
|
@@ -306,61 +304,61 @@ function getLineSeries(s) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- series = s.map((v, i) => {
|
|
|
+ s = series.map((v, i) => {
|
|
|
let m = Object.assign({},model);
|
|
|
m.name = v.name;
|
|
|
m.data = v.data;
|
|
|
return m;
|
|
|
});
|
|
|
- return series;
|
|
|
+ return s;
|
|
|
}
|
|
|
|
|
|
-function getPieSeries(l, s) {
|
|
|
+function getPieSeries(fontSize, layout, series) {
|
|
|
|
|
|
const model = {
|
|
|
type: 'pie',
|
|
|
- radius: `${l.w * .7}%`,
|
|
|
- center: [`${l.w >= 35 ? (l.w >= 60 ? 50 : (l.w / 100 * 50 / 35 + 35)) : 50}%`,`${l.w >= 35 ? 50 : 60}%`],
|
|
|
+ radius: `${layout.w * .7}%`,
|
|
|
+ center: [`${layout.w >= 35 ? (layout.w >= 60 ? 50 : (layout.w / 100 * 50 / 35 + 35)) : 50}%`,`${layout.w >= 35 ? 50 : 60}%`],
|
|
|
label: {
|
|
|
normal: {
|
|
|
textStyle: {
|
|
|
- fontSize: getFontSize(l) * 0.7
|
|
|
+ fontSize: fontSize || getFontSize(layout) * 0.7
|
|
|
},
|
|
|
formatter: '{b}: {c} \n {d}%'
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- let series = Object.assign({},model);
|
|
|
- series.name = '';
|
|
|
- series.data = s
|
|
|
- return [series];
|
|
|
+ let s = Object.assign({},model);
|
|
|
+ s.name = '';
|
|
|
+ s.data = series
|
|
|
+ return [s];
|
|
|
}
|
|
|
|
|
|
-function getPieLegend(l, s) {
|
|
|
+function getPieLegend(fontSize, layout, series) {
|
|
|
|
|
|
let legend = {
|
|
|
- show: !(l.w < 35 && s.length > 7),
|
|
|
- right: (s.length <= 7 && l.w < 35) ? 'auto' : `${l.w/30}%`,
|
|
|
- orient: (s.length <= 7 && l.w < 35) ? 'horizontal' : 'vertical',
|
|
|
+ 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,
|
|
|
- itemGap: l.w / 10,
|
|
|
+ itemGap: layout.w / 10,
|
|
|
top: '20%',
|
|
|
textStyle: {
|
|
|
- fontSize: getFontSize(l) * 0.7
|
|
|
+ fontSize: fontSize || getFontSize(layout) * 0.7
|
|
|
},
|
|
|
- data: s.map((v, i) => {
|
|
|
+ data: series.map((v, i) => {
|
|
|
return v.name
|
|
|
})
|
|
|
}
|
|
|
return legend;
|
|
|
}
|
|
|
|
|
|
-function getLayout(l) {
|
|
|
- let layout = {};
|
|
|
- for(let k in l) {
|
|
|
- layout[k] = l[k]/10
|
|
|
+function getLayout(layout) {
|
|
|
+ let l = {};
|
|
|
+ for(let k in layout) {
|
|
|
+ l[k] = layout[k]/10
|
|
|
}
|
|
|
- return layout;
|
|
|
+ return l;
|
|
|
}
|
|
|
|
|
|
function parseStr(str) {
|