Browse Source

更新数据

lite
luyisha 3 years ago
parent
commit
826e73ba66
  1. 237
      src/views/index.vue

237
src/views/index.vue

@ -197,7 +197,8 @@ export default {
mounted() { mounted() {
this.getStat(); this.getStat();
this.getHomeBarData(); this.btgetdata();
this.getPieData();
this.getInfoDatas(); this.getInfoDatas();
this.getGcgNumDatas(); this.getGcgNumDatas();
@ -237,7 +238,6 @@ export default {
homeApi.allTygGroupTimeNum({granularity:rqtp}).then(res => { homeApi.allTygGroupTimeNum({granularity:rqtp}).then(res => {
const tmpdata = res.data.data.allTimeData const tmpdata = res.data.data.allTimeData
const dkeys = res.data.data.dkeys const dkeys = res.data.data.dkeys
const groupsData = res.data.data.groupsData
let datas = [] let datas = []
Object.values(tmpdata).forEach((value) => { Object.values(tmpdata).forEach((value) => {
@ -247,16 +247,6 @@ export default {
that.klqsDatas = datas; that.klqsDatas = datas;
that.klqsXDatas = dkeys; that.klqsXDatas = dkeys;
that.proportionData = [];that.groupNameData=[];that.dataP=[];
groupsData.forEach((item) => {
that.proportionData.push(item.proportion);
that.groupNameData.push(item.groupName);
that.dataP.push({
name:item.groupName,
value:item.proportion.split('%')[0]
})
})
this.home_bar(); this.home_bar();
}); });
}, },
@ -265,7 +255,6 @@ export default {
selitem(type) { selitem(type) {
// console.log(type); // console.log(type);
this.klselt = type; this.klselt = type;
// this.getHomeBarData();
this.btgetdata(); this.btgetdata();
this.autoTimer0(); this.autoTimer0();
}, },
@ -499,7 +488,7 @@ export default {
] ]
}); });
} }
clearInterval(this.timer1);// clearInterval(that.timer1);//
that.timer1 = setInterval(function () { that.timer1 = setInterval(function () {
myChart.clear(); myChart.clear();
option && myChart.setOption(option); option && myChart.setOption(option);
@ -772,25 +761,15 @@ export default {
}); });
}, },
getHomeBarData() { getPieData() {
let that = this; let that = this;
homeApi.homeBarData().then(res => { homeApi.homeBarData().then(res => {
// /pass.passcc/allGroupTimeNum&granularity=daily // /pass.passcc/allGroupTimeNum&granularity=daily
// get allTimeData // get allTimeData
const tmpdata = res.data.data.allTimeData const pieData = res.data.data.groupsData;
const dkeys = res.data.data.dkeys
const groupsData = res.data.data.groupsData
let datas = []
Object.values(tmpdata).forEach((value) => {
datas.push(value.num);
});
that.klqsDatas = datas;
that.klqsXDatas = dkeys;
that.proportionData = [];that.groupNameData=[];that.dataP=[]; that.proportionData = [];that.groupNameData=[];that.dataP=[];
groupsData.forEach((item) => { pieData.forEach((item) => {
that.proportionData.push(item.proportion); that.proportionData.push(item.proportion);
that.groupNameData.push(item.groupName); that.groupNameData.push(item.groupName);
that.dataP.push({ that.dataP.push({
@ -866,7 +845,7 @@ export default {
// {name: '',value: 12,}, // {name: '',value: 12,},
// // {name: '',value: 13,} // // {name: '',value: 13,}
// ]; // ];
var dataP = that.dataP;
function hexToRgba(hex, opacity) { function hexToRgba(hex, opacity) {
return ( return (
'rgba(' + 'rgba(' +
@ -880,122 +859,116 @@ export default {
')' ')'
); );
} }
let color = ['#ff9acc', '#6666ff', '#ff6600', '#02ff00','#00ffff', '#fdff00'];
let color1=[], color2=[], color3=[]; function run(myChart){
// var dataP = that.dataP;
color.forEach((item) => { // -
color1.push(item, 'transparent'); let color = ['#ff9acc', '#6666ff', '#ff6600', '#02ff00','#00ffff', '#fdff00'];
color2.push(hexToRgba(item, 0.4), 'transparent'); let color1=[], color2=[], color3=[];
color3.push(hexToRgba(item, 1), 'transparent'); //
}); color.forEach((item) => {
let data1 = []; color1.push(item, 'transparent');
let sum = 0; color2.push(hexToRgba(item, 0.4), 'transparent');
// color3.push(hexToRgba(item, 1), 'transparent');
dataP.forEach((item) => { });
sum += Number(item.value); let data1 = [];
}); let sum = 0;
// //
dataP.forEach((item, index) => { dataP.forEach((item) => {
if (item.value !== 0) { sum += Number(item.value);
data1.push(item, { });
name: '', //
value: sum / 70, dataP.forEach((item, index) => {
labelLine: { if (item.value !== 0) {
show: false, data1.push(item, {
lineStyle: { name: '',
color: 'transparent', value: sum / 70,
}, labelLine: {
}, show: false,
itemStyle: { lineStyle: {
color: 'transparent', color: 'transparent',
},
});
}
});
var option = {
tooltip: {
formatter: (params) => {
if (params.name !== '') {
return params.name + ' : ' + params.value + '\n' + '%';
}
},
},
grid: {
top: 0,
bottom: 0,
left: 0,
right: 0,
containLabel: true,
},
series: [
{
type: 'pie',
radius: ['90%', '80%'],
center: ['50%', '50%'],
hoverAnimation: false,
startAngle: 90,
selectedMode: 'single',
selectedOffset: 0,
itemStyle: {
normal: {
color: (params) => {
// console.log('params', params)
return color2[params.dataIndex];
}, },
}, },
}, itemStyle: {
label: { color: 'transparent',
show: false,
formatter: '{b}' + ' ' + '{c}',
},
data: data1,
z: 666,
},
{
type: 'pie',
radius: ['90%', '100%'],
center: ['50%', '50%'],
hoverAnimation: false,
startAngle: 90,
selectedMode: 'single',
selectedOffset: 0,
itemStyle: {
normal: {
color: (params) => {
return color3[params.dataIndex];
},
}, },
}, });
label: {
show: false,
formatter: '{b}' + ' ' + '{c}',
},
data: data1,
z: 666,
},
],
}
function run(myChart){
// -
myChart.setOption({
series: [{
data: data1,
},
{
data: data1,
} }
]
}); });
var option = {
tooltip: {
formatter: (params) => {
if (params.name !== '') {
return params.name + ' : ' + params.value + '\n' + '%';
}
},
},
grid: {
top: 0,
bottom: 0,
left: 0,
right: 0,
containLabel: true,
},
series: [
{
type: 'pie',
radius: ['90%', '80%'],
center: ['50%', '50%'],
hoverAnimation: false,
startAngle: 90,
selectedMode: 'single',
selectedOffset: 0,
itemStyle: {
normal: {
color: (params) => {
// console.log('params', params)
return color2[params.dataIndex];
},
},
},
label: {
show: false,
formatter: '{b}' + ' ' + '{c}',
},
data: data1,
z: 666,
},
{
type: 'pie',
radius: ['90%', '100%'],
center: ['50%', '50%'],
hoverAnimation: false,
startAngle: 90,
selectedMode: 'single',
selectedOffset: 0,
itemStyle: {
normal: {
color: (params) => {
return color3[params.dataIndex];
},
},
},
label: {
show: false,
formatter: '{b}' + ' ' + '{c}',
},
data: data1,
z: 666,
},
],
}
option && myChart.setOption(option);
} }
// 使 // 使
setTimeout(()=>{ setTimeout(()=>{
var pieDom1 = document.getElementById("indexPie1"); var pieDom1 = document.getElementById("indexPie1");
var myChart = echarts.init(pieDom1); var myChart = echarts.init(pieDom1);
option && myChart.setOption(option); run(myChart);
setInterval(function () { setInterval(function () {
myChart.clear(); myChart.clear();
option && myChart.setOption(option); that.getPieData();
run(myChart); run(myChart);
}, 4000); }, 4000);
}, 200) }, 200)

Loading…
Cancel
Save