echarts-wordcloud词云

GitHub

  • echarts5版本以下的需要下载echarts-wordcloud1.0版本
  • echarts5及以上的下载echarts-wordcloud2.0版本

可结合之前发表的封装vue-echarts组件一起使用,传入echarts-wordCloud相关的options即可。

示例代码:

<template>
  <div id="xxxx" style="height: 400px; width: 400px; background: pink"></div>
</template>

<script setup>
import * as echarts from "echarts";
import "echarts-wordcloud";
import { nextTick } from "vue";

const initEchart = () => {
  const echartDom = document.getElementById("xxxx");
  console.log("echartDom: ", echartDom);
  const myChart = echarts.init(echartDom);
  const option = {
    series: [
      {
        type: "wordCloud",
        shape: "circle",
        keepAspect: false,
        // maskImage: maskImage,
        left: "center",
        top: "center",
        width: "100%",
        height: "90%",
        right: null,
        bottom: null,
        sizeRange: [12, 60],
        rotationRange: [-90, 90],
        rotationStep: 45,
        gridSize: 8,
        drawOutOfBound: false,
        layoutAnimation: true,
        textStyle: {
          fontFamily: "sans-serif",
          fontWeight: "bold",
          color: function () {
            return (
              "rgb(" +
              [
                Math.round(Math.random() * 160),
                Math.round(Math.random() * 160),
                Math.round(Math.random() * 160),
              ].join(",") +
              ")"
            );
          },
        },
        emphasis: {
          // focus: 'self',
          textStyle: {
            textShadowBlur: 3,
            textShadowColor: "#333",
          },
        },
        //data属性中的value值却大,权重就却大,展示字体就却大
        data: [
          { name: "Farrah", value: 366 },
          { name: "汽车", value: 900 },
          { name: "视频", value: 606 },
        ],
      },
    ],
  };
  option && myChart.setOption(option);

  //随着屏幕大小调节图表
  window.addEventListener("resize", () => {
    myChart.resize();
  });
};

nextTick(() => {
  initEchart();
});
</script>

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值