queue-gauge.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use client"
  2. import ReactECharts from "echarts-for-react"
  3. import type {FC} from "react"
  4. const QueueGauge: FC<{ backlog: number; throughput: number }> = ({ backlog = 0, throughput = 120 }) => {
  5. const lvl = Math.min(100, Math.round((backlog / 50) * 100))
  6. const option = {
  7. tooltip: { formatter: "{a}<br/>{b}: {c}%" },
  8. series: [
  9. {
  10. name: "队列积压",
  11. type: "gauge",
  12. radius: "90%",
  13. startAngle: 210,
  14. endAngle: -30,
  15. min: 0,
  16. max: 100,
  17. progress: { show: true, width: 16 },
  18. axisLine: { lineStyle: { width: 16 } },
  19. pointer: { show: true, length: "60%" },
  20. detail: { valueAnimation: true, formatter: "{value}%" },
  21. data: [{ value: lvl, name: "积压率" }],
  22. },
  23. ],
  24. }
  25. return (
  26. <div>
  27. <ReactECharts option={option as any} style={{ height: 220, width: "100%" }} notMerge />
  28. <div style={{ display: "flex", justifyContent: "space-between" }}>
  29. <div>Backlog: {backlog} 条</div>
  30. <div>吞吐: {throughput}/s</div>
  31. </div>
  32. </div>
  33. )
  34. }
  35. export default QueueGauge