<template> <div class="chart-container"> <div class="chart-header"> <!--标题 --> <span class="title">用户分布统计</span> </div> <div class="chart-content" :style="{ height: height, width: width }"> <!-- echarts内容 --> <baseRadarChartVue :seriesData="seriesData" :indicator="indicator" /> </div> </div> </template> <script> import baseRadarChartVue from "../../../components/echart/radarChart/baseRadarChart.vue"; import { getUserCount } from "@/api/cockpit/cockpit"; export default { name: "layoutChartSelect", components: { baseRadarChartVue, }, props: { name: { type: String, default: "", }, width: { type: String, default: "500px", }, height: { type: String, default: "300px", }, }, data() { return { seriesData: [], indicator: [], legend: [], }; }, mounted() { this.fetchData(); }, methods: { fetchData() { getUserCount().then((res) => { // {roleName: '集团用户', userCount: 5} let data = []; let legend = []; for (var i = 0; i < res.data.length; i++) { data.push(res.data[i].userCount); legend.push(res.data[i].roleName); } this.seriesData = [ { type: "radar", data: [ { value: data, name: "注册用户数", }, ], }, ]; // this.legend = legend let max = 0; for (var i = 0; i < res.data.length; i++) { if(res.data[i].userCount > max){ max = res.data[i].userCount } } this.indicator = res.data.map((item) => { return { name: item.roleName, max: max, }; }); }); }, }, }; </script> <style lang="scss" scoped> .chart-container { .chart-header { width: 600px; align-items: center; display: flex; justify-content: space-between; } .chart-content { // width: 600px; // height: 400px; } } </style>