Commit 78a3ba7b7c3f5de7e6147a3f49aae08b0f7149c2
1 parent
a390d377
泊位
Showing
6 changed files
with
178 additions
and
9 deletions
src/components/halfPieChart.vue
0 → 100644
1 | +<template> | |
2 | + <div :class="className" :style="{height:height,width:width}"></div> | |
3 | +</template> | |
4 | + | |
5 | +<script> | |
6 | +import echarts from 'echarts' | |
7 | + | |
8 | +require('echarts/theme/macarons') // echarts theme | |
9 | +import {debounce} from '../utils/debounce' | |
10 | + | |
11 | +export default { | |
12 | + name: 'halfPieChart', | |
13 | + props: { | |
14 | + className: { | |
15 | + type: String, | |
16 | + default: 'chart' | |
17 | + }, | |
18 | + width: { | |
19 | + type: String, | |
20 | + default: '100%' | |
21 | + }, | |
22 | + height: { | |
23 | + type: String, | |
24 | + default: '135px' | |
25 | + }, | |
26 | + autoResize: { | |
27 | + type: Boolean, | |
28 | + default: true | |
29 | + }, | |
30 | + chartData: { | |
31 | + type: Object, | |
32 | + required: true | |
33 | + } | |
34 | + }, | |
35 | + data() { | |
36 | + return { | |
37 | + chart: null, | |
38 | + sidebarElm: null | |
39 | + } | |
40 | + }, | |
41 | + watch: { | |
42 | + chartData: { | |
43 | + deep: true, | |
44 | + } | |
45 | + }, | |
46 | + mounted() { | |
47 | + this.initChart() | |
48 | + if (this.autoResize) { | |
49 | + this.__resizeHandler = debounce(() => { | |
50 | + if (this.chart) { | |
51 | + this.chart.resize() | |
52 | + } | |
53 | + }, 100) | |
54 | + window.addEventListener('resize', this.__resizeHandler) | |
55 | + } | |
56 | + }, | |
57 | + beforeDestroy() { | |
58 | + if (!this.chart) { | |
59 | + return | |
60 | + } | |
61 | + if (this.autoResize) { | |
62 | + window.removeEventListener('resize', this.__resizeHandler) | |
63 | + } | |
64 | + | |
65 | + this.chart.dispose() | |
66 | + this.chart = null | |
67 | + }, | |
68 | + methods: { | |
69 | + setOptions({xData, yData} = {}) { | |
70 | + this.chart.setOption({ | |
71 | + tooltip: { | |
72 | + trigger: 'item', | |
73 | + formatter: "{b} : {c} ({d}%)" | |
74 | + }, | |
75 | + series: [ | |
76 | + | |
77 | + { | |
78 | + name: '半径模式', | |
79 | + type: 'pie', | |
80 | + radius: ['75%', '90%'], | |
81 | + center: ['50%', '50%'], | |
82 | + label: { | |
83 | + show: false | |
84 | + }, | |
85 | + lableLine: { | |
86 | + show: false | |
87 | + }, | |
88 | + data: [ | |
89 | + { | |
90 | + value: 35, | |
91 | + name: '诱导屏', | |
92 | + itemStyle: { | |
93 | + normal: { | |
94 | + color: { | |
95 | + colorStops: [{ | |
96 | + offset: 0, | |
97 | + color: '#FFBA00' // 0% 处的颜色 | |
98 | + }, { | |
99 | + offset: 1, | |
100 | + color: '#FF8100' // 100% 处的颜色 | |
101 | + }] | |
102 | + }, | |
103 | + } | |
104 | + } | |
105 | + }, | |
106 | + { | |
107 | + value: 55, | |
108 | + name: '道闸', | |
109 | + itemStyle: { | |
110 | + normal: { | |
111 | + color: { | |
112 | + colorStops: [{ | |
113 | + offset: 0, | |
114 | + color: '#00CAFE' // 0% 处的颜色 | |
115 | + }, { | |
116 | + offset: 1, | |
117 | + color: '#2772F4' // 100% 处的颜色 | |
118 | + }] | |
119 | + }, | |
120 | + } | |
121 | + } | |
122 | + }, | |
123 | + | |
124 | + ], | |
125 | + animationType: 'scale', | |
126 | + animationEasing: 'elasticOut', | |
127 | + animationDelay: function(idx) { | |
128 | + return Math.random() * 200; | |
129 | + } | |
130 | + } | |
131 | + | |
132 | + ] | |
133 | + }) | |
134 | + }, | |
135 | + initChart() { | |
136 | + this.chart = echarts.init(this.$el, 'macarons') | |
137 | + this.setOptions(this.chartData) | |
138 | + } | |
139 | + } | |
140 | +} | |
141 | +</script> | ... | ... |
src/styles/reset.css
src/views/berthsection.vue
... | ... | @@ -3,12 +3,18 @@ |
3 | 3 | <titlesection title="泊位"></titlesection> |
4 | 4 | <totalsection :totalNum="totalVal"></totalsection> |
5 | 5 | <ul class="flexfm berth-wrap"> |
6 | - <li></li> | |
6 | + <li class="pos-rel"> | |
7 | + <halfPieChart></halfPieChart> | |
8 | + <div class="pos-abs halfPieText"> | |
9 | + <p>78%</p> | |
10 | + <p>占有</p> | |
11 | + </div> | |
12 | + </li> | |
7 | 13 | <li> |
8 | - <div> | |
14 | + <div class="berth-main"> | |
9 | 15 | <p><span class="free">{{ free|formatNum }}</span> <span>空余</span></p> |
10 | 16 | </div> |
11 | - <div> | |
17 | + <div class="berth-main"> | |
12 | 18 | <p><span class="nofree">{{ nofree|formatNum }}</span> <span>占有</span></p> |
13 | 19 | </div> |
14 | 20 | |
... | ... | @@ -20,14 +26,15 @@ |
20 | 26 | <script> |
21 | 27 | import titlesection from '../components/titlesection' |
22 | 28 | import totalsection from '../components/total' |
23 | -import { formatNum } from '../filters/filters' | |
29 | +import halfPieChart from '../components/halfPieChart' | |
24 | 30 | import {fetchList} from '../api/api' |
25 | 31 | |
26 | 32 | export default { |
27 | 33 | name: 'berthsection', |
28 | 34 | components: { |
29 | 35 | titlesection, |
30 | - totalsection | |
36 | + totalsection, | |
37 | + halfPieChart | |
31 | 38 | }, |
32 | 39 | data() { |
33 | 40 | return { |
... | ... | @@ -55,7 +62,24 @@ export default { |
55 | 62 | display: flex; |
56 | 63 | li{ |
57 | 64 | flex: 1; |
58 | - div{ | |
65 | + .halfPieText{ | |
66 | + width: 100%; | |
67 | + text-align: center; | |
68 | + top:50%; | |
69 | + transform:translateY(-50%) ; | |
70 | + p{ | |
71 | + &:nth-of-type(1){ | |
72 | + @include fonttextStyle(24px); | |
73 | + background-image: $fontOrange; | |
74 | + } | |
75 | + &:nth-of-type(2){ | |
76 | + padding-top: 5px; | |
77 | + font-size: 12px; | |
78 | + color: #fff; | |
79 | + } | |
80 | + } | |
81 | + } | |
82 | + .berth-main{ | |
59 | 83 | height: 50%; |
60 | 84 | display: flex; |
61 | 85 | align-items:center; | ... | ... |
src/views/dicisection.vue
src/views/sfysection.vue
src/views/youdaopingsection.vue