ChanLiangTongJi.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <div class="screen-common-component">
  3. <ScreenComHeader :module-id="moduleId" title="产量统计" />
  4. <div ref="chartRef" class="charts-container"></div>
  5. </div>
  6. </template>
  7. <script lang="ts" setup>
  8. import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
  9. import * as echarts from "echarts";
  10. import {
  11. allChartColors,
  12. chartLegend,
  13. } from "@/views/screens/configs/chartsConfig";
  14. import { productionStatisticsDetail } from "@/api/screens";
  15. const chartRef = ref(null);
  16. const bigScreenData: any = inject("bigScreenData");
  17. const option = {
  18. backgroundColor: "transparent",
  19. textStyle: {
  20. fontSize: bigScreenData.value.fontSize * 2,
  21. },
  22. tooltip: {
  23. trigger: "axis",
  24. axisPointer: {
  25. type: "cross",
  26. crossStyle: {
  27. color: "#999",
  28. },
  29. },
  30. },
  31. legend: {
  32. data: ["Evaporation", "Precipitation", "Temperature"],
  33. ...chartLegend,
  34. },
  35. xAxis: [
  36. {
  37. type: "category",
  38. data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
  39. axisPointer: {
  40. type: "shadow",
  41. },
  42. },
  43. ],
  44. yAxis: [
  45. {
  46. type: "value",
  47. name: "数量",
  48. min: 0,
  49. max: 250,
  50. interval: 50,
  51. axisLabel: {
  52. formatter: "{value} 个",
  53. },
  54. },
  55. ],
  56. series: [
  57. {
  58. name: "Evaporation",
  59. type: "bar",
  60. tooltip: {
  61. valueFormatter: function (value) {
  62. return value + " ml";
  63. },
  64. },
  65. data: [
  66. 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3,
  67. ],
  68. },
  69. {
  70. name: "Precipitation",
  71. type: "bar",
  72. tooltip: {
  73. valueFormatter: function (value) {
  74. return value + " ml";
  75. },
  76. },
  77. data: [
  78. 2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3,
  79. ],
  80. },
  81. {
  82. name: "Temperature",
  83. type: "line",
  84. tooltip: {
  85. valueFormatter: function (value) {
  86. return value + " °C";
  87. },
  88. },
  89. data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2],
  90. },
  91. ],
  92. };
  93. onMounted(async () => {
  94. const chart = echarts.init(chartRef.value, "dark");
  95. let res = await productionStatisticsDetail();
  96. let seriesData = [];
  97. for (let i = 0; i < res?.data?.materialCountVOList.length; i++) {
  98. let item = res.data.materialCountVOList[i];
  99. seriesData.push({
  100. type: "bar",
  101. name: item.materialName,
  102. // tooltip: {
  103. // valueFormatter: function (value) {
  104. // return value + " ml";
  105. // },
  106. // },
  107. data: item?.counts ?? [],
  108. });
  109. }
  110. let option = {
  111. color: allChartColors,
  112. backgroundColor: "transparent",
  113. textStyle: {
  114. fontSize: bigScreenData.value.fontSize * 2,
  115. },
  116. tooltip: {
  117. trigger: "axis",
  118. axisPointer: {
  119. type: "cross",
  120. // crossStyle: {
  121. // color: "#999",
  122. // },
  123. },
  124. },
  125. legend: {
  126. data: res?.data?.materialNames ?? [],
  127. },
  128. xAxis: [
  129. {
  130. type: "category",
  131. data: res?.data?.weeks ?? [],
  132. axisPointer: {
  133. type: "shadow",
  134. },
  135. axisLabel: {
  136. fontSize: bigScreenData.value.fontSize * 2,
  137. },
  138. },
  139. ],
  140. yAxis: [
  141. {
  142. type: "value",
  143. name: "数量",
  144. // min: 0,
  145. // max: 250,
  146. // interval: 50,
  147. minInterval: 1,
  148. axisLabel: {
  149. formatter: "{value} ",
  150. },
  151. axisLabel: {
  152. fontSize: bigScreenData.value.fontSize * 2,
  153. },
  154. },
  155. ],
  156. series: seriesData,
  157. };
  158. chart.setOption(option);
  159. });
  160. const props = defineProps({
  161. moduleId: {
  162. type: String,
  163. required: true,
  164. },
  165. });
  166. </script>
  167. <style lang="scss" scoped></style>