|
@@ -129,13 +129,8 @@ function barConfig(model) {
|
|
|
areaLeft = Number(areaconfig.left)>=0 ? areaconfig.left+'%' : '5%',
|
|
areaLeft = Number(areaconfig.left)>=0 ? areaconfig.left+'%' : '5%',
|
|
|
areaRight = Number(areaconfig.right)>=0 ? areaconfig.right+'%' : '5%',
|
|
areaRight = Number(areaconfig.right)>=0 ? areaconfig.right+'%' : '5%',
|
|
|
areaTop = Number(areaconfig.top)>=0 ? areaconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%'),
|
|
areaTop = Number(areaconfig.top)>=0 ? areaconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%'),
|
|
|
- areaBottom = Number(areaconfig.bottom)>=0 ? areaconfig.bottom+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%'),
|
|
|
|
|
-
|
|
|
|
|
- legendLeft = Number(legendconfig.left)>=0 ? legendconfig.left+'%' : null,
|
|
|
|
|
- legendTop = Number(legendconfig.top)>=0 ? legendconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
|
|
- itemGap = Number(legendconfig.itemGap)>=0 ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
|
|
- itemWidth = Number(legendconfig.itemWidth)>=0 ? Number(legendconfig.itemWidth) : 25,
|
|
|
|
|
- itemHeight = Number(legendconfig.itemHeight)>=0 ? Number(legendconfig.itemHeight) : 14;
|
|
|
|
|
|
|
+ areaBottom = Number(areaconfig.bottom)>=0 ? areaconfig.bottom+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%');
|
|
|
|
|
+
|
|
|
let o = {
|
|
let o = {
|
|
|
type: 'charts',
|
|
type: 'charts',
|
|
|
config: {
|
|
config: {
|
|
@@ -154,21 +149,7 @@ function barConfig(model) {
|
|
|
top: areaTop,
|
|
top: areaTop,
|
|
|
bottom: areaBottom
|
|
bottom: areaBottom
|
|
|
},
|
|
},
|
|
|
- legend: {
|
|
|
|
|
- show: !legendconfig.hide,
|
|
|
|
|
- top: legendTop,
|
|
|
|
|
- padding: 0,
|
|
|
|
|
- orient: legendconfig.orient || 'horizontal',
|
|
|
|
|
- itemGap: itemGap,
|
|
|
|
|
- itemWidth: itemWidth,
|
|
|
|
|
- itemHeight: itemHeight,
|
|
|
|
|
- textStyle: {
|
|
|
|
|
- fontSize: getFontSize() * 0.7
|
|
|
|
|
- },
|
|
|
|
|
- data: series.map((v, i) => {
|
|
|
|
|
- return v.name
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ legend: getBarLegend(fontSize, layout, series, legendconfig),
|
|
|
xAxis: [{
|
|
xAxis: [{
|
|
|
type: xtype,
|
|
type: xtype,
|
|
|
data: xf,
|
|
data: xf,
|
|
@@ -214,7 +195,7 @@ function barConfig(model) {
|
|
|
if(color && color.length > 0) {
|
|
if(color && color.length > 0) {
|
|
|
o.config.option.color = color;
|
|
o.config.option.color = color;
|
|
|
}
|
|
}
|
|
|
- legendLeft ? (o.config.option.legend.left = legendLeft) : (o.config.option.legend.right = '5%');
|
|
|
|
|
|
|
+
|
|
|
return o;
|
|
return o;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -234,14 +215,8 @@ function lineConfig(model) {
|
|
|
areaLeft = Number(areaconfig.left)>=0 ? areaconfig.left+'%' : '5%',
|
|
areaLeft = Number(areaconfig.left)>=0 ? areaconfig.left+'%' : '5%',
|
|
|
areaRight = Number(areaconfig.right)>=0 ? areaconfig.right+'%' : '5%',
|
|
areaRight = Number(areaconfig.right)>=0 ? areaconfig.right+'%' : '5%',
|
|
|
areaTop = Number(areaconfig.top)>=0 ? areaconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%'),
|
|
areaTop = Number(areaconfig.top)>=0 ? areaconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%'),
|
|
|
- areaBottom = Number(areaconfig.bottom)>=0 ? areaconfig.bottom+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%'),
|
|
|
|
|
|
|
+ areaBottom = Number(areaconfig.bottom)>=0 ? areaconfig.bottom+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%');
|
|
|
|
|
|
|
|
- legendLeft = Number(legendconfig.left)>=0 ? legendconfig.left+'%' : null,
|
|
|
|
|
- legendTop = Number(legendconfig.top)>=0 ? legendconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
|
|
- itemGap = Number(legendconfig.itemGap)>=0 ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
|
|
- itemWidth = Number(legendconfig.itemWidth)>=0 ? Number(legendconfig.itemWidth) : 25,
|
|
|
|
|
- itemHeight = Number(legendconfig.itemHeight)>=0 ? Number(legendconfig.itemHeight) : 14;
|
|
|
|
|
-
|
|
|
|
|
let o = {
|
|
let o = {
|
|
|
type: 'charts',
|
|
type: 'charts',
|
|
|
config: {
|
|
config: {
|
|
@@ -257,21 +232,7 @@ function lineConfig(model) {
|
|
|
top: areaTop,
|
|
top: areaTop,
|
|
|
bottom: areaBottom
|
|
bottom: areaBottom
|
|
|
},
|
|
},
|
|
|
- legend: {
|
|
|
|
|
- show: !legendconfig.hide,
|
|
|
|
|
- top: legendTop,
|
|
|
|
|
- padding: 0,
|
|
|
|
|
- orient: legendconfig.orient || 'horizontal',
|
|
|
|
|
- itemGap: itemGap,
|
|
|
|
|
- itemWidth: itemWidth,
|
|
|
|
|
- itemHeight: itemHeight,
|
|
|
|
|
- textStyle: {
|
|
|
|
|
- fontSize: fontSize || getFontSize() * 0.7
|
|
|
|
|
- },
|
|
|
|
|
- data: series.map((v, i) => {
|
|
|
|
|
- return v.name
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ legend: getLineLegend(fontSize, layout, series, legendconfig),
|
|
|
xAxis: [{
|
|
xAxis: [{
|
|
|
type: xtype,
|
|
type: xtype,
|
|
|
data: xf,
|
|
data: xf,
|
|
@@ -326,7 +287,7 @@ function lineConfig(model) {
|
|
|
if(color && color.length > 0) {
|
|
if(color && color.length > 0) {
|
|
|
o.config.option.color = color;
|
|
o.config.option.color = color;
|
|
|
}
|
|
}
|
|
|
- legendLeft ? (o.config.option.legend.left = legendLeft) : (o.config.option.legend.right = '5%');
|
|
|
|
|
|
|
+
|
|
|
return o;
|
|
return o;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -353,13 +314,8 @@ function mixChartConfig(model) {
|
|
|
areaLeft = Number(areaconfig.left)>=0 ? areaconfig.left+'%' : '5%',
|
|
areaLeft = Number(areaconfig.left)>=0 ? areaconfig.left+'%' : '5%',
|
|
|
areaRight = Number(areaconfig.right)>=0 ? areaconfig.right+'%' : '5%',
|
|
areaRight = Number(areaconfig.right)>=0 ? areaconfig.right+'%' : '5%',
|
|
|
areaTop = Number(areaconfig.top)>=0 ? areaconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%'),
|
|
areaTop = Number(areaconfig.top)>=0 ? areaconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%'),
|
|
|
- areaBottom = Number(areaconfig.bottom)>=0 ? areaconfig.bottom+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%'),
|
|
|
|
|
|
|
+ areaBottom = Number(areaconfig.bottom)>=0 ? areaconfig.bottom+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '16%');
|
|
|
|
|
|
|
|
- legendLeft = Number(legendconfig.left)>=0 ? legendconfig.left+'%' : null,
|
|
|
|
|
- legendTop = Number(legendconfig.top)>=0 ? legendconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
|
|
- itemGap = Number(legendconfig.itemGap)>=0 ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
|
|
- itemWidth = Number(legendconfig.itemWidth)>=0 ? Number(legendconfig.itemWidth) : 25,
|
|
|
|
|
- itemHeight = Number(legendconfig.itemHeight)>=0 ? Number(legendconfig.itemHeight) : 14;
|
|
|
|
|
var o = {
|
|
var o = {
|
|
|
type: 'charts',
|
|
type: 'charts',
|
|
|
config: {
|
|
config: {
|
|
@@ -368,21 +324,7 @@ function mixChartConfig(model) {
|
|
|
tooltip: {
|
|
tooltip: {
|
|
|
trigger: 'axis'
|
|
trigger: 'axis'
|
|
|
},
|
|
},
|
|
|
- legend: {
|
|
|
|
|
- show: !legendconfig.hide,
|
|
|
|
|
- top: legendTop,
|
|
|
|
|
- padding: 0,
|
|
|
|
|
- orient: legendconfig.orient || 'horizontal',
|
|
|
|
|
- itemGap: itemGap,
|
|
|
|
|
- itemWidth: itemWidth,
|
|
|
|
|
- itemHeight: itemHeight,
|
|
|
|
|
- textStyle: {
|
|
|
|
|
- fontSize: fontSize || getFontSize() * 0.7
|
|
|
|
|
- },
|
|
|
|
|
- data: series.map((v, i) => {
|
|
|
|
|
- return v.name
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ legend: getMixChartLegend(),
|
|
|
grid: {
|
|
grid: {
|
|
|
containLabel: true,
|
|
containLabel: true,
|
|
|
top: areaTop,
|
|
top: areaTop,
|
|
@@ -445,7 +387,6 @@ function mixChartConfig(model) {
|
|
|
},
|
|
},
|
|
|
layout: getLayout(layout)
|
|
layout: getLayout(layout)
|
|
|
};
|
|
};
|
|
|
- legendLeft ? (o.config.option.legend.left = legendLeft) : (o.config.option.legend.right = '5%');
|
|
|
|
|
|
|
|
|
|
return o;
|
|
return o;
|
|
|
}
|
|
}
|
|
@@ -554,6 +495,34 @@ function getBarSeries(fontSize, layout, series, barconfig) {
|
|
|
return s;
|
|
return s;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function getBarLegend(fontSize, layout, series, legendconfig) {
|
|
|
|
|
+ let legendLeft = Number(legendconfig.left)>=0 ? legendconfig.left+'%' : null,
|
|
|
|
|
+ legendTop = Number(legendconfig.top)>=0 ? legendconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
|
|
+ itemGap = Number(legendconfig.itemGap)>=0 ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
|
|
+ itemWidth = Number(legendconfig.itemWidth)>=0 ? Number(legendconfig.itemWidth) : 25,
|
|
|
|
|
+ itemHeight = Number(legendconfig.itemHeight)>=0 ? Number(legendconfig.itemHeight) : 14;
|
|
|
|
|
+
|
|
|
|
|
+ let legend = {
|
|
|
|
|
+ show: !legendconfig.hide,
|
|
|
|
|
+ top: legendTop,
|
|
|
|
|
+ padding: 0,
|
|
|
|
|
+ orient: legendconfig.orient || 'horizontal',
|
|
|
|
|
+ itemGap: itemGap,
|
|
|
|
|
+ itemWidth: itemWidth,
|
|
|
|
|
+ itemHeight: itemHeight,
|
|
|
|
|
+ textStyle: {
|
|
|
|
|
+ fontSize: getFontSize() * 0.7
|
|
|
|
|
+ },
|
|
|
|
|
+ data: series.map((v, i) => {
|
|
|
|
|
+ return v.name
|
|
|
|
|
+ })
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ legendLeft ? (legend.left = legendLeft) : (legend.right = '5%');
|
|
|
|
|
+
|
|
|
|
|
+ return legend;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function getLineSeries(fontSize, series, lineconfig) {
|
|
function getLineSeries(fontSize, series, lineconfig) {
|
|
|
let s = [],
|
|
let s = [],
|
|
|
areaStyleCfg = lineconfig.areaStyle || '{}';
|
|
areaStyleCfg = lineconfig.areaStyle || '{}';
|
|
@@ -676,6 +645,34 @@ function getLineSeries(fontSize, series, lineconfig) {
|
|
|
return s;
|
|
return s;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function getLineLegend(fontSize, layout, series, legendconfig) {
|
|
|
|
|
+ let legendLeft = Number(legendconfig.left)>=0 ? legendconfig.left+'%' : null,
|
|
|
|
|
+ legendTop = Number(legendconfig.top)>=0 ? legendconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
|
|
+ itemGap = Number(legendconfig.itemGap)>=0 ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
|
|
+ itemWidth = Number(legendconfig.itemWidth)>=0 ? Number(legendconfig.itemWidth) : 25,
|
|
|
|
|
+ itemHeight = Number(legendconfig.itemHeight)>=0 ? Number(legendconfig.itemHeight) : 14;
|
|
|
|
|
+
|
|
|
|
|
+ let legend = {
|
|
|
|
|
+ show: !legendconfig.hide,
|
|
|
|
|
+ top: legendTop,
|
|
|
|
|
+ padding: 0,
|
|
|
|
|
+ orient: legendconfig.orient || 'horizontal',
|
|
|
|
|
+ itemGap: itemGap,
|
|
|
|
|
+ itemWidth: itemWidth,
|
|
|
|
|
+ itemHeight: itemHeight,
|
|
|
|
|
+ textStyle: {
|
|
|
|
|
+ fontSize: fontSize || getFontSize() * 0.7
|
|
|
|
|
+ },
|
|
|
|
|
+ data: series.map((v, i) => {
|
|
|
|
|
+ return v.name
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ legendLeft ? (legend.left = legendLeft) : (legend.right = '5%');
|
|
|
|
|
+
|
|
|
|
|
+ return legend;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
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}];
|
|
|
|
|
|
|
@@ -726,7 +723,13 @@ function getPieLegend(fontSize, layout, series, legendconfig) {
|
|
|
left = legendconfig.left ? 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,
|
|
|
|
|
+ formatter = legendconfig.formatter || '{name}';
|
|
|
|
|
+
|
|
|
|
|
+ let dataMap = {};
|
|
|
|
|
+ series.map(function(s) {
|
|
|
|
|
+ dataMap[s.name] = s.value;
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
let legend = {
|
|
let legend = {
|
|
|
show: !hide,
|
|
show: !hide,
|
|
@@ -744,7 +747,14 @@ function getPieLegend(fontSize, layout, series, legendconfig) {
|
|
|
},
|
|
},
|
|
|
data: series.map((v, i) => {
|
|
data: series.map((v, i) => {
|
|
|
return v.name || 'Unkonw';
|
|
return v.name || 'Unkonw';
|
|
|
- })
|
|
|
|
|
|
|
+ }),
|
|
|
|
|
+ formatter: function(name) {
|
|
|
|
|
+ let value = dataMap[name],
|
|
|
|
|
+ label = '';
|
|
|
|
|
+
|
|
|
|
|
+ label = formatter.replace('{name}', name).replace('{value}', value);
|
|
|
|
|
+ return label;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if(series.length == 0) {
|
|
if(series.length == 0) {
|
|
|
legend.data = ['无数据']
|
|
legend.data = ['无数据']
|
|
@@ -825,6 +835,34 @@ function getMixChartSeries(fontSize, layout, series, barconfig, lineconfig, barc
|
|
|
return s;
|
|
return s;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function getMixChartLegend(fontSize, layout, series, legendconfig) {
|
|
|
|
|
+ let legendLeft = Number(legendconfig.left)>=0 ? legendconfig.left+'%' : null,
|
|
|
|
|
+ legendTop = Number(legendconfig.top)>=0 ? legendconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '20%' : '18%'),
|
|
|
|
|
+ itemGap = Number(legendconfig.itemGap)>=0 ? Number(legendconfig.itemGap) : layout.w / 10,
|
|
|
|
|
+ itemWidth = Number(legendconfig.itemWidth)>=0 ? Number(legendconfig.itemWidth) : 25,
|
|
|
|
|
+ itemHeight = Number(legendconfig.itemHeight)>=0 ? Number(legendconfig.itemHeight) : 14;
|
|
|
|
|
+
|
|
|
|
|
+ let legend = {
|
|
|
|
|
+ show: !legendconfig.hide,
|
|
|
|
|
+ top: legendTop,
|
|
|
|
|
+ padding: 0,
|
|
|
|
|
+ orient: legendconfig.orient || 'horizontal',
|
|
|
|
|
+ itemGap: itemGap,
|
|
|
|
|
+ itemWidth: itemWidth,
|
|
|
|
|
+ itemHeight: itemHeight,
|
|
|
|
|
+ textStyle: {
|
|
|
|
|
+ fontSize: fontSize || getFontSize() * 0.7
|
|
|
|
|
+ },
|
|
|
|
|
+ data: series.map((v, i) => {
|
|
|
|
|
+ return v.name
|
|
|
|
|
+ })
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ legendLeft ? (legend.left = legendLeft) : (legend.right = '5%');
|
|
|
|
|
+
|
|
|
|
|
+ return legend;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function getLayout(layout) {
|
|
function getLayout(layout) {
|
|
|
let l = {};
|
|
let l = {};
|
|
|
for (let k in layout) {
|
|
for (let k in layout) {
|