chart.setOption({
tooltip: {
formatter(item) {
// console.log('item', item);
return `${item.name}: ${item.value}次`;
},
},
series: [{
type: 'wordCloud',
shape: 'rect',
width: '80%',
height: '80%',
size: [25,120],
rotationRange: [-90, 90],
gridSize: 1,
textStyle: {
normal: {
fontFamily: 'Microsoft YaHei',
color() {
return `rgb(${
[Math.round(Math.random() * 160),
Math.round(Math.random() * 160),
Math.round(Math.random() * 160)]
.join(',')})`;
},
},
emphasis: {
shadowBlur: 3,
shadowColor: '#333',
},
},
data: hotwordList,
}],
});
通过改变data中的内容,加入n的确可以达到换行的目的,但是会发生文字堆叠的情况
可以对data数据做处理,对name属性做相应的判断,如果大于多少位,就在多少位以后插入n,在官网给的案例里面name加n有作用