隐藏页面特效

热词cloud-EChart安装

1.安装
npm install echarts

npm install echarts-wordcloud
注意版本:echarts版本5只能和wordcloud版本2的一起使用 ;echarts版本4只能和wordcloud版本1的一起使用

 

2.在main.js引入
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
require('echarts-wordcloud')
3.使用
<template>
<div id="echartsWordcloud" style="width:200px;height:200px;background-color:#0d071f"></div>
</template>
<script>
var run = 999
var createRandomItemStyle2 = function () {
var colorArr = ['#fda67e', '#81cacc', '#cca8ba', "#88cc81", "#82a0c5", '#fddb7e', '#735ba1', '#bda29a', '#6e7074', '#546570', '#c4ccd3'];
var flag = parseInt(Math.random() * 10);
return {
normal: {
fontFamily: '微软雅黑',
color:colorArr[flag]
}
};
}
var createRandomItemStyle1 = function (params) {    //此方法与下方配置中的第一个textStle下的color等同
var colors = ['#fda67e', '#81cacc', '#cca8ba', "#88cc81", "#82a0c5", '#fddb7e', '#735ba1', '#bda29a', '#6e7074', '#546570', '#c4ccd3'];
return colors[parseInt(Math.random() * 10)];
}
export default{
data() {
return {
data : [{name: "小区",value: "283"},{name: "留言板",value: "101"},{name: "业主",value: "148"},
{name: "同学",value: "283"},{name: "老师",value: "101"},{name: "话痨",value: "148"}
]
}
},
mounted(){
this.initEcharts(this.data)
},
methods:{
initEcharts(data){
let echartsWordcloud = this.$echarts.init(document.getElementById("echartsWordcloud"));
let option = {
title: {
text: "标题",
x: "center"
},
// backgroundColor: "#fff",
series: [
{
type: "wordCloud",
//用来调整词之间的距离
gridSize: 10,
//用来调整字的大小范围
sizeRange: [14, 26],
rotationRange: [0, 0],
//随机生成字体颜色
// textStyle: {
// fontFamily: 'sans-serif',
// // fontWeight: 'bold',
// // Color can be a callback function or a color string
// color: function () {
// // Random color
// return 'rgb(' + [
// Math.round(Math.random() * 160),
// Math.round(Math.random() * 160),
// Math.round(Math.random() * 160)
// ].join(',') + ')';
// }
// },
// 也可以自己定制颜色
textStyle: {
fontFamily: '微软雅黑',
color: function () {
var colors = ['#fda67e', '#81cacc', '#cca8ba', "#88cc81", "#82a0c5", '#fddb7e', '#735ba1', '#bda29a', '#6e7074', '#546570', '#c4ccd3'];
return colors[parseInt(Math.random() * 10)];
}
},
// textStyle: {
// color: function() {
// return (
// "rgb(" +
// Math.round(Math.random() * 255) +
// ", " +
// Math.round(Math.random() * 255) +
// ", " +
// Math.round(Math.random() * 255) +
// ")"
// );
// }
// },
//位置相关设置
left: "center",
top: "center",
right: null,
bottom: null,
width: "100%",
height: "100%",
//数据
data: data
}
]
};
echartsWordcloud.setOption(option);
//点击事件
echartsWordcloud.on("click",function(e){
alert(e)
})
}
}
}
</script>
原文链接:https://blog.csdn.net/qq_37550440/article/details/116779706


__EOF__

本文作者往心。
本文链接https://www.cnblogs.com/lx06/p/14907760.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   往心。  阅读(206)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示