自定义组件库-封装第三方图表,如echarts
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

index.js 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. const Utils = {
  2. deepCopy: function(obj){
  3. if(obj === null){
  4. return obj;
  5. }
  6. var result = Array.isArray(obj) ? [] : {};
  7. for (var key in obj) {
  8. if (obj.hasOwnProperty(key)) {
  9. if (typeof obj[key] === 'object' && obj[key]!==null) {
  10. result[key] = this.deepCopy(obj[key]); //递归复制
  11. } else {
  12. result[key] = obj[key];
  13. }
  14. }
  15. }
  16. return result;
  17. },
  18. insertCommonTheme:function(config,curTheme){
  19. if (config.title) {
  20. if(config.title.sub.textStyle&&config.title.sub.textStyle.sub.color)config.title.sub.textStyle.sub.color.defaultValue = curTheme.theme.titleColor;
  21. if(config.title.sub.color) config.title.sub.color.defaultValue = curTheme.theme.titleColor;
  22. }
  23. if (config.bg.sub.textureColor) {
  24. config.bg.sub.textureColor.defaultValue = curTheme.theme.textureColor;
  25. }
  26. if(config.bg){
  27. config.bg.sub.backgroundColor.defaultValue = curTheme.theme.backgroundColor
  28. }
  29. if (config.tooltip) {
  30. if (config.tooltip.sub.bgStyle) config.tooltip.sub.bgStyle.sub.backgroundColor.defaultValue = curTheme.theme.backgroundColor;
  31. if (config.tooltip.sub.shadowStyle) config.tooltip.sub.shadowStyle.sub.shadowColor.defaultValue = curTheme.theme.shadowColor;
  32. if (config.tooltip.sub.titleColor) config.tooltip.sub.titleColor.defaultValue = curTheme.theme.titleColor;
  33. if (config.tooltip.sub.targetline) {
  34. config.tooltip.sub.targetline.sub.color.defaultValue = curTheme.theme.targetLineColor;
  35. config.tooltip.sub.dangerline.sub.color.defaultValue = curTheme.theme.dangerLineColor;
  36. }
  37. }
  38. if (config.legend) {
  39. if(config.legend.sub.textStyle&&config.legend.sub.textStyle.sub.color) config.legend.sub.textStyle.sub.color.defaultValue = curTheme.theme.textColor;
  40. if(config.legend.sub.color) config.legend.sub.color.defaultValue = curTheme.theme.textColor;
  41. if(config.legend.sub.borderColor) config.legend.sub.borderColor.defaultValue = curTheme.theme.lineColor;
  42. }
  43. if (config.xAxis) {
  44. config.xAxis.sub.nameTextStyle && (config.xAxis.sub.nameTextStyle.sub.color.defaultValue = curTheme.theme.textColor);
  45. if (config.xAxis.sub.axisLine) config.xAxis.sub.axisLine.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
  46. if (config.xAxis.sub.axisTick) config.xAxis.sub.axisTick.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
  47. if (config.xAxis.sub.splitLine) config.xAxis.sub.splitLine.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
  48. if (config.xAxis.sub.axisLabel) {
  49. if (config.xAxis.sub.axisLabel.sub.color) config.xAxis.sub.axisLabel.sub.color.defaultValue = curTheme.theme.textColor;
  50. if (config.xAxis.sub.axisLabel.sub.textStyle) config.xAxis.sub.axisLabel.sub.textStyle.sub.color.defaultValue = curTheme.theme.textColor;
  51. }
  52. if (config.xAxis.sub.highLightColor) {
  53. config.xAxis.sub.highLightColor.defaultValue = curTheme.theme.highLightColor;
  54. }
  55. }
  56. if (config.yAxis) {
  57. config.yAxis.sub.nameTextStyle && (config.yAxis.sub.nameTextStyle.sub.color.defaultValue = curTheme.theme.textColor);
  58. if (config.yAxis.sub.axisLine) {
  59. if (config.yAxis.sub.axisLine.sub.lineStyle) {
  60. config.yAxis.sub.axisLine.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
  61. }
  62. if (config.yAxis.sub.axisLine.sub.color) {
  63. config.yAxis.sub.axisLine.sub.color.defaultValue = curTheme.theme.lineColor;
  64. }
  65. }
  66. if (config.yAxis.sub.axisTick) config.yAxis.sub.axisTick.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
  67. if (config.yAxis.sub.splitLine) config.yAxis.sub.splitLine.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
  68. if (config.yAxis.sub.axisLabel) {
  69. if (config.yAxis.sub.axisLabel.sub.color) config.yAxis.sub.axisLabel.sub.color.defaultValue = curTheme.theme.textColor;
  70. if (config.yAxis.sub.axisLabel.sub.textStyle) config.yAxis.sub.axisLabel.sub.textStyle.sub.color.defaultValue = curTheme.theme.textColor;
  71. }
  72. if (config.yAxis.sub.highLightColor) {
  73. config.yAxis.sub.highLightColor.defaultValue = curTheme.theme.highLightColor;
  74. }
  75. if (config.yAxis.sub.lightSplitLine) {
  76. config.yAxis.sub.lightSplitLine.sub.color.defaultValue = curTheme.theme.lineColor;
  77. }
  78. if (config.yAxis.sub.darkSplitLine) {
  79. config.yAxis.sub.darkSplitLine.sub.color.defaultValue = curTheme.theme.darkSplitColor;
  80. }
  81. }
  82. if (config.dataZoom) {
  83. config.dataZoom.sub.zoomBackgroundColor.defaultValue = curTheme.theme.zoomBackgroundColor;
  84. config.dataZoom.sub.zoomAreaColor.defaultValue = curTheme.theme.zoomAreaColor;
  85. config.dataZoom.sub.zoomLineColor.defaultValue = curTheme.theme.zoomLineColor;
  86. config.dataZoom.sub.zoomHandleColor.defaultValue = curTheme.theme.zoomHandleColor;
  87. config.dataZoom.sub.zoomMaskColor.defaultValue = curTheme.theme.zoomMaskColor;
  88. }
  89. if (config.radar) {
  90. config.radar.sub.indicatorName.sub.color.defaultValue = curTheme.theme.textColor;
  91. config.radar.sub.lineStyle.sub.color.defaultValue = curTheme.theme.lineColor;
  92. }
  93. // if (config.funnel) {
  94. // config.funnel.sub.changePercent.sub.lineColor.defaultValue = curTheme.theme.lineColor;
  95. // if (config.funnel.sub.changePercent.sub.textColor) {
  96. // config.funnel.sub.changePercent.sub.textColor.defaultValue = curTheme.theme.textColor;
  97. // }
  98. // }
  99. if (config.table) {
  100. // noinspection JSAnnotator
  101. config.table.sub.headTextColor && (config.table.sub.headTextColor.defaultValue = curTheme.theme.textColor);
  102. config.table.sub.contentTextColor && (config.table.sub.contentTextColor.defaultValue = curTheme.theme.textColor);
  103. // noinspection JSAnnotator
  104. config.table.sub.headColor && (config.table.sub.headColor.defaultValue = curTheme.theme.tableHeaderColor);
  105. // noinspection JSAnnotator
  106. config.table.sub.fillColor1 && (config.table.sub.fillColor1.defaultValue = curTheme.theme.backgroundColor);
  107. // noinspection JSAnnotator
  108. config.table.sub.fillColor2 && (config.table.sub.fillColor2.defaultValue = curTheme.theme.rowColor);
  109. // noinspection JSAnnotator
  110. config.table.sub.outlineColor && (config.table.sub.outlineColor.defaultValue = curTheme.theme.lineColor);
  111. // noinspection JSAnnotator
  112. config.table.sub.sliderBlockColor && (config.table.sub.sliderBlockColor.defaultValue = curTheme.theme.textColor);
  113. // noinspection JSAnnotator
  114. config.table.sub.sliderBackColor && (config.table.sub.sliderBackColor.defaultValue = curTheme.theme.rowColor);
  115. }
  116. if (config.series && config.series.sub) {
  117. if (config.series.sub.colorList) {
  118. config.series.sub.colorList.defaultValue = curTheme.color;
  119. }
  120. }
  121. if (config.setMap) {
  122. config.setMap.sub.label.normal.sub.color.defaultValue = curTheme.theme.textColor;
  123. config.setMap.sub.itemStyle.normal.sub.borderColor.defaultValue = curTheme.theme.lineColor;
  124. }
  125. if (config.viewMap) {
  126. config.viewMap.sub.inRange.sub.colorST.defaultValue = curTheme.theme.visualMapLowColor;
  127. config.viewMap.sub.inRange.sub.colorED.defaultValue = curTheme.theme.visualMapHighColor;
  128. config.viewMap.sub.itemStyle.sub.color.defaultValue = curTheme.theme.textColor;
  129. }
  130. return config
  131. }
  132. }
  133. export default Utils;