| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <template>
- <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
- </template>
- <script>
- import apiOperationAnalysis from "@/api/operation/apiOperationAnalysis";
- export default {
- data() {
- return {
- option: {
- legend: {
- top: "10",
- icon: 'circle',
- textStyle: { fontSize: 14, color: "#000000" },
- itemGap: 20,
- itemWidth: 20,
- data: ["年度环比节能(元)"],
- },
- radar: {
- name: {
- textStyle: {
- color: '#333333',
- fontSize: 14,
- },
- },
- indicator: [],
- center: ["50%", "50%"],
- radius: "60%",
- },
- tooltip: {
- show: true,
- trigger: 'item',
- },
- series: [
- {
- name: "年度环比节能(元)",
- type: "radar",
- color: "#3AA7E6",
- label: {
- show: true,
- },
- areaStyle: {
- color: "rgba(170, 217, 255, 0.35)",
- },
- data: [
- {
- value: [],
- },
- ],
- },
- ],
- },
- }
- },
- props: {
- height: Number,
- queryData: Object
- },
- mounted() {
- this.$nextTick(()=>{
- this.init()
- })
- },
- methods: {
- init() {
- let chart = this.$echarts.init(this.$refs.myChart);
- this.chart = chart;
- this.getData()
- },
- getData() {
- return apiOperationAnalysis.getEnergyAnalysisTotal(this.queryData).then(res=>{
- let values = []
- let indicatorList = [];
- let max = 0;
- if (res) {
- res.forEach((item, index) => {
- values.push(item.value)
- max = Math.max(max, item.value);
- indicatorList.push({
- name: item.name,
- value: item.value,
- });
- });
- }
- max = Math.max(max*2, 200);
- console.log(max)
- indicatorList.forEach(item => {
- item.max = max;
- });
- this.option.radar.indicator = indicatorList;
- this.option.series[0].data[0].value = values;
- this.chart.setOption(this.option);
- })
- }
- }
- }
- </script>
- <style lang="less" scoped>
- </style>
|