Echart词云
![词云图](https://img-blog.csdnimg.cn/946808f4b2aa453690d9d9f0701193af.png)
const option = {
series: [
{
shape: 'circle',//形状 'circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star'
//maskImage: maskImage ,//使用base64 词云配置背景图片
type: "wordCloud",
left: "center",
top: "center",
width: "100%",
height: "100%",
right: null,
backgroundColor:'#FAF2F2FF',
bottom: null,
sizeRange: (() => {
return [
this.option.minFontSize || 12,
this.option.maxFontSize || 60
];
})(),// 词的大小,最小12px,最大60px,可以在这个范围调整词的大小
rotationRange: (() => {
if (this.option.rotate) {
return [-90, 90];
} else {
return [0, 0];
}
})(), 每个词旋转的角度范围
//rotationRange: [-45, 0, 45, 90],
rotationStep: (() => {
if (this.option.rotate) {
return 15;
} else {
return 0;
}
})(),// // 词间距,数值越小,间距越小,这里间距太小的话,会出现大词把小词套住的情况,比如一个大的口字,中间会有比较大的空隙,这时候他会把一些很小的字放在口字里面,这样的话,鼠标就无法选中里面的那个小字
gridSize: this.option.split || 30,
drawOutOfBound: false,
// 这是全局的文字样式,相对应的还可以对每个词设置字体样式
textStyle: {
// fontFamily: 'sans-serif',
fontFamily: 'Arial',
fontWeight: 'normal',
// 颜色可以用一个函数来返回字符串(用来控制颜色的范围)
color: function () {
// Random color
return 'rgb(' + [
Math.round(Math.random() * 160),
Math.round(Math.random() * 160),
Math.round(Math.random() * 160)
].join(',') + ')';
},
// color: function () {
// return 'rgb(' + [
// Math.round(Math.random() * 200) + 50,
// Math.round(Math.random() * 50),
// Math.round(Math.random() * 50) + 50
// ].join(',') + ')';
// },
normal: {
fontFamily: "sans-serif",
fontWeight: "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: "#111111"
}
},
//动画
layoutAnimation:true,
data: optionData
// data: optionData
},
]
};