echarts 设置柱状图边框颜色

本文详细描述了一个ECharts图表的配置选项,包括tooltip的定制、颜色渐变在轴线和图形上的应用,以及数据系列(bar)的样式设置。
摘要由CSDN通过智能技术生成

代码如下:

this.options = {
  tooltip: {
    trigger: "axis",
    textStyle: {
      align: "left",
    },
    className: "custom-tooltip-box",
    formatter: function (params) {
      return `<div class='custom-tooltip-style'>
        <div class='title'>
          <span>${params[0].name}年</span>
        </div>
        <div class="span">
          <div class="content">
            <span>合同金额:</span>
            <span>${params[0].value}万元</span>
          </div>
        </div>
      </div>`;
    },
  },
  color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    {
      offset: 0,
      color: "rgba(4,180,53,0)", // 0% 处的颜色
    },
    {
      offset: 1,
      color: "#3CD783", // 100% 处的颜色
    },
  ]),
  grid: {
    top: "26%",
    bottom: "0%",
    right: "8%",
    left: "8%",
    containLabel: true,
  },
  xAxis: [
    {
      type: "category",
      data: this.xAxisData,
      axisLabel: {
        show: true,
        margin: 14,
        fontSize: 12,
        textStyle: {
          color: "#ffffffcc"
        }
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: "#355d8d",
        },
      },
      axisTick: {
        show: false,
      },
    },
  ],
  yAxis: [
    {
      type: "value",
      name: '单位:万元',
      nameTextStyle: {
        fontSize: this.handleWidth(12),
        color: "#FFFFFF99",
        padding: [0, 18, 10, 0]
      },
      axisLine: {
        onZero: false,
        lineStyle: {
          color: "#87C2FF",
          width: 1, //这里是为了突出显示加上的
        },
      },
      axisLabel: {
        formatter: function (val) {
          return val + "";
        },
        show: true,
        margin: 8,
        fontSize: 12,
        textStyle: {
          color: "#FFFFFF99", //字体颜色
        },
      },
      splitLine: {
        show: true,
        lineStyle: {
          color: "#87C2FF66",
          width: 0.7,
          type: "dashed",
        },
      },
    },
  ],
  series: [
    {
      type: "bar",
      // name: this.legendData[0],
      barWidth: 20,
      itemStyle: {
        borderWidth: 2,
        borderColor: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: "#3FFF8C", // 0% 处的颜色
          },
          {
            offset: 1,
            color: "#FBFFFA", // 100% 处的颜色
          },
        ])
      },
      areaStyle: {
        normal: {
          //颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: "#3CD783", // 0% 处的颜色
            },
            {
              offset: 1,
              color: "rgba(4,180,53,0)", // 100% 处的颜色
            },
          ])
        }
      },
      data: this.echartData
    }
  ]
};

  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

超级无敌小小小白

感谢老板的打赏~^v^~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值