Echarts之折线图配置详情

一,标题 title组件

let title = {
  text: "累计消费趋势", // 标题
  subtext: "同比上年同期,累计消费增加200元", // 副标题
  top: -5, // 定位
  left: -5, // 定位
  subtextStyle: {
    // 副标题样式
    color: "#808080",
    fontSize: 12,
  },
};

二,图例 legend 组件

let legend = {
  top: 24, // 定位,和副标题一排
  right: 0, // 定位,和副标题一排,且在右边
  icon: "circle", // 图例形状
  // itemWidth: 25, // 图例标记的图形宽度
  itemHeight: 6, // 图例标记的图形高度
  itemGap: 24, // 图例每项之间的间隔
  itemStyle: {}, // 图例的图形样式
  textStyle: {
    // 图例文字属性
    fontSize: 12,
    color: "#333",
    padding: [0, 0, 0, -8], // 修改文字和图标距离
  },
};

三,绘制网格 grid

用来调整绘图区域的属性

ler grid = {
  top: 70,
  left: 0,
  right: 12,
  bottom: 0,
  containLabel: true,
}

四 xAxis 轴

let xAxis = R.mergeDeepRight(xAxis, {
  type: "category",
  boundaryGap: false, // 不留白
  axisLabel: {
    interval: 50, // 只显示最大和最小坐标
    showMinLabel: true, // 显示最小标签
    showMaxLabel: true, // 显示最大标签
  },
  axisLine: {
    lineStyle: {
      type: "dashed", // 直线指示器为虚线
      // dashOffset: 5 // 虚线的偏移量
    },
  },
  axisPointer: {
    type: "line", // 直线指示器
  },
});

五,series 数据列

调节数据图表的样式(折线)

let series = [
  {
    type: "line",
    color: "#1890ff", // 线条颜色
    areaStyle: {
      color: "rgba(24,144,255,0.08)", // 区域背景色
    },
    showSymbol: false, // 只有在 tooltip hover 的时候显示
    symbol: "emptyCircle", // 拐点形状
    symbolSize: 6, //拐点大小
  },
  {
    type: "line",
    color: "#52c41a",
    areaStyle: {
      color: "rgba(82,196,26,0.08)",
    },
    showSymbol: false,
    symbol: "emptyCircle",
    symbolSize: 6,
  },
];

六,tooltip 提示框

let tooltip = {
  trigger: "axis",
  // 指示器样式配置
  axisPointer: {
    type: "cross",
    label: {
      show: true,
      color: "#808080",
      fontSize: 12,
      padding: [20, 0, 0, 0],
      backgroundColor: "transparent",
    },
    lineStyle: {
      color: "#808080",
      width: 0.5,
    },
    // position: [10, 10],
    // position(point, params) {
    //   // 默认距离鼠标定位
    //   if (params.length) {
    //     const { axisIndex, axisValue } = params[0];
    //     instance.convertToPixel({ xAxisIndex: axisIndex }, axisValue); // axisPointer position x
    //   }
    // },
//设置显示的内容格式
    formatter: {
return `标题:内容`
         }
};
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值