parent
2132150081
commit
7c2da27667
@ -1,61 +0,0 @@
|
||||
|
||||
require("./echarts-wordcloud");
|
||||
|
||||
// 将后台数据转成数组
|
||||
function doWordCloud(data) {
|
||||
let arr1 = [];
|
||||
for (let key in data) {
|
||||
let obj = { name: key, value: data[key] };
|
||||
arr1.push(obj);
|
||||
}
|
||||
return arr1;
|
||||
}
|
||||
//创建词云
|
||||
export default function createWordCloud(data) {
|
||||
let showData = null;
|
||||
if (Array.isArray(data)) {
|
||||
showData = data;
|
||||
} else {
|
||||
let words = doWordCloud(data);
|
||||
showData = words;
|
||||
}
|
||||
return {
|
||||
tooltip: {},
|
||||
series: [{
|
||||
type: 'wordCloud',
|
||||
gridSize: 12,
|
||||
sizeRange: [10, 52],
|
||||
rotationRange: [0, 0],
|
||||
shape: 'circle',
|
||||
width: 400,
|
||||
height: 400,
|
||||
left: 'center',
|
||||
top: 'center',
|
||||
right: null,
|
||||
bottom: null,
|
||||
drawOutOfBound: true,
|
||||
textStyle: {
|
||||
fontFamily: 'sans-serif',
|
||||
fontWeight: 'bold',
|
||||
color: function () {
|
||||
return 'rgb(' + [
|
||||
Math.round(Math.random() * 255),
|
||||
Math.round(Math.random() * 255),
|
||||
Math.round(Math.random() * 255)
|
||||
].join(',') + ')';
|
||||
}
|
||||
},
|
||||
emphasis: {
|
||||
textStyle: {
|
||||
shadowBlur: 100,
|
||||
shadowColor: '#333'
|
||||
}
|
||||
},
|
||||
data: showData
|
||||
// {
|
||||
// name: 'Sam S Club',
|
||||
// value: 10000,
|
||||
// }
|
||||
}]
|
||||
}
|
||||
}
|
Loading…
Reference in new issue