|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
/*
|
|
|
|
|
* @Author: your name
|
|
|
|
|
* @Date: 2021-10-21 11:36:36
|
|
|
|
|
* @LastEditTime: 2021-11-12 16:40:03
|
|
|
|
|
* @LastEditTime: 2021-11-25 11:07:14
|
|
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
|
|
* @Description: In User Settings Edit
|
|
|
|
|
* @FilePath: /data-show/src/utils/gol/bubbleWord.js
|
|
|
|
|
*/
|
|
|
|
|
import { compare } from "./dataTool"
|
|
|
|
|
import * as echarts from "echarts";
|
|
|
|
|
// 将后台数据转成数组
|
|
|
|
|
function doWordCloud(data) {
|
|
|
|
|
let arr1 = [];
|
|
|
|
@ -25,15 +26,49 @@ function bubbleChart(data = [], format = []) {
|
|
|
|
|
maxValue = Math.max.apply(null, temp);
|
|
|
|
|
// 气泡颜色数组
|
|
|
|
|
let color = [
|
|
|
|
|
"#FFB600",
|
|
|
|
|
"#886CFF",
|
|
|
|
|
"#0084FF",
|
|
|
|
|
"#4CB690",
|
|
|
|
|
"#58B458",
|
|
|
|
|
"#6C6C6C",
|
|
|
|
|
"#F56161",
|
|
|
|
|
"#FC754C",
|
|
|
|
|
"#5F5EEC",
|
|
|
|
|
{
|
|
|
|
|
key: '#047ddc',
|
|
|
|
|
fontColor: '#8ec0ea',
|
|
|
|
|
value: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: 'rgba(4, 60, 135, 1)'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: 'rgba(1, 11, 25, 1)'
|
|
|
|
|
}
|
|
|
|
|
], false)
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '#a3951f',
|
|
|
|
|
fontColor: '#a4a27f',
|
|
|
|
|
value: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: 'rgba(120, 124, 14, 1)'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: 'rgba(1, 11, 25, 1)'
|
|
|
|
|
}
|
|
|
|
|
], false)
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '#01aa87',
|
|
|
|
|
fontColor: '#99e5d5',
|
|
|
|
|
value: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: 'rgba(25, 137, 129, 1)'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: 'rgba(1, 11, 25, 1)'
|
|
|
|
|
}
|
|
|
|
|
], false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
// 气泡颜色备份
|
|
|
|
|
let bakeColor = [...color];
|
|
|
|
@ -61,7 +96,9 @@ function bubbleChart(data = [], format = []) {
|
|
|
|
|
if (!bakeColor.length) bakeColor = [...color];
|
|
|
|
|
let colorSet = new Set(bakeColor);
|
|
|
|
|
let curIndex = Math.round(Math.random() * (colorSet.size - 1));
|
|
|
|
|
let curColor = bakeColor[curIndex];
|
|
|
|
|
let borderColor = bakeColor[curIndex].key;
|
|
|
|
|
let curColor = bakeColor[curIndex].value;
|
|
|
|
|
let fontColor = bakeColor[curIndex].fontColor;
|
|
|
|
|
colorSet.delete(curColor);
|
|
|
|
|
bakeColor = [...colorSet];
|
|
|
|
|
// 气泡大小设置
|
|
|
|
@ -73,6 +110,11 @@ function bubbleChart(data = [], format = []) {
|
|
|
|
|
value: item[format[1]],
|
|
|
|
|
symbolSize: size,
|
|
|
|
|
draggable: true,
|
|
|
|
|
label: {
|
|
|
|
|
show: true,
|
|
|
|
|
color: fontColor,
|
|
|
|
|
fontSize: 12
|
|
|
|
|
},
|
|
|
|
|
itemStyle: {
|
|
|
|
|
normal: {
|
|
|
|
|
color: curColor,
|
|
|
|
@ -81,6 +123,9 @@ function bubbleChart(data = [], format = []) {
|
|
|
|
|
shadowOffsetX: 0,
|
|
|
|
|
shadowOffsetY: 0,
|
|
|
|
|
shadowColor: "rgba(0,0,0,0.3)",
|
|
|
|
|
borderType : 'solid',
|
|
|
|
|
borderColor: borderColor,
|
|
|
|
|
borderWidth: 1
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
@ -119,12 +164,6 @@ export default function createWordCloud(obj) {
|
|
|
|
|
series: [{
|
|
|
|
|
type: 'graph',
|
|
|
|
|
layout: 'force',
|
|
|
|
|
label: {
|
|
|
|
|
show: true,
|
|
|
|
|
color: "#FFF",
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
force: {
|
|
|
|
|
gravity: 0.2,
|
|
|
|
|
repulsion: bubble.repulsion,
|
|
|
|
|