TOC

ECharts 简单使用示例

一般都是参考着 官网示例 写,修修改改就好了,挺方便。

折线图

option = {
  title: { text: "数据对比" },
  xAxis: {
    type: "category",
    data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], // X 轴
  },
  yAxis: { type: "value" },
  legend: { data: ["AA", "BB"] }, // 两个 Series 的图例
  toolbox: {
    // 小工具
    show: true,
    feature: {
      dataZoom: { yAxisIndex: "none" },
      dataView: { readOnly: false },
      magicType: { type: ["line", "bar"] },
      restore: {},
      saveAsImage: {},
    },
  },
  series: [
    {
      data: [
        30.47, 39.22, 34.91, 23.79, 27.28, 38.39, 40.18, 48.18, 47.24, 44.86,
      ],
      name: "AA",
      type: "line",
      smooth: true,
      markPoint: { data: [{ type: "max" }, { type: "min" }] },
      markLine: { data: [{ type: "average" }] },
    },
    {
      data: [
        44.78, 50.59, 57.14, 64.25, 53.51, 53.79, 30.89, 42.76, 54.47, 50.0,
      ],
      name: "BB",
      type: "line",
      smooth: true,
      markPoint: { data: [{ type: "max" }, { type: "min" }] },
      markLine: { data: [{ type: "average" }] },
    },
  ],
};