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.
156 lines
4.5 KiB
156 lines
4.5 KiB
/*
|
|
* @Author: your name
|
|
* @Date: 2021-10-12 10:11:24
|
|
* @LastEditTime: 2021-11-22 10:11:55
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: In User Settings Edit
|
|
* @FilePath: /data-show/src/views/BrandInsight/titsopo/opt.js
|
|
*/
|
|
import * as echarts from "echarts";
|
|
import { bigNumberTransform } from "@/utils/gol/dataTool"
|
|
let colors = ['#546fc5', '#91cb74', '#f9c857', '#ed6565', '#72bfde', '#3aa272', '#fb8351'];
|
|
function createData(ds = [], hotIndex = []) {
|
|
let arr = [];
|
|
for (let i = 0; i < ds.length; i++) {
|
|
let arr1 = ds[i];
|
|
for (let j = 0; j < arr1.length; j++) {
|
|
let n = arr.findIndex(ele => {
|
|
return ele.name === arr1[j].key;
|
|
})
|
|
if (n === -1) {
|
|
let obj =
|
|
{
|
|
name: arr1[j].key,
|
|
type: 'line',
|
|
symbol: 'none',
|
|
areaStyle: {
|
|
normal: {
|
|
opacity: 0.2,
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
offset: 0, color: colors[j] // 0% 处的颜色
|
|
}, {
|
|
offset: 1, color: '#000' // 100% 处的颜色
|
|
}]
|
|
),
|
|
}
|
|
},
|
|
emphasis: {
|
|
focus: 'series'
|
|
},
|
|
data: [arr1[j].value],
|
|
markPoint: {
|
|
data: [],
|
|
}
|
|
}
|
|
arr.push(obj)
|
|
} else {
|
|
arr[n].data.push(arr1[j].value)
|
|
}
|
|
}
|
|
}
|
|
//设定标记点
|
|
hotIndex.forEach(e => {
|
|
let yMax = 0; //y轴
|
|
let colorMax = 0; //颜色的索引
|
|
for(let i = 0; i<arr.length; i++){
|
|
if(arr[i].data[e] * 1 > yMax){
|
|
yMax = arr[i].data[e];
|
|
colorMax = i;
|
|
}
|
|
}
|
|
arr.forEach(ele => {
|
|
ele.markPoint.data.push(
|
|
{
|
|
name: 'Max',
|
|
xAxis: e, yAxis: yMax,
|
|
symbol: 'pin',
|
|
symbolSize: 16,
|
|
symbolOffset: [0, '-70%'],
|
|
itemStyle: {color: colors[colorMax]},
|
|
}
|
|
)
|
|
})
|
|
})
|
|
return arr;
|
|
}
|
|
export default function createOpt(dx=[], ds=[], sTimeType = 20, hotIndex = []) {
|
|
let data = createData(ds,hotIndex)
|
|
return {
|
|
grid: {
|
|
left: 10,
|
|
right: '3%',
|
|
bottom: 10,
|
|
top: 36,
|
|
containLabel: true
|
|
},
|
|
tooltip: {
|
|
trigger: "axis",
|
|
backgroundColor: "#08182F",
|
|
color: "#fff",
|
|
borderColor: "#3373CC",
|
|
textStyle: {
|
|
color: "#fff", //设置文字颜色
|
|
},
|
|
extraCssText: "box-shadow: 0px 0px 10px 0px #3373CC;"
|
|
},
|
|
legend: {
|
|
icon: 'roundRect',
|
|
textStyle: { //图例文字的样式
|
|
color: '#fff',
|
|
fontSize: 10
|
|
},
|
|
y: 0,
|
|
x: 10,
|
|
itemWidth: 12,
|
|
itemHeight: 12
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
boundaryGap: false,
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
axisLine: {
|
|
show: false,
|
|
lineStyle: {
|
|
color: "#fff",
|
|
},
|
|
},
|
|
axisLabel: {
|
|
formatter: (value) => {
|
|
let str = "";
|
|
if(sTimeType === 34) {
|
|
str = value.substring(10, 16)
|
|
} else {
|
|
str = value.substring(0, 10)
|
|
}
|
|
return str;
|
|
}
|
|
},
|
|
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: data
|
|
}
|
|
}
|