123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- const Utils = {
- deepCopy: function(obj){
- if(obj === null){
- return obj;
- }
- var result = Array.isArray(obj) ? [] : {};
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- if (typeof obj[key] === 'object' && obj[key]!==null) {
- result[key] = this.deepCopy(obj[key]); //递归复制
- } else {
- result[key] = obj[key];
- }
- }
- }
- return result;
- },
- insertCommonTheme:function(config,curTheme){
- if (config.title) {
- if(config.title.sub.textStyle&&config.title.sub.textStyle.sub.color)config.title.sub.textStyle.sub.color.defaultValue = curTheme.theme.titleColor;
- if(config.title.sub.color) config.title.sub.color.defaultValue = curTheme.theme.titleColor;
- }
- if (config.bg.sub.textureColor) {
- config.bg.sub.textureColor.defaultValue = curTheme.theme.textureColor;
- }
- if(config.bg){
- config.bg.sub.backgroundColor.defaultValue = curTheme.theme.backgroundColor
- }
- if (config.tooltip) {
- if (config.tooltip.sub.bgStyle) config.tooltip.sub.bgStyle.sub.backgroundColor.defaultValue = curTheme.theme.backgroundColor;
- if (config.tooltip.sub.shadowStyle) config.tooltip.sub.shadowStyle.sub.shadowColor.defaultValue = curTheme.theme.shadowColor;
- if (config.tooltip.sub.titleColor) config.tooltip.sub.titleColor.defaultValue = curTheme.theme.titleColor;
- if (config.tooltip.sub.targetline) {
- config.tooltip.sub.targetline.sub.color.defaultValue = curTheme.theme.targetLineColor;
- config.tooltip.sub.dangerline.sub.color.defaultValue = curTheme.theme.dangerLineColor;
- }
- }
- if (config.legend) {
- if(config.legend.sub.textStyle&&config.legend.sub.textStyle.sub.color) config.legend.sub.textStyle.sub.color.defaultValue = curTheme.theme.textColor;
- if(config.legend.sub.color) config.legend.sub.color.defaultValue = curTheme.theme.textColor;
- if(config.legend.sub.borderColor) config.legend.sub.borderColor.defaultValue = curTheme.theme.lineColor;
- }
- if (config.xAxis) {
- config.xAxis.sub.nameTextStyle && (config.xAxis.sub.nameTextStyle.sub.color.defaultValue = curTheme.theme.textColor);
- if (config.xAxis.sub.axisLine) config.xAxis.sub.axisLine.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
- if (config.xAxis.sub.axisTick) config.xAxis.sub.axisTick.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
- if (config.xAxis.sub.splitLine) config.xAxis.sub.splitLine.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
- if (config.xAxis.sub.axisLabel) {
- if (config.xAxis.sub.axisLabel.sub.color) config.xAxis.sub.axisLabel.sub.color.defaultValue = curTheme.theme.textColor;
- if (config.xAxis.sub.axisLabel.sub.textStyle) config.xAxis.sub.axisLabel.sub.textStyle.sub.color.defaultValue = curTheme.theme.textColor;
- }
- if (config.xAxis.sub.highLightColor) {
- config.xAxis.sub.highLightColor.defaultValue = curTheme.theme.highLightColor;
- }
- }
- if (config.yAxis) {
- config.yAxis.sub.nameTextStyle && (config.yAxis.sub.nameTextStyle.sub.color.defaultValue = curTheme.theme.textColor);
- if (config.yAxis.sub.axisLine) {
- if (config.yAxis.sub.axisLine.sub.lineStyle) {
- config.yAxis.sub.axisLine.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
- }
- if (config.yAxis.sub.axisLine.sub.color) {
- config.yAxis.sub.axisLine.sub.color.defaultValue = curTheme.theme.lineColor;
- }
- }
- if (config.yAxis.sub.axisTick) config.yAxis.sub.axisTick.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
- if (config.yAxis.sub.splitLine) config.yAxis.sub.splitLine.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
- if (config.yAxis.sub.axisLabel) {
- if (config.yAxis.sub.axisLabel.sub.color) config.yAxis.sub.axisLabel.sub.color.defaultValue = curTheme.theme.textColor;
- if (config.yAxis.sub.axisLabel.sub.textStyle) config.yAxis.sub.axisLabel.sub.textStyle.sub.color.defaultValue = curTheme.theme.textColor;
- }
- if (config.yAxis.sub.highLightColor) {
- config.yAxis.sub.highLightColor.defaultValue = curTheme.theme.highLightColor;
- }
- if (config.yAxis.sub.lightSplitLine) {
- config.yAxis.sub.lightSplitLine.sub.color.defaultValue = curTheme.theme.lineColor;
- }
- if (config.yAxis.sub.darkSplitLine) {
- config.yAxis.sub.darkSplitLine.sub.color.defaultValue = curTheme.theme.darkSplitColor;
- }
- }
- if (config.dataZoom) {
- config.dataZoom.sub.zoomBackgroundColor.defaultValue = curTheme.theme.zoomBackgroundColor;
- config.dataZoom.sub.zoomAreaColor.defaultValue = curTheme.theme.zoomAreaColor;
- config.dataZoom.sub.zoomLineColor.defaultValue = curTheme.theme.zoomLineColor;
- config.dataZoom.sub.zoomHandleColor.defaultValue = curTheme.theme.zoomHandleColor;
- config.dataZoom.sub.zoomMaskColor.defaultValue = curTheme.theme.zoomMaskColor;
- }
- if (config.radar) {
- config.radar.sub.indicatorName.sub.color.defaultValue = curTheme.theme.textColor;
- config.radar.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
- }
-
- // if (config.funnel) {
- // config.funnel.sub.changePercent.sub.lineColor.defaultValue = curTheme.theme.lineColor;
- // if (config.funnel.sub.changePercent.sub.textColor) {
- // config.funnel.sub.changePercent.sub.textColor.defaultValue = curTheme.theme.textColor;
- // }
- // }
- if (config.table) {
- // noinspection JSAnnotator
- config.table.sub.headTextColor && (config.table.sub.headTextColor.defaultValue = curTheme.theme.textColor);
- config.table.sub.contentTextColor && (config.table.sub.contentTextColor.defaultValue = curTheme.theme.textColor);
- // noinspection JSAnnotator
- config.table.sub.headColor && (config.table.sub.headColor.defaultValue = curTheme.theme.tableHeaderColor);
- // noinspection JSAnnotator
- config.table.sub.fillColor1 && (config.table.sub.fillColor1.defaultValue = curTheme.theme.backgroundColor);
- // noinspection JSAnnotator
- config.table.sub.fillColor2 && (config.table.sub.fillColor2.defaultValue = curTheme.theme.rowColor);
- // noinspection JSAnnotator
- config.table.sub.outlineColor && (config.table.sub.outlineColor.defaultValue = curTheme.theme.lineColor);
- // noinspection JSAnnotator
- config.table.sub.sliderBlockColor && (config.table.sub.sliderBlockColor.defaultValue = curTheme.theme.textColor);
- // noinspection JSAnnotator
- config.table.sub.sliderBackColor && (config.table.sub.sliderBackColor.defaultValue = curTheme.theme.rowColor);
- }
- if (config.series && config.series.sub) {
- if (config.series.sub.colorList) {
- config.series.sub.colorList.defaultValue = curTheme.color;
- }
- }
- if (config.setMap) {
- config.setMap.sub.label.normal.sub.color.defaultValue = curTheme.theme.textColor;
- config.setMap.sub.itemStyle.normal.sub.borderColor.defaultValue = curTheme.theme.lineColor;
- }
-
- if (config.viewMap) {
- config.viewMap.sub.inRange.sub.colorST.defaultValue = curTheme.theme.visualMapLowColor;
- config.viewMap.sub.inRange.sub.colorED.defaultValue = curTheme.theme.visualMapHighColor;
- config.viewMap.sub.itemStyle.sub.color.defaultValue = curTheme.theme.textColor;
- }
- return config
- }
- }
-
- export default Utils;
|