12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <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: ["40%", "70%"],
- avoidLabelOverlap: false,
- itemStyle: {
- borderRadius: 10,
- },
- labelLine: {
- show: true,
- },
- 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>
|