echart 图表 柱状图设置圆角,图例设置为圆形,图例距离

效果:
在这里插入图片描述

设置圆角:
圆角:
borderWidth:宽度

itemStyle: {
              normal: {
                //这里设置柱形图圆角 [左上角,右上角,右下角,左下角]
                barBorderRadius: [10, 10, 0, 0],
              },
            },

在这里插入图片描述
图例形状圆形:
icon: “circle”, // 这个字段控制形状 类型包括 circle 圆形,triangle 三角形,diamond 四边形,arrow 变异三角形,none 无

legend: {
          icon: "circle",
          padding: [20, 15, 0, 0], //设置图例距上⽅距离,距右⽅距离,距下⽅距离,距左⽅距
          x: "right", //居右显示
          textStyle: {
            // 图例文字的样式
            color: "#fff",
            fontSize: 12,
          },
        },

在这里插入图片描述
完整代码:

<template>
  <div
    class="echart"
    id="myBarchart"
    :style="{
      bottom: '0px',
      width: '100%',
      height: '400px',
    }"
  ></div>
</template>
<script>
import * as echarts from "echarts";
export default {
  name: "lineChart",
  data() {
    return {};
  },
  mounted() {
    this.initEcharts();
  },
  methods: {
    initEcharts() {
      const option = {
        legend: {
          icon: "circle",
          padding: [20, 15, 0, 0], //设置图例距上⽅距离,距右⽅距离,距下⽅距离,距左⽅距
          x: "right", //居右显示
          textStyle: {
            // 图例文字的样式
            color: "#fff",
            fontSize: 12,
          },
        },
        grid: {
          left: "3%",
          right: "3%",
          bottom: "0.1%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sun"],
          },
        ],
        yAxis: [
          {
            type: "value",
            splitLine: {
              show: true,
              lineStyle: {
                type: "solid",
                color: "#656c94",
              },
            },
          },
        ],
        series: [
          {
            name: "严重",
            type: "bar",
            barWidth: 5,
            itemStyle: {
              normal: {
                //这里设置柱形图圆角 [左上角,右上角,右下角,左下角]
                barBorderRadius: [10, 10, 0, 0],
              },
            },
            stack: "Search Engine",
            color: "red",
            emphasis: {
              focus: "series",
            },
            data: [40, 42, 90, 100, 50, 60],
          },
          {
            name: "异常",
            type: "bar",
            stack: "Search Engine",
            itemStyle: {
              normal: {
                //这里设置柱形图圆角 [左上角,右上角,右下角,左下角]
                barBorderRadius: [10, 10, 0, 0],
              },
            },
            color: "#f0f075",
            emphasis: {
              focus: "series",
            },
            data: [80, 105, 110, 200, 90, 30],
          },
          {
            name: "正常",
            type: "bar",
            itemStyle: {
              normal: {
                //这里设置柱形图圆角 [左上角,右上角,右下角,左下角]
                barBorderRadius: [10, 10, 0, 0],
              },
            },
            stack: "Search Engine",
            color: "#109d2a",
            emphasis: {
              focus: "series",
            },
            data: [180, 320, 550, 410, 110, 150],
          },
        ],
      };
      const myChart = echarts.init(document.getElementById("myBarchart")); // 图标初始化
      myChart.setOption(option); // 渲染页面
      //随着屏幕大小调节图表
      window.addEventListener("resize", () => {
        myChart.resize();
      });
    },
  },
};
</script>
<style scoped>
</style>
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值