12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <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: {
- xdata: [],
- type: [],
- },
- option: {
- tooltip: {
- trigger: "item",
- },
- xAxis: {
- type: "category",
- data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
- },
- yAxis: {
- type: "value",
- },
- series: [
- {
- data: [120, 200, 150, 80, 70, 110, 130],
- type: "bar",
- },
- ],
- },
- };
- },
- 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>
|