This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue

334 lines
8.1 KiB
Vue
Raw Normal View History

<script>
import chartDataFormat from "../../../charts/chartDataFormat";
import bus from '../../../../libs/bus';
2020-04-22 19:45:10 +08:00
let bgColorList=['#b3424a','#7bbfea', '#f05b72', '#596032', '#bd6758',
'#cd9a5b', '#918597', '#70a19f', '#005344', '#FF00FF',
'#f7acbc', '#5f5d46', '#66ffff', '#ccFF66', '#f47920',
'#769149', '#1d953f', '#abc88b', '#7f7522', '#9b95c9',
'#f3715c', '#ea66a6', '#d1c7b7', '#9d9087', '#77787b',
'#f58220', '#c37e00', '#00ae9d', '#f26522', '#76becc',
'#76624c', '#d71345', '#2468a2', '#ca8687', '#1b315e',
];
let overviewBgColor = ['#d64f40', '#ffdb28', '#7bfc95', '#77baf4',
'#ac958f', '', '', '', '', '', '', '', '', '', '', ];
/* let pieColor = ["#0c69ff","#59f747","#2eeab8","#b5ed8e",
"#205299","#ffd6c6","#a0ffdf","#9be524",
"#8abafc","#d181e8","#d88d50","#cce8ff",
"#161ef9"];*/
let pieColor = ['#d64f40', '#e66f60', '#f68f80', '#f6afa0',
'#ffdb28', '#ffeb38', '#fffb48', '#ffffbb'];
const commonOption={
title:{
show:false,
},
color: bgColorList,
legend:{
show:false,
},
2020-04-22 19:45:10 +08:00
toolbox:{
show:false,
top:'0',
showTitle:false,
tooltip:{
show:false,
},
feature:{
dataZoom:{
yAxisIndex:false
},
magicType:{
type:['stack']
},
// restore: {},
}
},
tooltip: {
trigger: 'axis',
confine:false,
extraCssText:'z-index:1000;',
backgroundColor:'rgba(221,228,237,1)',
borderColor:'rgba(221,228,237,1)',
textStyle:{color: "#000"}
// formatter:null,
// position:null,
},
grid: {
2020-04-22 19:45:10 +08:00
top: 30,
left: 0,
right: 30,
containLabel: true,
2020-04-22 19:45:10 +08:00
bottom:8,//156
},
dataZoom: [{
type: 'slider',
show:false,
xAxisIndex: [0],
start: 0,
end: 100,
height:25,
bottom:10,//96
left:40,
right:48,
}],
xAxis: {
type: 'time',
// boundaryGap: false,//line-false; bar-true;
axisLabel: {
intervale: 0,
rotate: 0,
formatter: function (value) {
value=bus.computeTimezone(value)
var t_date = new Date(value);
return [t_date.getFullYear(), t_date.getMonth() + 1, t_date.getDate()].join('-') + "\n"
+ [t_date.getHours(), t_date.getMinutes()].join(':');
}
},
axisPointer: {//y轴上显示指针对应的值
show: true,
},
splitLine:{
show:false
}
},
yAxis: {
type: 'value',
splitLine:{
show:true
},
axisLabel: {
// formatter:null,
},
},
useUTC: false,//使用本地时间
series: [],
2020-04-23 22:27:41 +08:00
};
2020-03-24 13:19:18 +08:00
const mapOptions={
2020-03-24 20:25:16 +08:00
geo:{
map:'',
roam:'scale',//鼠标是否可以控制缩放
scaleLimit:{
min:0.7,
max:1.5
},
2020-03-24 20:25:16 +08:00
// center:[],//当前视角的中心点,用经纬度表示
label: { //控制显示地图名称
normal: {
show: true
},
emphasis: {
show: true
},
} ,
itemStyle:{
// areaColor:'lightgrey', //设置默认状态下地图颜色
2020-03-24 20:25:16 +08:00
},
emphasis:{
itemStyle: {
areaColor:'white'
}
},
left:0,
top:0,
right:0,
bottom:0,
},
2020-03-24 13:19:18 +08:00
tooltip : {
trigger: 'item',
type:'cross',
alwaysShowContent: false,
// backgroundColor: 'rgba(0,0,0,0.7)',
2020-03-24 20:25:16 +08:00
borderColor:'#ffffff',
2020-03-24 13:19:18 +08:00
borderRadius: 4,
borderWidth: 1,
padding: 0,
},
2020-04-23 22:27:41 +08:00
};
const assetTypePie = {
title: {
show: false,
},
color: pieColor,
2020-04-23 22:27:41 +08:00
legend: {
show: false,
},
grid: {},
series: [],
tooltip : {}
};
const alertMessageBar = {
title: {
show: false,
},
color: overviewBgColor,
2020-04-23 22:27:41 +08:00
legend: {
show: false,
},
grid: {
top: 30,
left: 0,
right: 30,
containLabel: true,
bottom:8
},
2020-04-23 22:27:41 +08:00
series: [],
tooltip : {},
xAxis: {
type: 'value',
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
fontSize: 13*window.devicePixelRatio
}
2020-04-23 22:27:41 +08:00
},
yAxis: {
type: 'category',
axisLine: {
show: false
},
axisTick: {
show: false
},
data: [],
axisLabel: {
formatter: function(value) {
if (value.length > 12) {
return value.substring(0, 9) + "...";
}
return value;
},
fontSize: 12*window.devicePixelRatio
},
triggerEvent: true
},
};
const overviewLine = {
title:{
show: false,
},
color: overviewBgColor,
legend:{
show:false,
},
toolbox:{
show:false,
top:'0',
showTitle:false,
tooltip:{
show:false,
},
feature:{
dataZoom:{
yAxisIndex:false
},
magicType:{
type:['stack']
},
}
},
tooltip: {
trigger: 'axis',
confine: false,
extraCssText:'z-index:1000;',
formatter: function(v, i) {
return v;
}
},
grid: {
left: 6,
right: 20,
containLabel: true,
bottom: 0,
2020-04-23 22:27:41 +08:00
},
xAxis: {
type: 'time',
axisLabel: {
intervale: 0,
rotate: 0,
formatter: function (value) {
value = bus.computeTimezone(value)
let now = bus.computeTimezone(new Date().getTime());
let t_date = new Date(value);
let hhmm = [t_date.getHours(), t_date.getMinutes() < 10 ? "0" + t_date.getMinutes() : t_date.getMinutes()].join(':');
let mmdd = [t_date.getMonth() + 1, t_date.getDate() < 10 ? "0" + t_date.getDate() : t_date.getDate()].join('/');
if (value-now < 1000*60*60*24) {
return hhmm;
} else if (value-now >= 1000*60*60*24 && value-now < 1000*60*60*24*30) {
return mmdd + " " + hhmm;
} else {
return mmdd;
}
},
fontSize: 13*window.devicePixelRatio
},
axisPointer: {//y轴上显示指针对应的值
show: true,
},
splitLine:{
show:false
},
axisLine: {
show: false
},
axisTick: {
show: false
},
},
yAxis: {
type: 'value',
splitLine:{
show:true
},
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
fontSize: 13*window.devicePixelRatio,
formatter: function(value, i) {
let y;
if (value < 1000) {
y = value + " Bs";
} else if (value < 1000000) {
y = value/1000 + " KBs";
} else if (value >= 1000000) {
y = value/1000000 + " MBs";
} else {
y = value/1000000000 + " GBs";
}
return y;
}
}
},
useUTC: false,//使用本地时间
series: [],
2020-04-23 22:27:41 +08:00
};
2020-03-24 13:19:18 +08:00
const chartTypes={
line:{name:'line',option:commonOption},
overviewLine: {name: 'line', option: overviewLine},
2020-03-24 13:19:18 +08:00
map:{name:'map',option:mapOptions},
2020-04-23 22:27:41 +08:00
pie: {name: 'assetType', option: assetTypePie},
bar: {name: 'alertMessage', option: alertMessageBar}
};
2020-03-24 13:19:18 +08:00
export default {
getOption:function(type){
return Object.assign({},chartTypes[type].option);
},
2020-03-24 20:25:16 +08:00
setMap:function(map){
mapOptions.geo.map=map
},
getBgColorList:function(){
return Object.assign([],bgColorList)
2020-03-24 20:25:16 +08:00
}
}
</script>