嘉禾二期设备管理
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.

180 lines
4.2 KiB

2 years ago
<template>
<div class="box">
<tit :title="'碳排放月总量环比'">
<!-- <div class="tit-r">单位kw·h</div> -->
</tit>
<div id="mainRingPercent"></div>
</div>
</template>
<script>
import tit from "./tit.vue";
2 years ago
import { getSixMonthCarbonQoq } from "@/api/energySourcesProvince/energySourcesProvince"
2 years ago
export default {
data() {
return {
};
},
components: {
tit
},
created() {
this.$nextTick(() => {
2 years ago
this.getData()
2 years ago
})
},
mounted() {
},
methods: {
2 years ago
getData() {
getSixMonthCarbonQoq().then(res => {
const data = res.data.data
const sortedKeys = Object.keys(data).sort()
// let monthData = data.map(r => Object.keys(r)[0])
// console.log(monthData, 'monthData')
let json = {}
sortedKeys.forEach(e => {
json[e] = data[e]
})
// let yAxisData = sortedKeys.map(r => this.$moment(r).format('M') + '月')
// ,
// let arr = []
// for(let k in json){
// arr.push({
// {
// value: 12, label: { position: 'right' },
// itemStyle: {
// color: "#63D5FF"
// }
// }
// })
// }
this.echartsInit(yAxisData)
})
},
echartsInit(yAxisData) {
2 years ago
const chartDom = document.getElementById('mainRingPercent');
const myChart = this.$echarts.init(chartDom);
const option = {
// title: {
// text: 'Bar Chart with Negative Value'
// },
// tooltip: {
// trigger: 'axis',
// axisPointer: {
// type: 'shadow'
// }
// },
grid: {
top: "10%",
left: "10",
right: "20",
bottom: "0",
containLabel: true,
},
xAxis: {
type: 'value',
// position: 'top',
axisLabel: { formatter: '{value}%' },
color: "#fff",
splitLine: {
lineStyle: {
type: 'solid',
color: "#9fabc1",
}
}
},
yAxis: {
type: 'category',
axisLine: { show: false },
axisLabel: { show: false },
axisTick: { show: false },
splitLine: { show: false },
2 years ago
data: yAxisData
2 years ago
},
series: [
{
name: 'Cost',
type: 'bar',
stack: 'Total',
label: {
show: true,
formatter: '{b}',
color: "#fff"
},
data: [
{
value: 12, label: { position: 'right' },
itemStyle: {
color: "#63D5FF"
}
},
{
value: -12, label: { position: 'left' },
itemStyle: {
color: "#1BE9BB"
}
},
{
value: 24, label: { position: 'right' },
itemStyle: {
color: "#63D5FF"
}
},
{
value: -24, label: { position: 'left' },
itemStyle: {
color: "#1BE9BB"
}
},
{
value: -17, label: { position: 'left' },
itemStyle: {
color: "#1BE9BB"
}
},
{
value: 50, label: { position: 'right' },
itemStyle: {
color: "#63D5FF"
}
},
]
}
]
};
myChart.setOption(option);
}
}
};
</script>
<style lang="scss" scoped>
.box {
width: 4.6rem;
height: 2.55rem;
border-radius: 4px;
box-sizing: border-box;
background: url("../../../../public/img/energySourcesProvince/ringPercent.png");
background-size: 100% 100%;
padding: 0.54rem 0.22rem 0 0.22rem;
position: absolute;
bottom: 0.24rem;
left: 4.94rem;
2 years ago
z-index: 29;
2 years ago
.tit-r {
font-size: 0.14rem;
color: rgba($color: #fff, $alpha: 0.4);
margin-top: 0.04rem;
}
#mainRingPercent {
height: 1.8rem;
}
}</style>