123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <div class="data_body">
- <!-- v-if="this.ooption.xdata.length" -->
- <div style="width: 100%; height: 100%">
- <div id="charts_canvas" class="echart" style="width: 100%; height: 100%; "></div>
- </div>
- <!-- <div style="width: 100%; height: 100%;display: flex;align-items: center;justify-content: center;"
- v-show="!this.ooption.xdata.length">暂无数据</div> -->
- </div>
- </template>
-
- <script>
- export default {
- props: {
- evCourseArray: {
- type: Array,
- default: []
- },
- eva: {
- type: String,
- default: ''
- }
- },
- data() {
- return {
- chartObj: null,
- ooption: {
- xdata: [],
- sdata: [],
- },
- option: {
- tooltip: {},
- radar: {
- axisName: {
- color: "#000"
- },
- // shape: 'circle',
- indicator: [
- // { name: '目标一', max: 5 },
- // { name: '目标二', max: 5 },
- // { name: '目标三', max: 5 },
- // { name: '目标四', max: 5 },
- // { name: '目标五', max: 5 }
- ]
- },
- series: [
- {
- name: '学生综合评价',
- type: 'radar',
- data: [
- {
- areaStyle: {
- opacity: 0.2,
- color: '#0061FF'
- },
- itemStyle: {
- color: '#0061FF',
- lineStyle: {
- color: '#0061FF'
- }
- },
- // 5, 4, 3, 5, 5, 2
- value: [],
- name: ''
- }
- ]
- }
- ]
- },
- };
- },
- methods: {
- setChart(option) {
- // 雷达图显示的标签
- let newPromise = new Promise((resolve) => {
- resolve();
- });
- //然后异步执行echarts的初始化函数
- newPromise.then(() => {
- const chartObj = this.$echarts.init(
- //劳动课程
- this.$el.querySelector("#charts_canvas")
- );
- // this.option.radar.indicator = option.xdata;
- // this.option.series[0].data[0].value = option.sdata;
- this.option.radar.indicator = [
- { name: '成茁小先生', max: 5 },
- { name: '成行小先生', max: 5 },
- { name: '成智小先生', max: 5 },
- { name: '成德小先生', max: 5 },
- { name: '成彩小先生', max: 5 }
- ]
- this.option.series[0].data[0].value = [1,1,3,5,5];
- // 初始化雷达图
- this.chartObj = chartObj;
- this.chartObj.setOption(this.option);
- });
- },
- setArray(array) {
- this.setChart(array);
- return
- this.ooption = {
- xdata: [],
- sdata: [],
- }
- for (var i = 0; i < array.length; i++) {
- if (array[i].evid == this.eva) {
- this.ooption.xdata = array[i].indicator
- this.ooption.sdata = array[i].value
- break;
- }
- }
- setTimeout(() => {
- // if (!this.chartObj) {
- this.setChart(this.ooption);
- // } else {
- // this.option.radar.indicator = this.ooption.xdata;
- // this.option.series[0].data[0].value = this.ooption.sdata;
- // this.chartObj.setOption(this.option);
- // }
- }, 100);
- this.$forceUpdate();
- },
- },
- watch: {
- evCourseArray: {
- immediate: true,
- deep: true,
- handler(newValue, oldValue) {
- this.setArray(newValue)
- this.$forceUpdate();
- },
- },
- eva: {
- immediate: true,
- deep: true,
- handler(newValue, oldValue) {
- this.setArray(this.evCourseArray)
- this.$forceUpdate();
- },
- },
- },
- mounted() {
- this.setArray(this.evCourseArray)
- // this.setChart(this.ooption);
- 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: 95%;
- background: #fff;
- }
- </style>
-
|