1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <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 {
- data() {
- return {
- chartObj: null,
- ooption: {
- data: [],
- },
- option: {
- tooltip: {
- trigger: "item",
- },
- series: [
- {
- type: "pie",
- radius: '50%',
- avoidLabelOverlap: true,
- emphasis: {
- label: {
- show: true,
- fontSize: 16,
- fontWeight: "bold",
- },
- },
- data: [
- { value: 100, name: "一年级" },
- { value: 150, name: "二年级" },
- { value: 223, name: "三年级" },
- { value: 216, name: "四年级" },
- { value: 130, name: "五年级" },
- { value: 208, name: "六年级" },
- ],
- },
- ],
- },
- };
- },
- methods: {
- setChart() {
- // 雷达图显示的标签
- let newPromise = new Promise((resolve) => {
- resolve();
- });
- //然后异步执行echarts的初始化函数
- newPromise.then(() => {
- const chartObj = this.$echarts.init(
- //劳动课程
- this.$el.querySelector("#charts_canvas")
- );
- // 初始化雷达图
- this.chartObj = chartObj;
- this.chartObj.setOption(this.option);
- });
- },
- },
- watch: {
- },
- mounted() {
- this.setChart();
- 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>
|