Comments (1)
// js代码部分
<script> import echarts from 'echarts' require('echarts-wordcloud') require('echarts/theme/macarons') //require('echarts/theme/vintage') export default { props:{ // title: '' id: '', contData:'' }, data() { return { currentDate: new Date(), // 初始化空对象 // chartWorldcloud: null, option: '', // opinionData: [ // { // name: '租购', // value: 10000, // textStyle: { // normal: { // color: '#559DFF' // }, // emphasis: { // // color: '#f0f0f0' // } // } // } // ] opinionData: [] } }, watch: { contData: { handler: function (val, oldVal) { this.contData = val this.$nextTick(function() { this.drawGraph(this.id) }) if(this.contData){ this.opinionData = this.contData.opinionData } }, deep: true } }, mounted: function () { // 将回调延迟到下次 DOM 更新循环之后执行。在修改数据之后立即使用它,然后等待 DOM 更新 this.$nextTick(function() { this.drawGraph(this.id) }) if(this.contData){ this.opinionData = this.contData.opinionData } }, methods: { drawGraph(id) { let dom = document.getElementById(id) //初始化echarts 字符云图实例 let chartWorldcloud = echarts.init(dom, 'macarons') chartWorldcloud.showLoading() this.option = { tooltip: { show: true }, animation:false, series: [ { type: 'wordCloud', center: ['50%', '50%'], autoSize: { enable: true, minSize: 20 }, size: ['90%', '90%'], // 字体旋转角度 rotationRange: [0,0], textPadding: 0, gridSize: 2, sizeRange: [20, 50], shape: 'pentagon', width: 600, height: 350, drawOutOfBound: false, textStyle: { normal: { color: function () { return 'rgb(' + [ Math.round(Math.random() * 160), Math.round(Math.random() * 160), Math.round(Math.random() * 160) ].join(',') + ')'; } }, emphasis: { shadowBlur: 10, shadowColor: '#333' } }, data: this.opinionData } ] } chartWorldcloud.setOption(this.option); chartWorldcloud.hideLoading(); console.log('1',chartWorldcloud) console.log('2',chartWorldcloud.getDataURL()) console.log('3',chartWorldcloud.getConnectedDataURL()) let url = chartWorldcloud.getDataURL(); this.$emit('worldCloudData', url); //浏览器大小改变时重置大小 window.addEventListener("resize", function () { dom.style.width = 100+'%' chartWorldcloud.resize() }) } } }from echarts-wordcloud.
Related Issues (20)
- optionKeywords.html打开是空白的
- 如何设置点击后选中词的样式
- MaskImage HOT 5
- 有什么方法可以保证某几个词一定显示吗? HOT 1
- V2.0.0 和 echarts 5.0.1无法展示图云 HOT 2
- ReferenceError: window is not defined on next.js HOT 2
- Graph error Canvas2D HOT 1
- TypeScript error HOT 2
- 渲染大量数据时页面卡顿 HOT 3
- How can I use echarts wordcloud under nuxt3? Error is reported according to the document HOT 1
- How can I add event handler when clicking specific word in the cloud?
- 渲染大量数据时报错堆栈溢出
- Is this supposed to be interactive? HOT 2
- 能不能加上动画的效果或者有没有相关的配置?
- echarts5.4.2 版本 和 echarts-wordcloud2.1.0 版本 兼容报错了!!! HOT 4
- layout.js文件中window.postMessage是否有存在必要
- 基于此项目修改的微信小程序版,请官方大大过目
- 可以修改绘制起点origin吗?
- 使用maskImage渲染出来的字体特别不清楚,是什么原因
- maskImage无法显示 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from echarts-wordcloud.