echarts疑难杂症

1.调整柱状图、饼图的大小

//柱状图主要根据grid属性中的top/bottom/left/right属性调整大小
let option = {
    grid: {
          left: 25,
          right: 25,
          bottom:25,
          top:25,
          containLabel: true, // 保证label不会被挤掉
        },
}

//饼图调整主要根据radius调整饼图的大小(官方描述:数组的第一项是内半径,第二项是外半径),
//调整位置依旧可以按照上下左右以及center属性
//radius[0](案例中的40%,数值越大则越细,反之越粗),
//radius[1](案例中的70%,数值越大则图越大,反之越小)
let option = {
    series: [
              {
                type: "pie",
                left: 25,
                right: 25,
                bottom:25,
                top:25, 
                radius: ["40%", "70%"],
                center: ["50%", "50%"],
                avoidLabelOverlap: false,
              }
			]
		}

在这里插入图片描述

2.嵌套饼图且颜色保持一致


链接: 可以参考该博主

3.并排展示饼图且中间展示文字

//并排展示饼图需要注意center属性,具体摆放位置可以自己调

//展示文字主要取决于formatter属性,如果里面文字过多或者多行文字,
//可以通过"{aaa|我叫aaa}"+"\n"+"{bbb|我叫bbb}",则下面可以通过rich属性去给前面设置的aaa或bbb设置单独样式
let option = {
        series: [
          {
            type: "pie",
            center: ["12.5%", "50%"],
            radius: ["75%", "90%"],
            data: [
              {
                value: 28,
                name: "Quoted",
                label: {
                  position: "center",
                  formatter: "{proportion|13/15}" + "\n" + "{title|Quoted}",
                  rich: {
                    proportion: {
                      fontSize: 12,
                      fontFamily: "微软雅黑",
                      fontWeight: 700,
                      color: "#000",
                      lineHeight: 20,
                    },
                    title: {
                      fontSize: 10,
                      fontFamily: "微软雅黑",
                      color: "#7e7e7e",
                    },
                  },
                },
                itemStyle: {
                  color: "#00af50",
                },
              },
              {
                value: 13,
                name: "",
                label: {
                  show: false,
                },
                itemStyle: {
                  color: "#a6a6a7",
                },
              },
            ],
          },
          {
            type: "pie",
            center: ["37.5%", "50%"],
            radius: ["75%", "90%"],
            data: [
              {
                value: 26,
                name: "Shortlist",
                label: {
                  position: "center",
                  formatter: "{proportion|11/15}" + "\n" + "{title|Shortlist}",
                  rich: {
                    proportion: {
                      fontSize: 12,
                      fontFamily: "微软雅黑",
                      fontWeight: 700,
                      color: "#000",
                      lineHeight: 20,
                    },
                    title: {
                      fontSize: 10,
                      fontFamily: "微软雅黑",
                      color: "#7e7e7e",
                    },
                  },
                  textStyle: {
                    color: "#000",
                    fontSize: 12,
                  },
                },
                itemStyle: {
                  color: "#c00000",
                },
              },
              {
                value: 15,
                name: "",
                label: {
                  show: false,
                },
                itemStyle: {
                  color: "#a6a6a7",
                },
              },
            ],
          },
          {
            type: "pie",
            center: ["62.5%", "50%"],
            radius: ["75%", "90%"],
            data: [
              {
                value: 26,
                name: "Sampling",
                label: {
                  position: "center",
                  formatter: "{proportion|11/15}" + "\n" + "{title|Sampling}",
                  rich: {
                    proportion: {
                      fontSize: 12,
                      fontFamily: "微软雅黑",
                      fontWeight: 700,
                      color: "#000",
                      lineHeight: 20,
                    },
                    title: {
                      fontSize: 10,
                      fontFamily: "微软雅黑",
                      color: "#7e7e7e",
                    },
                  },
                },
                itemStyle: {
                  color: "#bc9200",
                },
              },
              {
                value: 11,
                name: "",
                label: {
                  show: false,
                },
                itemStyle: {
                  color: "#a6a6a7",
                },
              },
            ],
          },
          {
            type: "pie",
            center: ["87.5%", "50%"],
            radius: ["75%", "90%"],
            data: [
              {
                value: 2,
                name: "Ordered",
                label: {
                  position: "center",
                  formatter: "{proportion|2/15}" + "\n" + "{title|Ordered}",
                  rich: {
                    proportion: {
                      fontSize: 12,
                      fontFamily: "微软雅黑",
                      fontWeight: 700,
                      color: "#000",
                      lineHeight: 20,
                    },
                    title: {
                      fontSize: 10,
                      fontFamily: "微软雅黑",
                      color: "#7e7e7e",
                    },
                  },
                  //   textStyle: {
                  //     color: "#000",
                  //     fontSize: 12,
                  //   },
                },
                itemStyle: {
                  color: "#92d14f",
                },
              },
              {
                value: 17,
                name: "",
                label: {
                  show: false,
                },
                itemStyle: {
                  color: "#a6a6a7",
                },
              },
            ],
          },
        ],
      };

在这里插入图片描述

4.折线图(柱状图)双y轴

在这里插入图片描述

5.使用echarts5

//安装
npm i echarts5 -S
//引用
import * as echarts5 from "echarts5";
//添加图表后使用
const pieItem = echarts5.init(this.$refs.pieItem);
pieItem.setOption(option);

注意:在vue中使用echarts时,一定得放到mounted生命周期,必须得dom元素挂载后再去渲染,如果是react中则放到useEffect中

6.图形不展示的问题

1.可能是放错了生命周期,例如在vue中,放到了created钩子中,必须放到dom挂载后
2.宽高没有设置,如果不展示,可以先审查元素,如果canvas中的height或width为0也不展示

按需引入等具体配置请

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用Docker时,可能会遇到一些疑难杂症。其中,一些常见的问题及解决办法如下: 1. 运行docker version时报错"Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"这个错误通常是由于Docker守护进程未启动引起的。可以通过运行以下命令来启动守护进程:`sudo systemctl start docker`(适用于基于systemd的Linux发行版)。如果您不是使用systemd,请根据您的操作系统和版本来启动Docker守护进程。 2. 使用yum安装Docker时报错"Cannot retrieve metalink for repository: epel. Please verify its path and try again."这个错误通常是由于epel源(Extra Packages for Enterprise Linux)未正确安装或配置引起的。您可以尝试以下解决办法: - 首先,确保您的系统与互联网连接正常。 - 检查您的操作系统和版本,并根据官方文档正确安装epel源。 - 如果您已经安装了epel源,但仍然遇到这个错误,请尝试更新epel源并再次运行安装命令。 这些是一些常见的Docker疑难杂症及其解决办法。当然,Docker的使用过程中可能还会遇到其他问题,您可以参考官方文档、社区论坛或搜索引擎来寻找更多解决办法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [docker 疑难杂症](https://blog.csdn.net/weixin_33805992/article/details/92266045)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [docker常见疑难杂症](https://blog.csdn.net/weixin_45776707/article/details/103142818)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值