|
|
@@ -6,6 +6,7 @@ import EllipsisTooltip from '../components/common/ellipsisTooltip/index'
|
|
|
import { deepAssign, numberFormat } from '../utils/baseUtils'
|
|
|
import STATISTICS_OPTION from '../components/chartDesigner/sections/statisticsOption.json'
|
|
|
import themes from '../components/chartDesigner/sections/style/theme/index'
|
|
|
+import EChartsMedia from './EChartsMedia'
|
|
|
|
|
|
export default function(viewType, data, chartConfig, themeName, styleConfig) {
|
|
|
if(!data) {
|
|
|
@@ -58,7 +59,7 @@ export default function(viewType, data, chartConfig, themeName, styleConfig) {
|
|
|
function barOption(data, barConfig, themeConfig, styleConfig) {
|
|
|
const { xAxis, yAxis, groupBy } = barConfig;
|
|
|
const { barMaxWidth, barMinHeight, barGap, stack, labelVisible, labelPosition, labelDistance,
|
|
|
- labelRotate, xNameLocation, xNameGap, xNameRotate, xLabelHiddenCover, xLabelRotate,
|
|
|
+ labelRotate, xNameLocation, xNameGap, xNameRotate, xLabelHiddenCover, xLabelRotate, dataZoomVisible,
|
|
|
xLabelMargin, yNameLocation, yNameGap, yNameRotate, labelZeroVisible } = styleConfig;
|
|
|
let xTitle = xAxis?`${xAxis.column.label}${xAxis.granularity.value?'('+xAxis.granularity.label+')':''}`:null
|
|
|
let yTitle = yAxis?`${yAxis.column.label}${yAxis.gauge.value?'('+yAxis.gauge.label+')':''}`:null
|
|
|
@@ -135,40 +136,13 @@ function barOption(data, barConfig, themeConfig, styleConfig) {
|
|
|
}
|
|
|
}),
|
|
|
dataZoom: {
|
|
|
- show: false
|
|
|
+ show: !!dataZoomVisible
|
|
|
}
|
|
|
}, themeConfig);
|
|
|
|
|
|
let mediaOption = {
|
|
|
baseOption: option,
|
|
|
- media: legendVisible ? [{
|
|
|
- query: { minWidth: 1000, minHeight: 1000 }, // I
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '20%'} }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, minHeight: 1000 }, // H
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, minHeight: 1000 }, // G
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { minWidth: 1000, maxHeight: 1000 }, // F
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '16%' } }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, maxHeight: 1000 }, // E
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, maxHeight: 1000 }, // D
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { minWidth: 1000, maxHeight: 500 }, // C
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '20%'} }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, maxHeight: 500 }, // B
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, grid: { top: 30, left: 80, right: 80 } }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, maxHeight: 500 }, // A
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, grid: { top: 30, left: 80, right: 80 } }
|
|
|
- }] : []
|
|
|
+ media: EChartsMedia('bar', legendVisible, dataZoomVisible)
|
|
|
}
|
|
|
|
|
|
return mediaOption;
|
|
|
@@ -177,7 +151,7 @@ function barOption(data, barConfig, themeConfig, styleConfig) {
|
|
|
function lineOption(data, lineConfig, themeConfig, styleConfig) {
|
|
|
const { labelSymbol, xNameLocation, xNameGap, xNameRotate, xLabelRotate, xLabelMargin,
|
|
|
yNameLocation, yNameGap, yNameRotate, stack, labelVisible, labelPosition, labelDistance, labelRotate,
|
|
|
- lineSmooth, labelSymbolSize } = styleConfig;
|
|
|
+ lineSmooth, labelSymbolSize, dataZoomVisible } = styleConfig;
|
|
|
const { xAxis, yAxis, groupBy } = lineConfig;
|
|
|
let xTitle = xAxis?`${xAxis.column.label}${xAxis.granularity.value?'('+xAxis.granularity.label+')':''}`:null
|
|
|
let yTitle = yAxis?`${yAxis.column.label}${yAxis.gauge.value?'('+yAxis.gauge.label+')':''}`:null
|
|
|
@@ -213,7 +187,7 @@ function lineOption(data, lineConfig, themeConfig, styleConfig) {
|
|
|
nameRotate: (yNameRotate === '' || yNameRotate === null || yNameRotate === undefined) ? 0 : Number(yNameRotate),
|
|
|
}],
|
|
|
|
|
|
- series: (data.serieses || []).map(s => {
|
|
|
+ series: data.serieses.map(s => {
|
|
|
return {
|
|
|
name: s.name,
|
|
|
type: 'line',
|
|
|
@@ -233,45 +207,18 @@ function lineOption(data, lineConfig, themeConfig, styleConfig) {
|
|
|
symbolSize: (labelSymbolSize === '' || labelSymbolSize === null || labelSymbolSize === undefined) ? 4 : Number(labelSymbolSize),
|
|
|
smooth: !!lineSmooth,
|
|
|
data: s.mdata.map(m => {
|
|
|
- return [m.date, numberFormat(m.value)]
|
|
|
+ return m ? [m.date, numberFormat(m.value)] : [null, 0]
|
|
|
}).sort((a, b) => {return new Date(a[0]).getTime() - new Date(b[0]).getTime()} )
|
|
|
}
|
|
|
}),
|
|
|
dataZoom: {
|
|
|
- show: false
|
|
|
+ show: !!dataZoomVisible
|
|
|
}
|
|
|
}, themeConfig, styleConfig);
|
|
|
|
|
|
let mediaOption = {
|
|
|
baseOption: option,
|
|
|
- media: legendVisible ? [{
|
|
|
- query: { minWidth: 1000, minHeight: 1000 }, // I
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '20%'} }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, minHeight: 1000 }, // H
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, minHeight: 1000 }, // G
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { minWidth: 1000, maxHeight: 1000 }, // F
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '16%' } }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, maxHeight: 1000 }, // E
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, maxHeight: 1000 }, // D
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { minWidth: 1000, maxHeight: 500 }, // C
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '20%'} }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, maxHeight: 500 }, // B
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, grid: { top: 30, left: 80, right: 80 } }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, maxHeight: 500 }, // A
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, grid: { top: 30, left: 80, right: 80 } }
|
|
|
- }] : []
|
|
|
+ media: EChartsMedia('line', legendVisible, dataZoomVisible)
|
|
|
}
|
|
|
|
|
|
return mediaOption;
|
|
|
@@ -364,52 +311,16 @@ function pieOption(data, pieConfig, themeConfig, styleConfig) {
|
|
|
}]
|
|
|
}, themeConfig);
|
|
|
|
|
|
- /**
|
|
|
- * | G | H | I
|
|
|
- * 1000 +----+----+---
|
|
|
- * | D | E | F
|
|
|
- * 500 +----+----+---
|
|
|
- * | A | B | C
|
|
|
- * 0 +----+----+---
|
|
|
- * 0 500 1000
|
|
|
- */
|
|
|
let mediaOption = {
|
|
|
baseOption: option,
|
|
|
- media: [{
|
|
|
- query: { minWidth: 1000, minHeight: 1000 }, // I
|
|
|
- option: { legend: { type: 'scroll', top: 'center', right: 50, orient: 'vertical', width: '35%' }, series: [{ radius: [0, '65%'], center: ['35%', '50%'] }] }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, minHeight: 1000 }, // H
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, series: [{ radius: [0, '55%'], center: ['50%', '40%'] }] }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, minHeight: 1000 }, // G
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, series: [{ radius: [0, '65%'], center: ['50%', '55%'] }] }
|
|
|
- }, {
|
|
|
- query: { minWidth: 1000, maxHeight: 1000 }, // F
|
|
|
- option: { legend: { type: 'scroll', top: 'center', right: 50, orient: 'vertical', width: '35%' }, series: [{ radius: [0, '65%'], center: ['35%', '50%'] }] }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, maxHeight: 1000 }, // E
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, series: [{ radius: [0, '55%'], center: ['50%', '40%'] }] }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, maxHeight: 1000 }, // D
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, series: [{ radius: [0, '55%'], center: ['50%', '40%'] }] }
|
|
|
- }, {
|
|
|
- query: { minWidth: 1000, maxHeight: 500 }, // C
|
|
|
- option: { legend: { type: 'scroll', top: 'center', right: 50, orient: 'vertical', width: '35%' }, series: [{ radius: [0, '65%'], center: ['35%', '50%'] }] }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, maxHeight: 500 }, // B
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, series: [{ radius: [0, '65%'], center: ['50%', '45%'] }] }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, maxHeight: 500 }, // A
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, series: [{ radius: [0, '65%'], center: ['50%', '45%'] }] }
|
|
|
- }]
|
|
|
+ media: EChartsMedia('pie')
|
|
|
}
|
|
|
|
|
|
return mediaOption;
|
|
|
}
|
|
|
|
|
|
function scatterOption(data, scatterConfig, themeConfig, styleConfig) {
|
|
|
- const { labelSymbol,xNameLocation, xNameGap, xNameRotate, xLabelRotate, xLabelMargin, yNameLocation, yNameGap, yNameRotate, labelSymbolSize, xLabelHiddenCover } = styleConfig;
|
|
|
+ const { labelSymbol, xNameLocation, xNameGap, xNameRotate, yNameLocation, yNameGap, yNameRotate, labelSymbolSize, dataZoomVisible } = styleConfig;
|
|
|
const { xAxis, yAxis, groupBy } = scatterConfig;
|
|
|
let xTitle = xAxis?`${xAxis.column.label}${xAxis.granularity.value?'('+xAxis.granularity.label+')':''}`:null
|
|
|
let yTitle = yAxis?`${yAxis.column.label}${yAxis.gauge.value?'('+yAxis.gauge.label+')':''}`:null
|
|
|
@@ -431,11 +342,6 @@ function scatterOption(data, scatterConfig, themeConfig, styleConfig) {
|
|
|
nameLocation: (xNameLocation === '' || xNameLocation === null || xNameLocation === undefined) ? 'end' : xNameLocation,
|
|
|
nameGap: (xNameGap === '' || xNameGap === null || xNameGap === undefined) ? 15 : Number(xNameGap),
|
|
|
nameRotate: (xNameRotate === '' || xNameRotate === null || xNameRotate === undefined) ? 0 : Number(xNameRotate),
|
|
|
- axisLabel: {
|
|
|
- interval: xLabelHiddenCover === undefined ? 'auto' : (!!xLabelHiddenCover ? 'auto' : 0),
|
|
|
- rotate: (xLabelRotate === '' || xLabelRotate === null || xLabelRotate === undefined) ? 0 : Number(xLabelRotate),
|
|
|
- margin: (xLabelMargin === '' || xLabelMargin === null || xLabelMargin === undefined) ? 8 : Number(xLabelMargin),
|
|
|
- },
|
|
|
scale:true,
|
|
|
splitLine: {
|
|
|
show: true
|
|
|
@@ -464,40 +370,13 @@ function scatterOption(data, scatterConfig, themeConfig, styleConfig) {
|
|
|
}
|
|
|
}),
|
|
|
dataZoom: {
|
|
|
- show: false
|
|
|
+ show: !!dataZoomVisible
|
|
|
}
|
|
|
}, themeConfig);
|
|
|
|
|
|
let mediaOption = {
|
|
|
baseOption: option,
|
|
|
- media: legendVisible ? [{
|
|
|
- query: { minWidth: 1000, minHeight: 1000 }, // I
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '20%'} }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, minHeight: 1000 }, // H
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, minHeight: 1000 }, // G
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { minWidth: 1000, maxHeight: 1000 }, // F
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '16%' } }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, maxHeight: 1000 }, // E
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 50, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, maxHeight: 1000 }, // D
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, }
|
|
|
- }, {
|
|
|
- query: { minWidth: 1000, maxHeight: 500 }, // C
|
|
|
- option: { legend: { type: 'scroll', top: 50, right: 50, orient: 'vertical', width: '35%' }, grid: { right: '20%'} }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 1000, maxHeight: 500 }, // B
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, grid: { top: 30, left: 80, right: 80 } }
|
|
|
- }, {
|
|
|
- query: { maxWidth: 500, maxHeight: 500 }, // A
|
|
|
- option: { legend: { type: 'scroll', right: 'center', bottom: 0, orient: 'horizontal', width: '90%' }, grid: { top: 30, left: 80, right: 80 } }
|
|
|
- }] : []
|
|
|
+ media: EChartsMedia('scatter', legendVisible, dataZoomVisible)
|
|
|
}
|
|
|
|
|
|
return mediaOption;
|