当前位置: 首页 > 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>

相关文章:

  • Elasticsearch增删改查语句
  • freeCAD 学习 step1
  • 金属工具制造企业如何做项目管理?数字化系统全面提升交付效率
  • vue的这两个特性:数据驱动视图 与 双向数据绑定的区别
  • 日志收集工具-logstash
  • Gartner企业技术参考架构学习心得
  • GPU架构对大模型推理部署到底有什么影响?
  • 86壳温湿度传感器:高温下工业生产的安全防线
  • 【C#】C++的回调函数和C#的事件委托在某些方面有相似之处
  • 土地利用/土地覆盖遥感解译与基于CLUE模型未来变化情景预测技术应用
  • spearman相关性 - 斯皮尔曼秩相关系数
  • 黑马python(二)
  • 题单:归并排序
  • Alerting中配置多个OpsGenie时,如何匹配同一个条件匹配多个opsgenie的contact points
  • 以太网协议(Ethernet)深入解析:从底层原理到实战应用
  • 智能文档结构化技术的应用,重塑合同管理模式
  • 期末考试复习总结-《ArkTS基础语法(上)》
  • G-Star公益行 | 公益组织入门开源技术,六月北京点燃改变的星火
  • Docker常用命令笔记
  • 【大模型】 使用llama.cpp 进行模型转换和量化
  • 网站建设评语/深圳将进一步优化防控措施
  • 建设一个网站需要什么软件/近一周热点新闻
  • wordpress推荐管理/seo快速上排名
  • 鞍山最新通知/seo课程培训班
  • 新的南宁网站建设公司/北京竞价托管代运营
  • 网络营销方式的对比分析论文/游戏优化大师手机版