realtime-line.tsx 919 B

1234567891011121314151617181920212223242526272829
  1. "use client"
  2. import ReactECharts from "echarts-for-react"
  3. import type {FC} from "react"
  4. const RealtimeLine: FC<{ title?: string; xs: string[]; ys: number[] }> = ({ title = "实时趋势", xs = [], ys = [] }) => {
  5. const option = {
  6. title: { text: title, left: "center", textStyle: { fontSize: 12, fontWeight: 500 } },
  7. tooltip: { trigger: "axis" },
  8. grid: { left: 40, right: 16, top: 32, bottom: 32 },
  9. xAxis: { type: "category", boundaryGap: false, data: xs },
  10. yAxis: { type: "value", name: "" },
  11. series: [
  12. {
  13. name: "value",
  14. type: "line",
  15. smooth: true,
  16. symbol: "none",
  17. areaStyle: {
  18. color: "rgba(34,197,94,0.15)",
  19. },
  20. lineStyle: { color: "#22c55e", width: 2 },
  21. data: ys,
  22. },
  23. ],
  24. }
  25. return <ReactECharts option={option as any} style={{ height: 300, width: "100%" }} notMerge />
  26. }
  27. export default RealtimeLine