环形echarts图 颜色渐变 文字居中

本文介绍了如何在Vue项目中使用Echarts创建环形图,并实现颜色渐变效果。同时,详细讲解了如何设置使得图表内的文字保持居中显示,为视觉呈现提供更佳的用户体验。
摘要由CSDN通过智能技术生成

在这里插入图片描述

      <div class="risk-type-echarts" id="main"></div>

import * as echarts from "echarts";
option: {
        title: {
          text: "14",
          x: "center",
          y: "center",
          top: "80",
          textStyle: {
            fontSize: 25,
            color: "#FAB208",
            fontWeight: "700",
          },
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "0",
          left: "0",
          data: [],
        },
        graphic: {
          type: "text",
          left: "center",
          top: "120px",
          z: 2,
          zlevel: 100,
          style: {
            text: "巡检总次数",
            fill: "#fff",
 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要在 ECharts 的饼中实现环形渐变,可以使用 ECharts 的 `color` 属性来实现。以下是一个简单的示例代码: ```javascript option = { title: { text: '环形渐变', left: 'center' }, tooltip: { trigger: 'item', formatter: '{a} <br/>{b}: {c} ({d}%)' }, series: [ { name: '访问来源', type: 'pie', radius: ['40%', '60%'], avoidLabelOverlap: false, label: { show: false, position: 'center' }, emphasis: { label: { show: true, fontSize: '30', fontWeight: 'bold' } }, labelLine: { show: false }, data: [ {value: 435, name: '直接访问'}, {value: 310, name: '邮件营销'}, {value: 234, name: '联盟广告'}, {value: 135, name: '视频广告'}, {value: 1548, name: '搜索引擎'} ], color: [ new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#fbb962'}, {offset: 0.5, color: '#f37b1d'}, {offset: 1, color: '#f37b1d'} ]), new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#00c2ff'}, {offset: 0.5, color: '#008cff'}, {offset: 1, color: '#008cff'} ]), new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#6fde6f'}, {offset: 0.5, color: '#00c633'}, {offset: 1, color: '#00c633'} ]), new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#f5d114'}, {offset: 0.5, color: '#e8b027'}, {offset: 1, color: '#e8b027'} ]), new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#3bafff'}, {offset: 0.5, color: '#0072ff'}, {offset: 1, color: '#0072ff'} ]) ] } ] }; ``` 在这个示例中,我们的饼有 5 个扇形,每个扇形都有一个渐变颜色。我们使用 `new echarts.graphic.LinearGradient` 方法创建了一个线性渐变,然后将其分配给每个扇形。线性渐变的参数分别为 `0, 0, 0, 1`,表示从上到下的垂直渐变。在 `color` 属性中,我们将每个扇形的颜色设置为线性渐变
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值