echart.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import * as echarts from "echarts";
  2. export default function getData(params = []) {
  3. let resList = params.alarmList.map(val => {
  4. return {
  5. ...val,
  6. createTime: new Date(val.createTime).getDate()
  7. }
  8. }).reverse()
  9. let resList2 = params.unOnlineList.map(val => {
  10. return {
  11. ...val,
  12. createTime: new Date(val.createTime).getDate()
  13. }
  14. }).reverse()
  15. return {
  16. color: [
  17. "rgba(62,175,64,.8)",
  18. "rgba(239,107,61,.8)",
  19. ],
  20. title: {
  21. show: false,
  22. text: "渐变堆叠面积图",
  23. },
  24. tooltip: {
  25. trigger: "axis",
  26. textStyle: {
  27. color: "#FFF",
  28. },
  29. confine: true,
  30. backgroundColor: "rgba(11, 12, 72, 0.8)",
  31. borderColor: "rgba(11, 12, 72, 0.4)",
  32. position: "bottom",
  33. },
  34. legend: {
  35. show: true,
  36. top: 0,
  37. right: 10,
  38. itemGap: 20,
  39. textStyle: {
  40. color: "#FFF",
  41. },
  42. },
  43. // toolbox: {},
  44. grid: {
  45. top: 30,
  46. left: 10,
  47. right: 15,
  48. bottom: 10,
  49. containLabel: true,
  50. },
  51. xAxis: {
  52. type: "category",
  53. boundaryGap: false,
  54. data: resList.map(val => val.createTime),
  55. axisLabel: {
  56. color: "#FFFFFF",
  57. // rotate: 50,
  58. },
  59. axisTick: {
  60. show: false,
  61. },
  62. },
  63. yAxis: {
  64. type: "value",
  65. axisLabel: {
  66. color: "#FFFFFF",
  67. },
  68. splitLine: {
  69. lineStyle: {
  70. color: "#ccc",
  71. },
  72. },
  73. },
  74. series: [{
  75. name: "告警数",
  76. type: "line",
  77. smooth: true,
  78. showSymbol: true,
  79. areaStyle: {
  80. opacity: 0.8,
  81. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  82. offset: 0,
  83. color: "rgba(62,175,64)",
  84. },
  85. {
  86. offset: 1,
  87. color: "rgba(62,175,64,.1)",
  88. },
  89. ]),
  90. },
  91. data: resList.map(val => val.count),
  92. },
  93. {
  94. name: "离线数",
  95. type: "line",
  96. smooth: true,
  97. showSymbol: true,
  98. areaStyle: {
  99. opacity: 0.8,
  100. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  101. offset: 0,
  102. color: "rgba(62, 175, 64,1)",
  103. },
  104. {
  105. offset: 1,
  106. color: "rgba(62, 175, 64,.1)",
  107. },
  108. ]),
  109. },
  110. data: resList2.map(val => val.count),
  111. },
  112. ],
  113. }
  114. }