|
@@ -6,6 +6,7 @@
|
|
import resize from './mixins/resize'
|
|
import resize from './mixins/resize'
|
|
import "echarts-wordcloud/dist/echarts-wordcloud";
|
|
import "echarts-wordcloud/dist/echarts-wordcloud";
|
|
import "echarts-wordcloud/dist/echarts-wordcloud.min";
|
|
import "echarts-wordcloud/dist/echarts-wordcloud.min";
|
|
|
|
+ import '../../assets/js/echarts-wordcloud.min'
|
|
|
|
|
|
export default {
|
|
export default {
|
|
mixins: [resize],
|
|
mixins: [resize],
|
|
@@ -40,8 +41,21 @@
|
|
chart: null
|
|
chart: null
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ watch: {
|
|
|
|
+ //观察option的变化
|
|
|
|
+ data: {
|
|
|
|
+ handler(newVal, oldVal) {
|
|
|
|
+ if (newVal) {
|
|
|
|
+ this.initChart();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ deep: true //对象内部属性的监听,关键。
|
|
|
|
+ }
|
|
|
|
+ },
|
|
mounted() {
|
|
mounted() {
|
|
- this.initChart();
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.initChart();
|
|
|
|
+ })
|
|
},
|
|
},
|
|
beforeDestroy() {
|
|
beforeDestroy() {
|
|
if (!this.chart) {
|
|
if (!this.chart) {
|
|
@@ -53,7 +67,7 @@
|
|
methods: {
|
|
methods: {
|
|
initChart() {
|
|
initChart() {
|
|
this.chart = echarts.init(document.getElementById(this.id));
|
|
this.chart = echarts.init(document.getElementById(this.id));
|
|
- const option = {
|
|
|
|
|
|
+ let option = {
|
|
title: {
|
|
title: {
|
|
text: this.title,
|
|
text: this.title,
|
|
x: "center"
|
|
x: "center"
|
|
@@ -65,6 +79,7 @@
|
|
series: [
|
|
series: [
|
|
{
|
|
{
|
|
type: "wordCloud",
|
|
type: "wordCloud",
|
|
|
|
+ shape: "circle",
|
|
//用来调整词之间的距离
|
|
//用来调整词之间的距离
|
|
gridSize: 6,
|
|
gridSize: 6,
|
|
//用来调整字的大小范围
|
|
//用来调整字的大小范围
|
|
@@ -75,14 +90,19 @@
|
|
//用来调整词的旋转方向,,[0,0]--代表着没有角度,也就是词为水平方向,需要设置角度参考注释内容
|
|
//用来调整词的旋转方向,,[0,0]--代表着没有角度,也就是词为水平方向,需要设置角度参考注释内容
|
|
// rotationRange: [-45, 0, 45, 90],
|
|
// rotationRange: [-45, 0, 45, 90],
|
|
// rotationRange: [ 0,90],
|
|
// rotationRange: [ 0,90],
|
|
- rotationRange: [0, 90],
|
|
|
|
|
|
+ rotationRange: [-90, 90],
|
|
//随机生成字体颜色
|
|
//随机生成字体颜色
|
|
// maskImage: maskImage,
|
|
// maskImage: maskImage,
|
|
textStyle: {
|
|
textStyle: {
|
|
normal: {
|
|
normal: {
|
|
color: function() {
|
|
color: function() {
|
|
- var colors = ['#00BBFE', '#3F96EA', '#0B5AAD', "#4198ED",'#F29901'];
|
|
|
|
- return colors[parseInt(Math.random() * 10)];
|
|
|
|
|
|
+ // var colors = ['#00BBFE', '#3F96EA', '#0B5AAD', "#4198ED",'#F29901'];
|
|
|
|
+ // return colors[parseInt(Math.random() * 10)];
|
|
|
|
+ return 'rgb(' + [
|
|
|
|
+ Math.round(Math.random() * 256),
|
|
|
|
+ Math.round(Math.random() * 256),
|
|
|
|
+ Math.round(Math.random() * 256)
|
|
|
|
+ ].join(',') + ')';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|