123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <template>
- <div class="data_body">
- <div style="width: 100%; height: 100%">
- <div id="charts_canvas" class="echart" style="width: 100%; height: 100%"></div>
- </div>
- </div>
- </template>
-
- <script>
- export default {
- props: {
- loginArray: {
- type: Array
- },
- },
- data() {
- return {
- chartObj: null,
- ooption: {
- xdata: [],
- type: [],
- },
- option: {
- tooltip: {},
- radar: {
- indicator: [
- { name: '煜煜星光', max: 100 },
- { name: '个人写真', max: 100 },
- { name: '明灯导航', max: 100 },
- { name: '教师耕耘', max: 100 },
- { name: '其他', max: 100 }
- ],
- axisName: {
- color: '#000'
- },
- axisName: {
- color: '#000',
- fontSize: 12
- },
- radius: ['0%', '70%'],
- center: ['50%', '55%'],
- nameGap: 5,
- },
- series: [
- {
- name: '综合平均分',
- type: 'radar',
- data: [
- {
- value: [86, 76, 35, 85, 80, 86],
- itemStyle: {
- color: '#F5B763' // 设置数据点的颜色
- },
- lineStyle: {
- normal: {
- color: '#F5B763' //
- }
- },
- areaStyle: {
- normal: {
- color: '#F5B76333' //
- }
- }
- }
- ]
- }
- ]
- },
- };
- },
- methods: {
- setChart(array) {
- // 雷达图显示的标签
- let newPromise = new Promise((resolve) => {
- resolve();
- });
- //然后异步执行echarts的初始化函数
- newPromise.then(() => {
- const chartObj = this.$echarts.init(
- this.$el.querySelector("#charts_canvas")
- );
- // this.option.series[0].data = array;
- // 初始化雷达图
- this.chartObj = chartObj;
- this.chartObj.setOption(this.option);
- });
- },
- setJson(array) {
- this.ooption = {
- xdata: [],
- sdata: [],
- max: 0
- }
- if (!this.chartObj) {
- this.setChart(array);
- } else {
- this.option.series[0].data = array;
- this.chartObj.setOption(this.option);
- }
- }
- },
- watch: {
- loginArray: {
- immediate: true,
- deep: true,
- handler(newValue, oldValue) {
- this.setJson(newValue)
- this.$forceUpdate();
- },
- },
- },
- mounted() {
- this.setJson(this.loginArray)
- var _this = this;
- window.addEventListener("resize", () => {
- if (_this.chartObj) {
- _this.chartObj.resize();
- }
- });
- },
- };
- </script>
-
- <style scoped>
- .data_body {
- height: 100%;
- /* display: flex; */
- position: relative;
- border-radius: 5px;
- /* border: 1px solid #eee; */
- margin: 0 auto;
- box-sizing: border-box;
- padding: 0;
- width: 100%;
- /* background: #fff; */
- }
- </style>
|