Vue3 词云

效果图:

html 复制代码
<template>
  <v-chart ref="vChartRef" :option="option" style="background-color: #000;"></v-chart>
</template>

<script setup lang="ts">
import { ref, reactive } from "vue";
import VChart from "vue-echarts";
import * as echarts from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
import { GridComponent } from "echarts/components";
import "echarts-wordcloud";
echarts.use([CanvasRenderer, GridComponent]);

const vChartRef = ref();

const chartData = ref<any>([
  {
    name: "矛盾调解",
    value: 500,
  },
  {
    name: "拖欠克扣工资",
    value: 300,
  },
  {
    name: "食品安全",
    value: 300,
  },
  {
    name: "街面秩序",
    value: 200,
  },
  {
    name: "涉法涉讼",
    value: 200,
  },
  {
    name: "施工噪音投诉",
    value: 100,
  },
  {
    name: "信访接待",
    value: 100,
  },
  {
    name: "社会治安",
    value: 100,
  },
  {
    name: "房屋交易",
    value: 50,
  },
  {
    name: "施工管理",
    value: 50,
  },
  {
    name: "日常维控",
    value: 20,
  },
]);

const option = reactive({
  backgroundColor: "rgba(0,0,0,0)",
  tooltip: {
    show: true,
    formatter: (params: any) => {
      return `${params.name}: ${params.value}`;
    },
  },
  series: [
    {
      type: "wordCloud",
      shape: "pentagon",
      left: "center",
      top: "center",
      width: "100%",
      height: "100%",
      right: null,
      bottom: null,
      sizeRange: [14, 31],
      rotationRange: [0, 0],
      rotationStep: 0,
      gridSize: 25,
      drawOutOfBound: false,
      layoutAnimation: true,
      emphasis: {
        focus: "none",
      },
      data: chartData.value,
      textStyle: {
        fontFamily: "AlibabaPuHuiTi_2_85_Bold",
        fontWeight: 600,
        color: () => {
          const colors = [
            "#029CD4FF",
            "#D54941FF",
            "#3B9330FF",
            "#F5BA18FF",
            "#A0DA12FF",
            "#E37318FF",
            "#8E56DDFF",
            "#2BA471FF",
            "#029CD499",
            "#D5494199",
            "#3B933099",
            "#F5BA1899",
            "#A0DA1299",
            "#E3731899",
            "#8E56DD99",
            "#2BA47199",
            "#029CD44D",
            "#D549414D",
            "#3B93304D",
            "#F5BA184D",
            "#A0DA124D",
            "#E373184D",
            "#8E56DD4D",
            "#2BA4714D",
          ];
          return colors[Math.floor(Math.random() * colors.length)];
        },
      },
    },
  ],
});
</script>
相关推荐
qq7422349845 小时前
VitePress静态网站从零搭建到GitHub Pages部署一站式指南和DeepWiki:AI 驱动的下一代代码知识平台
人工智能·python·vue·github·vitepress·wiki
是梦终空19 小时前
JAVA毕业设计259—基于Java+Springboot+vue3工单管理系统的设计与实现(源代码+数据库+开题报告)
java·spring boot·vue·毕业设计·课程设计·工单管理系统·源代码
@AfeiyuO21 小时前
封装表格操作列按钮
vue
千寻技术帮1 天前
10382_基于Springboot的高校排课管理系统
mysql·vue·毕设·spingboot·高校排课
IT教程资源C1 天前
(N_115)基于springboot,vue教务管理系统
mysql·vue·前后端分离·springboot教务系统
沧澜sincerely1 天前
WebSocket 实时聊天功能
网络·websocket·vue·springboot
苏打水com1 天前
第二十篇:Day58-60 前端性能优化进阶——从“能用”到“好用”(对标职场“体验优化”需求)
前端·css·vue·html·js
Jeking2171 天前
进阶流程图绘制工具 Unione Flow Editor-- 直击行业痛点:高扩展性解决方案解析
vue·流程图·workflow·unione flow·flow editor·unione cloud
旧梦星轨1 天前
掌握 Vite 环境配置:从 .env 文件到运行模式的完整实践
前端·前端框架·node.js·vue·react