LineChart.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div id="lineChartRef"></div>
  3. </template>
  4. <script>
  5. import { ref, onMounted, computed, inject } from "vue";
  6. import { mapState } from "vuex";
  7. import exchangeUrl from "utils/exchangeUrl";
  8. export default {
  9. setup() {
  10. let echarts = inject("ec");
  11. let lineChart = ref({});
  12. let option = ref({
  13. title: {
  14. text: "汇很多航运数字经济区块链认证",
  15. textStyle: {
  16. fontSize: "16",
  17. fontFamily: " PingFangSC-Semibold, PingFang SC",
  18. fontWeight: 600,
  19. color: " #F9FFFF",
  20. },
  21. top: "45",
  22. left: "40",
  23. },
  24. legend: {
  25. data: ["货种", "吨位"],
  26. bottom: "10px",
  27. icon: "path://M102.4 443.904h819.2v136.704H102.4z",
  28. textStyle: {
  29. fontSize: "12",
  30. fontFamily: "PingFangSC-Regular, PingFang SC",
  31. fontWeight: 400,
  32. color: " #9199A3",
  33. },
  34. itemGap: 50,
  35. },
  36. grid: {
  37. top: "110",
  38. left: "40",
  39. right: "40",
  40. bottom: "50",
  41. containLabel: true,
  42. },
  43. xAxis: {
  44. type: "category",
  45. boundaryGap: false,
  46. data: [
  47. "9-21 00:00",
  48. "9-21 00:00",
  49. "9-22 00:00",
  50. "9-23 00:00",
  51. "9-24 00:00",
  52. "9-25 00:00",
  53. "9-26 00:00",
  54. ],
  55. },
  56. yAxis: {
  57. type: "value",
  58. },
  59. splitLine: {
  60. show: true,
  61. lineStyle: {
  62. type: "dashed", //默认实线,dashed虚线
  63. width: 10,
  64. color: "#000",
  65. },
  66. },
  67. series: [
  68. {
  69. name: "货种",
  70. data: [0.42, 0.35, 0.71, 0.67, 0.85, 0.52, 0.79],
  71. type: "line",
  72. symbolSize: 0,
  73. itemStyle: {
  74. lineStyle: {
  75. color: "#5B8FF9",
  76. },
  77. },
  78. areaStyle: {
  79. //右,下,左,上
  80. color: new echarts.graphic.LinearGradient(
  81. 0,
  82. 0,
  83. 0,
  84. 1,
  85. [
  86. {
  87. offset: 0,
  88. color: "#091e3b",
  89. },
  90. {
  91. offset: 1,
  92. color: "#1b293c",
  93. },
  94. ],
  95. false
  96. ),
  97. },
  98. },
  99. {
  100. name: "吨位",
  101. data: [0.32, 0.25, 0.51, 0.37, 0.65, 0.32, 0.69],
  102. type: "line",
  103. symbolSize: 0,
  104. itemStyle: {
  105. lineStyle: {
  106. color: "#5AD8A6",
  107. },
  108. },
  109. areaStyle: {
  110. //右,下,左,上
  111. color: new echarts.graphic.LinearGradient(
  112. 0,
  113. 0,
  114. 0,
  115. 1,
  116. [
  117. {
  118. offset: 0,
  119. color: "#203748",
  120. },
  121. {
  122. offset: 1,
  123. color: "#1b293c",
  124. },
  125. ],
  126. false
  127. ),
  128. },
  129. },
  130. ],
  131. backgroundColor: "rgba(0, 0, 0, 0)",
  132. });
  133. function init() {
  134. lineChart.value = echarts.init(document.getElementById("lineChartRef"));
  135. lineChart.value.setOption(option.value);
  136. }
  137. onMounted(() => {
  138. init();
  139. });
  140. return {
  141. init,
  142. exchangeUrl,
  143. };
  144. },
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. #id {
  149. width: 100%;
  150. height: 100%;
  151. }
  152. </style>