MonitoringCharts.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. "use client"
  2. import {Tabs} from "antd"
  3. import EChart from "@/components/echarts"
  4. const { TabPane } = Tabs
  5. export default function MonitoringCharts() {
  6. // 液位监测数据
  7. const levelOption = {
  8. title: {
  9. text: "液位监测",
  10. textStyle: { fontSize: 14 },
  11. },
  12. tooltip: {
  13. trigger: "axis",
  14. },
  15. xAxis: {
  16. type: "category",
  17. data: ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00", "24:00"],
  18. },
  19. yAxis: {
  20. type: "value",
  21. name: "液位(m)",
  22. },
  23. series: [
  24. {
  25. data: [0.2, 0.3, 0.4, 0.8, 0.6, 0.4, 0.3],
  26. type: "line",
  27. smooth: true,
  28. areaStyle: {
  29. opacity: 0.3,
  30. },
  31. markLine: {
  32. data: [{ yAxis: 0.5, name: "报警线", lineStyle: { color: "red" } }],
  33. },
  34. },
  35. ],
  36. }
  37. // 流量监测数据
  38. const flowOption = {
  39. title: {
  40. text: "流量监测",
  41. textStyle: { fontSize: 14 },
  42. },
  43. tooltip: {
  44. trigger: "axis",
  45. },
  46. xAxis: {
  47. type: "category",
  48. data: ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00", "24:00"],
  49. },
  50. yAxis: {
  51. type: "value",
  52. name: "流量(m³/s)",
  53. },
  54. series: [
  55. {
  56. data: [1.2, 1.5, 2.1, 2.8, 2.3, 1.8, 1.4],
  57. type: "line",
  58. smooth: true,
  59. itemStyle: { color: "#1890ff" },
  60. },
  61. ],
  62. }
  63. // 设备状态饼图
  64. const deviceStatusOption = {
  65. title: {
  66. text: "设备状态分布",
  67. textStyle: { fontSize: 14 },
  68. },
  69. tooltip: {
  70. trigger: "item",
  71. },
  72. series: [
  73. {
  74. type: "pie",
  75. radius: "60%",
  76. data: [
  77. { value: 1180, name: "在线", itemStyle: { color: "#52c41a" } },
  78. { value: 34, name: "离线", itemStyle: { color: "#d9d9d9" } },
  79. { value: 20, name: "故障", itemStyle: { color: "#ff4d4f" } },
  80. ],
  81. emphasis: {
  82. itemStyle: {
  83. shadowBlur: 10,
  84. shadowOffsetX: 0,
  85. shadowColor: "rgba(0, 0, 0, 0.5)",
  86. },
  87. },
  88. },
  89. ],
  90. }
  91. return (
  92. <div className="h-full">
  93. <Tabs defaultActiveKey="1" size="small">
  94. <TabPane tab="液位监测" key="1">
  95. <EChart option={levelOption} style={{ height: 280 }} />
  96. </TabPane>
  97. <TabPane tab="流量监测" key="2">
  98. <EChart option={flowOption} style={{ height: 280 }} />
  99. </TabPane>
  100. <TabPane tab="设备状态" key="3">
  101. <EChart option={deviceStatusOption} style={{ height: 280 }} />
  102. </TabPane>
  103. </Tabs>
  104. </div>
  105. )
  106. }