vue3【echarts 做的词云图】

效果图

echarts 做的词云图

安装

安装echarts

 npm install echarts

安装词云图

 npm install echarts-wordcloud

echarts-wordcloud的git仓库地址
echarts官网地址

引用

import * as ECharts from "echarts"; //引用eacharts
import 'echarts-wordcloud';//引用云词

这里的echarts 是自己简单封装了一下,如需要请参考:echarts封装

实力代码 (vue3)

<template>
   <div style="width: 100%; height: 300px">
      <echarts :visible="true" :option="optionText"></echarts>
   </div>
</template>

<script>
export default {
  components: {
    Echarts: defineAsyncComponent(() => import("@/components/echarts")),
  },
  setup() {
 const state = reactive({
    optionText: {
        backgroundColor: "#fff",
        tooltip: {
          show: false,
        },
        series: [
          {
            type: "wordCloud",
            //maskImage: maskImage,
            gridSize: 1,
            sizeRange: [12, 55],
            rotationRange: [-45, 0, 45, 90],
            width: "100%",
            height: "100%",
            textStyle: {
             // normal: { 目前使用echarts版本是5 所以使用normal颜色未生效,把normal去掉就生效了 颜色不生效的话请注意使用echarts版本问题
                color: function () {
                  return (
                    "rgb(" +
                    Math.round(Math.random() * 255) +
                    ", " +
                    Math.round(Math.random() * 255) +
                    ", " +
                    Math.round(Math.random() * 255) +
                    ")"
                  )
                //  }
              },
              emphasis: {
                shadowBlur: 10,
                shadowColor: "#333",
              },
            },
            data: [
              {
                name: "花鸟市场",
                value: 1446,
              },
              {
                name: "汽车",
                value: 928,
              },
              {
                name: "视频",
                value: 906,
              },
              {
                name: "电视",
                value: 825,
              },
              {
                name: "Lover Boy 88",
                value: 514,
              },
              {
                name: "动漫",
                value: 486,
              },
              {
                name: "音乐",
                value: 53,
              },
              {
                name: "直播",
                value: 163,
              },
              {
                name: "广播电台",
                value: 86,
              },
              {
                name: "戏曲曲艺",
                value: 17,
              },
              {
                name: "演出票务",
                value: 6,
              },
              {
                name: "给陌生的你听",
                value: 1,
              },
              {
                name: "资讯",
                value: 1437,
              },
            ],
          },
        ],
      },
 })
  },

}
</script>
<style scoped lang="scss">
.charts-wrapper {
  width: 300px;
  height: 300px;
    .charts-content {
    width: 100%;
    height: 100%;
  }

  }
</style>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值