highcharts制作3D饼图渐变效果

代码如下:

let color1 = [

        "rgb(161, 194, 255)",

        "rgb(250, 214, 9)",

        "rgb(255, 109, 12)",

      ];

      let color2 = [

        "rgb(93, 159, 219)",

        "rgb(255, 229, 120)",

        "rgb(255, 190, 154)",

      ];

      // 创建渐变色

      highcharts.getOptions().colors = highcharts.map(

        highcharts.getOptions().colors,

        function (color, index) {

          return {

            radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },

            stops: [

              [0, color2[index]],

              [1, color1[index]],

            ],

          };

        }

      );

      if (this.charts) {

        chart.destroy();

      }



      let that = this;

      highcharts.chart("bottom-echarts", {

        // colors: ["#5D9FDB", "#FFBE9A", "#FFE578"],

        chart: {

          type: "pie",

          backgroundColor: null,

          options3d: {

            enabled: true,

            alpha: this.getFontSize(30),

            beta: 0,

          },

        },

        title: {

          text: null,

        },

        // tooltip: {

        //   // pointFormat:'{series.name}: <b>{point.percentage:.1f}</b>',

        // },

        tooltip: {

          enabled: true,

          // shared: true, //是否共享提示,也就是X一样的所有点都显示出来

          useHTML: true, //是否使用HTML编辑提示信息

          // headerFormat: '<small>{point.key}</small><table>',

          backgroundColor: "rgba(0,0,0,0.6)",

          borderWidth: 0,

          style: {

            // 文字内容相关样式

            color: "white",

            textAlign: "center",

          },

          formatter: function (series) {

            console.log(this);

            console.log(series);

            let res = `<div style="text-align:center;padding:5px;font-size:${that.getFontSize(14)}px;">

            <span>荣誉数量</span>

            <div style="margin-top:5px;">${this.key}:&nbsp; ${(this.percentage).toFixed(1)}%</div>

            </div>`;

            return res;

          },

        },

        credits: {

          //text: 'Example.com',

          //href: 'http://www.example.com',

          enabled: false,

        },

        plotOptions: {

          pie: {

            allowPointSelect: true,

            cursor: "pointer",

            depth: this.getFontSize(50),

            // format: "{series.name}: <b>{point.percentage:.1f}%</b>",

          },

        },



        series: [

          {

            type: "pie",

            name: "荣誉数量占比",

            data: [

              ["2021年15项", 45.8],

              ["2022年30项", 26.0],

              ["2023年55项", 22.8],

            ],

            lable: {

              show: true,

            },

            dataLabels: {

              enabled: true,

              connectorShape: "crookedLine",

              crookDistance: "50%",

              y: -14,

              //转折线设置

              connectorShape: function (

                labelPosition,

                connectorPosition,

                options

              ) {

                var touchingSliceAt = connectorPosition.touchingSliceAt,

                  alignment = labelPosition.alignment,

                  left = 0,

                  right = 0;

                if (alignment == "left") {

                  left = labelPosition.x + this.dataLabel.bBox.width + 14;

                  right = labelPosition.x + 2;

                } else {

                  left = labelPosition.x - this.dataLabel.bBox.width - 14;

                  right = labelPosition.x - 2;

                }

                return [

                  "M",

                  left,

                  labelPosition.y,

                  "L",

                  right,

                  labelPosition.y,

                  "L",

                  touchingSliceAt.x,

                  touchingSliceAt.y,

                ];

              },

              //旁边提示的label

              formatter: function () {

                // console.log(this.point);

                // console.log(123);

                if (this.point.name) {

                  return `<span style="color:#AAD3FF;backgroung:transparent;font-size:${that.getFontSize(14)};font-weight:300">${this.point.name}</span>`;

                }

              },

              style: {

                textOutline: "none",

              },

            },

           

          },

        ],

      });

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值