echarts常见配置

1,折线平滑,线条颜色,数据点颜色,tooltip框加单位

series:[{
      name: "执行率",
      type: "line",
      yAxisIndex: 1,
      tooltip: {
        valueFormatter: function (value) {
          return value + " %";
        },
      },
      lineStyle: {
        color: "#2ebf90", // 线条颜色
      },
      itemStyle: {
        color: "#2ebf90", // 数据点颜色
      },
      smooth: true,//折线平滑
      data: taskexecuStatState.value3,
    }]

2,y轴每个刻度加单位,y轴最上方加单位,最小刻度值,最大刻度值,间隔刻度值

yAxis: [
       {
      type: "value",
      name: "执行率", // y轴最上方加单位
      min: 0,//最小刻度值
      max: 100,//最大刻度值
      interval: 20,//间隔刻度值
      axisLabel: {
        formatter: "{value}%",//y轴每个刻度加单位
      },
    },
  ],

3,倾斜30度,强制显示所有标签(避免自动隐藏)

xAxis: [
    {
      type: "category",
      data:[],
      axisPointer: {
        type: "shadow",
      },
      axisLabel: {
        rotate: 10, // 倾斜30度
        interval: 0, // 强制显示所有标签(避免自动隐藏)
        // fontSize: 12, // 可选:调整字体大小
        // color: "#333", // 可选:调整字体颜色
      },
    },
  ],
  

4,legend 位置

 legend: {
    data: ["应排查数", "实际排查数", "执行率"],
    orient: "horizontal",
    left: "center",
    top: "20px",
  },

5,grid调整

grid: {
    top: "25%",
    left: "10%",
    right: "10%",
  },
posted @ 2026-01-23 09:16  sinceForever  阅读(5)  评论(0)    收藏  举报