image.png
npm install echarts
npm install echarts-wordcloud
<template>
<div id="main" style="height: 500px;"></div>
</template>
<script>
import * as echarts from 'echarts';
import 'echarts-wordcloud';
export default {
name: "worldCloud",
mounted() {
const list = [
{name: "陕西省", value: "111"},
{name: "安徽省", value: "222"},
{name: "湖北省", value: "458"},
{name: "海南省", value: "445"},
{name: "福建省", value: "456"},
{name: "山东省", value: "647"},
{name: "山西省", value: "189"},
{name: "河南省", value: "864"},
{name: "四川省", value: "652"},
];
const option = {
tooltip: {
show: true
},
series: [{
name: '项目分析',
type: 'wordCloud',
sizeRange: [10, 50],//文字范围
//文本旋转范围,文本将通过rotationStep45在[-90,90]范围内随机旋转
rotationRange: [-45, 90],
rotationStep: 45,
textStyle: {
color: function () {//文字颜色的随机色
return 'rgb(' + [
Math.round(Math.random() * 250),
Math.round(Math.random() * 250),
Math.round(Math.random() * 250)
].join(',') + ')';
},
},
data: list
}]
};
const myChartFour = echarts.init(document.getElementById('main'));
//使用制定的配置项和数据显示图表
myChartFour.setOption(option);
}
}
</script>
网友评论