You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.2 KiB

fetch('/wordcloud')
.then(response => response.json())
.then(data => {
// let wordCloudData = [];
// for (let word in data) {
// wordCloudData.push({ name: word, value: data[word] });
// }
let chart = echarts.init(document.getElementById('r2'));
let option = {
tooltip: {
show: true
},
series: [{
type: 'wordCloud',
shape: 'circle',
maskImage: new Image(),
left: 'center',
top: 'center',
width: '100%',
height: '100%',
right: null,
bottom: null,
sizeRange: [12, 50],
rotationRange: [-90, 90],
rotationStep: 45,
gridSize: 8,
drawOutOfBound: false,
textStyle: {
normal: {
fontFamily: 'sans-serif',
fontWeight: 'bold',
color: function () {
return 'rgb(' + [
Math.round(Math.random() * 200) + 50,
Math.round(Math.random() * 50),
Math.round(Math.random() * 50) + 50
].join(',') + ')';
}
},
emphasis: {
shadowBlur: 10,
shadowColor: '#333'
}
},
data: data
}]
};
// 加载遮罩图像
let maskImage = new Image();
maskImage.src = 'static/img/log.png';
maskImage.onload = function() {
option.series[0].maskImage = maskImage;
chart.setOption(option);
};
});