| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <template>
- <view>
- <div class="chart1" ref="chart1"></div>
- </view>
- </template>
-
- <script>
- import echarts from "echarts";
- export default {
- props: {
- // beforeFan:{
- // type: Array,
- // // 定义是否必须传
- // required: false,
- // // 定义默认值
- // default: []
- // },
- },
- mounted() {
- this.getEchartData1()
- },
- data() {
- return {
- }
- },
-
- methods: {
- // 折线图
- getEchartData1() {
- const chart1 = this.$refs.chart1;
- var option = null;
- const myChart = this.$echarts.init(chart1);
- option = {
- tooltip: {
- trigger: 'item'
- },
- color:['rgb(0, 157, 255)','rgb(34, 228, 255)','rgb(59, 255, 208)','rgb(4, 227, 138)',
- 'rgb(157, 255, 134)','rgb(254, 229, 136)','rgb(254, 168, 68)','rgb(254, 112, 68)'],
- legend: {
- top: 'bottom',
- bottom:-10
- },
- series: [
- {
- name: 'Access From',
- type: 'pie',
- radius: '50%',
- center: ['50%', '40%'],
- data: [
- { value: 48, name: '待付款' },
- { value: 135, name: '已支付' },
- { value: 580, name: '已取消' },
- { value: 484, name: '已退单' },
- { value: 300, name: '待入住' },
- { value: 580, name: '已入住' },
- { value: 484, name: '已退款' },
- { value: 300, name: '已消费' }
- ],
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- };
- myChart.setOption(option);
- window.addEventListener("resize", function () {
- myChart.resize();
- });
- this.$on("hook:destroyed", () => {
- window.removeEventListener("resize", function () {
- chart1.resize();
- });
- });
- return option;
- },
-
- },
-
- }
- </script>
- <style>
- .chart1 {
- width: 100%;
- height: 100%;
- display: block;
- }
- </style>
|