Browse Source

修改图表显示

master
453530270@qq.com 3 years ago
parent
commit
cb52788680
  1. 206
      src/views/WhView.vue

206
src/views/WhView.vue

@ -367,12 +367,12 @@ export default {
// //
this.whtdrs() this.whtdrs()
// this.gc_line() // this.gc_line()
// //
this.libinfoData() this.libinfoData()
// websocket // websocket
this.ws = new WebSocket(publicConfig.WS_URL_WH); this.ws = new WebSocket(publicConfig.WS_URL_WH);
// this.getsckdata() this.getsckdata()
}, },
methods: { methods: {
@ -564,205 +564,25 @@ export default {
whtdrs() { whtdrs() {
homeApi.whtdrs().then(res => { homeApi.whtdrs().then(res => {
console.log("whtd", res) console.log("whtd", res)
// const tmpdata = res.data.data
// this.xData.push(res.data.data[0].list.dkeys)
// // X
// const darr =new Array;
// tmpdata.forEach(function(item,idx){
// // list
// const list = item.list
// darr.push(list.dvalue)
// })
// this.whfwdata = darr
// get allTimeData // get allTimeData
const tmpdata = res.data.data const tmpdata = res.data.data
// X // X
const xarr = new Array const xarr = tmpdata[0].list.dkeys
const darr = new Array; const darr = new Array;
tmpdata.forEach(function (item, idx) { tmpdata.forEach(function (item, idx) {
// list // list
const list = item.list const list = item.list
xarr.push(list.dkeys)
darr.push(list.dvalue) darr.push(list.dvalue)
}) })
// console.log(darr) // console.log(darr)
this.zxlindata = xarr this.zxlindata = xarr
this.zxliddata = darr this.zxliddata = darr
// //
this.gc_line() this.cg_line()
}); });
}, },
//
gc_line() {
var chartDom = document.getElementById("gc_charts");
var myChart = echarts.init(chartDom);
var option
var xData = this.xData
//var xData = ['09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00',];
var color = ['#FF99CC', '#6666FF', '#FF6600', '#7049f0', '#fa704d', '#01babc',]
var name = ['图书馆', '文化馆', '博物馆']
var xData = this.zxlindata
var data = this.zxliddata
var series = [];
for (var i = 0; i < 3; i++) {
series.push({
name: name[i],
type: "line",
symbolSize: 3,// 10 [20, 10] 2010[ default: 4 ]
symbol: 'circle',//ECharts 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
smooth: true, //线
showSymbol: false, // symbol, false tooltip hover
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: color[i]
}, {
offset: 0.8,
color: 'rgba(255,255,255,0)'
}], false),
// shadowColor: 'rgba(255,255,255, 0.1)',
shadowBlur: 10,
opacity: 0.3,
}
},
itemStyle: {
normal: {
color: color[i],
lineStyle: {
width: 1,
type: 'solid' //'dotted'线 'solid'线
},
borderColor: color[i], // color
borderWidth: 8,//线 0 [ default: 0 ]
barBorderRadius: 0,
label: {
show: false,
},
opacity: 0.5,
}
},
data: data[i],
})
}
option = {
// backgroundColor: "#141f56",
legend: {
top: 0,
right: 10,
itemGap: 15,
itemWidth: 20,
itemHeight: 20,
// icon: ['image://img/tyc_icon.png', 'image://img/tyg_icon.png', 'image://img/tyc_icon.png'],
textStyle: {
color: '#fff',
fontSize: '14'
},
data: [
{ icon: 'image://img/tyc_icon.png', name: '图书馆' },
{ icon: 'image://img/tyg_icon.png', name: '文化馆' },
{ icon: 'image://img/yyg_icon.png', name: '博物馆' },
]
},
title: {
// text: "",
textStyle: {
color: '#fff',
fontSize: '22',
fontWeight: 'normal',
},
subtextStyle: {
color: '#90979c',
fontSize: '16',
},
},
tooltip: {
trigger: "axis",
axisPointer: { //
type: 'line', // 线'line' | 'shadow'
lineStyle: {
color: '#57617B'
}
},
formatter: '{b}<br />{a0}: {c0}<br />{a1}: {c1}<br />{a2}: {c2}',
backgroundColor: 'rgba(0,0,0,0.7)', //
padding: [8, 10], //
extraCssText: 'box-shadow: 0 0 3px rgba(255, 255, 255, 0.4);', //
},
grid: {
borderWidth: 0,
top: 240,
left: 30,
right: 10,
bottom: 240,
textStyle: {
color: "#fff"
}
},
xAxis: [{
type: "category",
axisLine: {
show: false,
},
splitLine: {
show: false,
},
boundaryGap: false, //
axisTick: {
show: false
},
splitArea: {
show: false
},
axisLabel: {
inside: false,
interval: 0,
textStyle: {
color: '#FFFFFF',
fontWeight: 'normal',
fontSize: '12',
},
},
data: xData,
}],
yAxis: {
type: 'value',
axisTick: {
show: false
},
axisLine: {
show: false,
},
splitLine: {
show: true,
lineStyle: {
color: '#32346c ',
}
},
axisLabel: {
textStyle: {
color: '#0095FF',
fontWeight: 'normal',
fontSize: '12',
},
formatter: '{value}',
},
},
series: series,
}
option && myChart.setOption(option);
},
// //
libinfoData() { libinfoData() {
homeApi.libLeaseData().then(res => { homeApi.libLeaseData().then(res => {
@ -1074,22 +894,6 @@ export default {
} }
option = { option = {
// backgroundColor: "#141f56", // backgroundColor: "#141f56",
legend: {
bottom: 0,
right: 20,
itemGap: 20,
itemWidth: 20,
itemHeight: 20,
textStyle: {
color: '#fff',
fontSize: '14'
},
data: [
{ icon: 'image://img/tyc_icon.png', name: '体育场' },
{ icon: 'image://img/tyg_icon.png', name: '体育馆' },
{ icon: 'image://img/yyg_icon.png', name: '游泳场馆' },
]
},
title: { title: {
// text: "", // text: "",
textStyle: { textStyle: {
@ -1231,7 +1035,7 @@ export default {
that.rsqsDatas.push(item.list) that.rsqsDatas.push(item.list)
}) })
that.zxlindata = jstr.toDayGroupsEnterNum.data[0].list.dkeys; that.zxlindata = jstr.getLibraryGroupHoursList.data[0].list.dkeys;
that.rsqsDatas.forEach((item) => { that.rsqsDatas.forEach((item) => {
let rsqsData = [] let rsqsData = []
Object.getOwnPropertyNames(item).forEach((value) => { Object.getOwnPropertyNames(item).forEach((value) => {

Loading…
Cancel
Save