constant.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { graphic } from 'echarts';
  2. // 常量-echarts滚动轴设置
  3. const ECHARTS_OPTION_DATAZOOM = [
  4. {
  5. type: 'slider',
  6. start: 0,
  7. end: 100,
  8. height: '12px',
  9. showDetail:false,
  10. bottom: '0',
  11. borderRadius:'50%',
  12. moveHandleSize: 0,
  13. moveHandleStyle: {},
  14. handleSize: '80%',
  15. handleIcon:'path://M512,512m-448,0a448,448,0,1,0,896,0a448,448,0,1,0,-896,0Z',
  16. handleStyle: {
  17. borderWidth: 0,
  18. color: 'rgba(132,176,222,0.5)'
  19. }
  20. },
  21. {
  22. type: 'inside',
  23. start: 0,
  24. end: 100,
  25. }
  26. ]
  27. let echartsColors = [
  28. '#178FE6',
  29. '#3CC2AC',
  30. '#EE8242',
  31. ]
  32. let echartsGradientColors = [
  33. getEchartsGradientColor('#8BCFFF'),
  34. getEchartsGradientColor('#7EE6D4'),
  35. getEchartsGradientColor('#FFB78D'),
  36. ]
  37. function getEchartsGradientColor(color) {
  38. return new graphic.LinearGradient(0, 0, 0, 1, [{
  39. offset: 0,
  40. color: color // 0% 处的颜色
  41. }, {
  42. offset: 0.8,
  43. color: '#ffffff' // 100% 处的颜色
  44. }], false)
  45. }
  46. const ECHARTS_BAR_WIDTH = '30%'
  47. // 常量-时间范围快捷搜索条件
  48. const PICKER_OPTIONS = {
  49. shortcuts: [
  50. {
  51. text: "去年十二个月",
  52. onClick(picker) {
  53. const end = new Date(new Date().getFullYear() - 1, 11);
  54. const start = new Date(new Date().getFullYear() - 1, 0);
  55. picker.$emit("pick", [start, end]);
  56. }
  57. },
  58. {
  59. text: "今年至今",
  60. onClick(picker) {
  61. const end = new Date();
  62. const start = new Date(new Date().getFullYear(), 0);
  63. picker.$emit("pick", [start, end]);
  64. }
  65. },
  66. {
  67. text: "最近十二个月",
  68. onClick(picker) {
  69. const end = new Date();
  70. const start = new Date();
  71. start.setMonth(start.getMonth() - 11);
  72. picker.$emit("pick", [start, end]);
  73. }
  74. },
  75. {
  76. text: "最近六个月",
  77. onClick(picker) {
  78. const end = new Date();
  79. const start = new Date();
  80. start.setMonth(start.getMonth() - 5);
  81. picker.$emit("pick", [start, end]);
  82. }
  83. }
  84. ]
  85. }
  86. // 核心指标中的碳配额存量中的不同等级对应的icon颜色(1:绿色、2:黄色、3:红色)
  87. const COLOR_LEAVEL = {
  88. 1: "#67C23A",
  89. 2: "#E6A23C",
  90. 3: "#F56C6C"
  91. }
  92. // 折线图可选颜色
  93. const ECHART_LINE_COLOR_LIST = ["#303133", "#606266", "#909399", "#C0C4CC", "DCDFE6"];
  94. export default {
  95. PICKER_OPTIONS, COLOR_LEAVEL, ECHART_LINE_COLOR_LIST, ECHARTS_OPTION_DATAZOOM, ECHARTS_BAR_WIDTH,
  96. echartsColors, echartsGradientColors
  97. }