Echart词云

Echart词云

词云图

const option = {
        series: [
          {
            shape: 'circle',//形状 'circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star'
             //maskImage: maskImage  ,//使用base64 词云配置背景图片
            type: "wordCloud",
            left: "center",
            top: "center",
            width: "100%",
            height: "100%",
            right: null,
            backgroundColor:'#FAF2F2FF',
            bottom: null,
            sizeRange: (() => {
              return [
                this.option.minFontSize || 12,
                this.option.maxFontSize || 60
              ];
            })(),// 词的大小,最小12px,最大60px,可以在这个范围调整词的大小
            rotationRange: (() => {
              if (this.option.rotate) {
                return [-90, 90];
              } else {
                return [0, 0];
              }
            })(), 每个词旋转的角度范围
            //rotationRange: [-45, 0, 45, 90],
            rotationStep: (() => {
              if (this.option.rotate) {
                return 15;
              } else {
                return 0;
              }
            })(),// // 词间距,数值越小,间距越小,这里间距太小的话,会出现大词把小词套住的情况,比如一个大的口字,中间会有比较大的空隙,这时候他会把一些很小的字放在口字里面,这样的话,鼠标就无法选中里面的那个小字
            gridSize: this.option.split || 30,
            drawOutOfBound: false,
            // 这是全局的文字样式,相对应的还可以对每个词设置字体样式
            textStyle: {
              // fontFamily: 'sans-serif',
              fontFamily: 'Arial',
              fontWeight: 'normal',
              // 颜色可以用一个函数来返回字符串(用来控制颜色的范围)
              color: function () {
                // Random color
                return 'rgb(' + [
                  Math.round(Math.random() * 160),
                  Math.round(Math.random() * 160),
                  Math.round(Math.random() * 160)
                ].join(',') + ')';
              },
              // color: function () {
              //   return 'rgb(' + [
              //     Math.round(Math.random() * 200) + 50,
              //     Math.round(Math.random() * 50),
              //     Math.round(Math.random() * 50) + 50
              //   ].join(',') + ')';
              // },
              normal: {
                fontFamily: "sans-serif",
                fontWeight: "normal",
                color: function () {
                  return (
                    "rgb(" +
                    [
                      Math.round(Math.random() * 160),
                      Math.round(Math.random() * 160),
                      Math.round(Math.random() * 160)
                    ].join(",") +
                    ")"
                  );
                }
              },
              emphasis: {
                shadowBlur: 10,
                shadowColor: "#111111"
              }
            },
            //动画
            layoutAnimation:true,
            data: optionData
            // data: optionData
          },
        ]
      };
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值