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.
169 lines
3.2 KiB
169 lines
3.2 KiB
/*
|
|
* @Author: your name
|
|
* @Date: 2021-10-09 11:01:19
|
|
* @LastEditTime: 2021-11-21 16:51:55
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: In User Settings Edit
|
|
* @FilePath: /data-show/src/views/Index/spreadTheSound/opt.js
|
|
*/
|
|
import { bigNumberTransform } from "@/utils/gol/dataTool";
|
|
import * as echarts from "echarts";
|
|
|
|
let colors = [new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
{
|
|
offset: 0,
|
|
color: '#3373CC'
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: '#071a32'
|
|
}
|
|
], false), new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
{
|
|
offset: 0,
|
|
color: '#63AECC'
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: '#071a32'
|
|
}
|
|
], false), new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
{
|
|
offset: 0,
|
|
color: '#54BF93'
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: '#071a32'
|
|
}
|
|
], false), new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
{
|
|
offset: 0,
|
|
color: '#CC9D12'
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: '#071a32'
|
|
}
|
|
], false), new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
{
|
|
offset: 0,
|
|
color: '#CC7733'
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: '#071a32'
|
|
}
|
|
], false), new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
{
|
|
offset: 0,
|
|
color: '#CC5B41'
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: '#071a32'
|
|
}
|
|
], false)]
|
|
|
|
function createData(dataList = [],dx) {
|
|
let arr = [];
|
|
dataList.forEach(ele => {
|
|
let a = [];
|
|
let Data = ele.value || [];
|
|
dx.forEach(e => {
|
|
Data.forEach(ex => {
|
|
if (ex.key === e) {
|
|
a.push(ex.value)
|
|
}
|
|
})
|
|
})
|
|
let o = {
|
|
name: ele.key,
|
|
type: 'bar',
|
|
stack: 'total',
|
|
barWidth: 24,
|
|
emphasis: {
|
|
focus: 'series'
|
|
},
|
|
data: a
|
|
};
|
|
arr.push(o);
|
|
})
|
|
return arr;
|
|
}
|
|
|
|
export default function createOpt(dx = [], dataList = [], n = 4) {
|
|
let info = createData(dataList, dx);
|
|
return {
|
|
grid: {
|
|
left: 10,
|
|
right: '5%',
|
|
bottom: 10,
|
|
top: 52,
|
|
containLabel: true
|
|
},
|
|
tooltip: {
|
|
trigger: "axis",
|
|
backgroundColor: "#08182F",
|
|
color: "#fff",
|
|
borderColor: "#3373CC",
|
|
textStyle: {
|
|
color: "#fff", //设置文字颜色
|
|
},
|
|
extraCssText: "box-shadow: 0px 0px 10px 0px #3373CC;"
|
|
},
|
|
color: colors,
|
|
legend: {
|
|
textStyle: { //图例文字的样式
|
|
color: '#fff',
|
|
fontSize: 10
|
|
},
|
|
y: 12,
|
|
x: 16,
|
|
itemWidth: 12,
|
|
itemHeight: 12
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
axisLabel: {
|
|
interval: 0,
|
|
formatter: function (value) {
|
|
return (value.length > n ? (value.slice(0,n)+"...") : value )
|
|
},
|
|
},
|
|
axisLine: {
|
|
show: false,
|
|
lineStyle: {
|
|
color: "#fff",
|
|
},
|
|
},
|
|
data: dx
|
|
},
|
|
yAxis: {
|
|
type: 'value',
|
|
axisLine: {
|
|
show: false,
|
|
lineStyle: {
|
|
color: "#fff",
|
|
},
|
|
},
|
|
axisLabel: {
|
|
formatter: (value) => {
|
|
let str = bigNumberTransform(value);
|
|
return str;
|
|
}
|
|
},
|
|
splitLine: {
|
|
lineStyle: {
|
|
type: "dashed", // y轴分割线类型
|
|
color: "#012b4b",
|
|
},
|
|
},
|
|
},
|
|
series: info
|
|
}
|
|
|
|
} |