当前位置: 首页 > news >正文

vue实现气泡词云图

在这里插入图片描述
1、下载插件 echarts-wordcloud跟echarts
2、修改插件代码WordCloudView.js
在这里插入图片描述

import * as echarts from 'echarts/lib/echarts';echarts.extendChartView({type: 'wordCloud',render: function (seriesModel, ecModel, api) {var group = this.group;group.removeAll();var data = seriesModel.getData();var gridSize = seriesModel.get('gridSize');seriesModel.layoutInstance.ondraw = function (text, size, dataIdx, drawn) {var itemModel = data.getItemModel(dataIdx);var textStyleModel = itemModel.getModel('textStyle');var textEl = new echarts.graphic.Text({style: echarts.helper.createTextStyle(textStyleModel),scaleX: 1 / drawn.info.mu,scaleY: 1 / drawn.info.mu,x: (drawn.gx + drawn.info.gw / 2) * gridSize,y: (drawn.gy + drawn.info.gh / 2) * gridSize,rotation: drawn.rot});textEl.setStyle({x: drawn.info.fillTextOffsetX,y: drawn.info.fillTextOffsetY + size * 0.5,text: text,verticalAlign: 'middle',fill: data.getItemVisual(dataIdx, 'style').fill,fontSize: size});group.add(textEl);data.setItemGraphicEl(dataIdx, textEl);textEl.ensureState('emphasis').style = echarts.helper.createTextStyle(itemModel.getModel(['emphasis', 'textStyle']),{state: 'emphasis'});textEl.ensureState('blur').style = echarts.helper.createTextStyle(itemModel.getModel(['blur', 'textStyle']),{state: 'blur'});echarts.helper.enableHoverEmphasis(textEl,itemModel.get(['emphasis', 'focus']),itemModel.get(['emphasis', 'blurScope']));textEl.stateTransition = {duration: seriesModel.get('animation')? seriesModel.get(['stateAnimation', 'duration']): 0,easing: seriesModel.get(['stateAnimation', 'easing'])};// TODOtextEl.__highDownDispatcher = true;};this._model = seriesModel;},remove: function () {this.group.removeAll();this._model.layoutInstance.dispose();},dispose: function () {this._model.layoutInstance.dispose();}
});
<template><div><div class="left-center"><div class="left-center-title"><img src="../../../assets/large-screen/title-img.png" alt=""><div class="titleName"> 气泡列表</div></div><div id="hotChart" style="width: 100%; height:220px; margin:0 auto;"></div></div></div>
</template>
<script>
import * as echarts from 'echarts';
import barY from "@/assets/large-screen/cicle01.png"
import 'echarts-wordcloud';
import { getPageList } from "@/api/algorithm-house/index";
export default {data () {return {hotChart: null,searchForm: {pageIndex: 1,pageSize: 10,},bubbleData: [{ value: 12, label: "", symbolSize: 40 },{ value: 25, label: "", symbolSize: 70 },{ value: 20, label: "", symbolSize: 41 },{ value: 30, label: "", symbolSize: 49 },{ value: 18, label: "", symbolSize: 60 },{ value: 15, label: "", symbolSize: 38 },{ value: 11, label: "", symbolSize: 57 },{ value: 13, label: "", symbolSize: 45 },{ value: 25, label: "", symbolSize: 50 },{ value: 13, label: "", symbolSize: 40 },],arrList: []}},mounted () {this.$nextTick(() => {this.getChart4();});},methods: {// 随机设置气泡大小getRandom (max, min) {return Math.floor(Math.random() * (max - min) + min);},async getChart4 (data) {this.myChart4 = this.$echarts.init(document.getElementById("hotChart"));let res = await getPageList(this.searchForm);if (res.code == 200) {this.arrList = [];res.data.records.forEach((item, recordIndex) => {if (recordIndex < this.bubbleData.length) {// const bubbleItem = this.bubbleData[recordIndex];this.arrList.push({symbolSize: this.getRandom(80, 40), //气泡大小draggable: true, //是否可以拖动symbol: "image://" + barY, //气泡图片name: item.algName //气泡名称});}});}this.myChart4.setOption({tooltip: {},color: ['#59EBE8', '#f29701'],animationDurationUpdate: function (idx) {return idx * 100;},animationEasingUpdate: "bounceIn",series: [{type: "graph",layout: "force",left: "center",width: '100%',height: 220,// top: 25,gridSize: 20,sizeRange: [30, 80],rotationRange: [0, 0],rotationStep: 90,drawOutOfBound: true,layoutAnimation: true,force: {repulsion: 70,  //节点之间的斥力因子。支持数组表达斥力范围,值越大斥力越大。edgeLength: 50,   //边的两个节点之间的距离,值越小则长度越长,这个距离也会受                                             repulsion影响。    gravity: 0.11,  //节点受到的向中心的引力因子。该值越大节点越往中心点靠拢。layoutAnimation: true,  //初始化时转动动画// edgeLength: [10, 50],//边的两个节点之间的距离},label: {show: true,formatter: ["{b|{b}}"].join("\n"),fontWeight: "1000",fontSize: "18",align: "center",verticalAlign: "center",rich: {a: {color: "#fff",fontSize: 12,lineHeight: 30,textBorderColor: "transparent",textBorderWidth: 0,},b: {color: "#fff",fontSize: 12,lineHeight: 30,textBorderColor: "transparent",textBorderWidth: 0,},},},data: this.arrList},],});},}
}
</script>
<style lang="scss" scoped>
.left-center {background-image: url("../../../assets/large-screen/border-bg.png");background-repeat: no-repeat;background-size: 100% 100%;padding: 25px 10px 21px 30px;margin-bottom: 10px;.left-center-title {font-size: 24px;font-family: Alibaba PuHuiTi, Alibaba PuHuiTi;color: #C8DAFF;font-weight: bold;text-shadow: 0px 0px 35px rgba(0, 255, 234, 0.68);position: relative;.titleName {position: absolute;top: -2px;left: 25px;}}}
</style>
http://www.xdnf.cn/news/970795.html

相关文章:

  • FastJson的反序列化问题入门
  • Qt使用ODBC连接MySQL数据库
  • R7-1 显示Pascal三角形
  • 【代码模板】从huggingface加载tokenizer和模型,进行推理
  • idea64.exe.vmoptions配置
  • IDEA中配置HTML和Thymeleaf热部署的步骤
  • 蓝桥杯 2024 15届国赛 A组 儿童节快乐
  • 指针与引用参数传递的区别及内存操作流程详解
  • 分散电站,集中掌控,安科瑞光伏云平台助力企业绿色转型
  • 高通录像功能
  • Vim 光标移动命令总览
  • Java中高并发线程池的相关面试题详解
  • 《ZLMediaKit 全流程实战:从部署到 API 调用与前后端集成》
  • 用 LoRA 对 Qwen2.5-VL 模型进行SFT - FORCE_TORCHRUN=1
  • 条件运算符
  • error: src refspec master does not match any - Git
  • coze的基本使用
  • 从零开始搭建现代化 Monorepo 开发模板:TypeScript + Rollup + Jest + 持续集成完整指南
  • Git操作问题及解决方案-记录5
  • (十)学生端搭建
  • 【SQL学习笔记3】深入理解窗口函数的用法
  • 鹰盾加密器系统黑屏问题的深度解析与处理机制
  • RAG系统向量数据库选型与Prompt Engineering鲁棒性测试实践
  • 10:00开始面试,10:06就出来了,问的问题有点变态。。。
  • 第14篇:数据库中间件的分布式配置与动态路由规则热加载机制
  • vxe-table 如何实现直接渲染输入框控件,不需要点击编辑方式,直接就显示文本框
  • DSL查询文档
  • Android OpenSL ES 音频播放完整实现指南
  • AtCoder Beginner Contest 408
  • 电路笔记(元器件):并串转换芯片 SN65LV1023A 10:1 LVDS 串行器/解串器变送器 100 至 660Mbps