Commit 9092f766c2fd61117a609a209962c6b739b3287b
1 parent
07fc88b5
pda
Showing
2 changed files
with
138 additions
and
25 deletions
src/components/barChart.vue
| @@ -4,8 +4,6 @@ | @@ -4,8 +4,6 @@ | ||
| 4 | 4 | ||
| 5 | <script> | 5 | <script> |
| 6 | import echarts from 'echarts' | 6 | import echarts from 'echarts' |
| 7 | - | ||
| 8 | -require('echarts/theme/macarons') // echarts theme | ||
| 9 | import {debounce} from '../utils/debounce' | 7 | import {debounce} from '../utils/debounce' |
| 10 | 8 | ||
| 11 | export default { | 9 | export default { |
| @@ -21,7 +19,7 @@ export default { | @@ -21,7 +19,7 @@ export default { | ||
| 21 | }, | 19 | }, |
| 22 | height: { | 20 | height: { |
| 23 | type: String, | 21 | type: String, |
| 24 | - default: '350px' | 22 | + default: '100%' |
| 25 | }, | 23 | }, |
| 26 | autoResize: { | 24 | autoResize: { |
| 27 | type: Boolean, | 25 | type: Boolean, |
| @@ -69,42 +67,157 @@ export default { | @@ -69,42 +67,157 @@ export default { | ||
| 69 | setOptions({xData, yData} = {}) { | 67 | setOptions({xData, yData} = {}) { |
| 70 | this.chart.setOption({ | 68 | this.chart.setOption({ |
| 71 | xAxis: { | 69 | xAxis: { |
| 72 | - data: xData, | ||
| 73 | boundaryGap: true, | 70 | boundaryGap: true, |
| 71 | + axisLabel : { | ||
| 72 | + formatter: '{value}', | ||
| 73 | + textStyle: { | ||
| 74 | + color: '#59AAF7' | ||
| 75 | + } | ||
| 76 | + }, | ||
| 77 | + axisLine:{ | ||
| 78 | + lineStyle:{ | ||
| 79 | + color:'rgba(89,170,247,.3)' | ||
| 80 | + } | ||
| 81 | + }, | ||
| 74 | axisTick: { | 82 | axisTick: { |
| 75 | show: false | 83 | show: false |
| 76 | - } | 84 | + }, |
| 85 | + splitLine: { | ||
| 86 | + show: false | ||
| 87 | + }, | ||
| 88 | + data: [ | ||
| 89 | + { | ||
| 90 | + value: xData[0], | ||
| 91 | + textStyle: { | ||
| 92 | + fontSize: 12, | ||
| 93 | + color: '#59AAF7' | ||
| 94 | + } | ||
| 95 | + }, | ||
| 96 | + { | ||
| 97 | + value: xData[1], | ||
| 98 | + textStyle: { | ||
| 99 | + fontSize: 12, | ||
| 100 | + color: '#FFB900' | ||
| 101 | + } | ||
| 102 | + }, | ||
| 103 | + { | ||
| 104 | + value: xData[2], | ||
| 105 | + textStyle: { | ||
| 106 | + fontSize: 12, | ||
| 107 | + color: '#FD4B15' | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | + ] | ||
| 77 | }, | 111 | }, |
| 78 | grid: { | 112 | grid: { |
| 79 | left: 10, | 113 | left: 10, |
| 80 | right: 10, | 114 | right: 10, |
| 81 | - bottom: 20, | ||
| 82 | - top: 30, | 115 | + bottom: 10, |
| 116 | + top: 10, | ||
| 83 | containLabel: true | 117 | containLabel: true |
| 84 | }, | 118 | }, |
| 85 | - tooltip: { | ||
| 86 | - trigger: 'axis', | ||
| 87 | - axisPointer: { | ||
| 88 | - type: 'cross' | ||
| 89 | - }, | ||
| 90 | - padding: [5, 10] | ||
| 91 | - }, | 119 | + // tooltip: { |
| 120 | + // | ||
| 121 | + // }, | ||
| 92 | yAxis: { | 122 | yAxis: { |
| 123 | + axisLabel : { | ||
| 124 | + formatter: '{value}', | ||
| 125 | + textStyle: { | ||
| 126 | + color: '#fff' | ||
| 127 | + } | ||
| 128 | + }, | ||
| 129 | + axisLine:{ | ||
| 130 | + lineStyle:{ | ||
| 131 | + color:'rgba(89,170,247,.3)' | ||
| 132 | + } | ||
| 133 | + }, | ||
| 93 | axisTick: { | 134 | axisTick: { |
| 94 | show: false | 135 | show: false |
| 95 | - } | ||
| 96 | - }, | ||
| 97 | - legend: { | ||
| 98 | - data: ['expected', 'actual'] | 136 | + }, |
| 137 | + splitLine: { | ||
| 138 | + show: false | ||
| 139 | + }, | ||
| 140 | + splitNumber:3 | ||
| 99 | }, | 141 | }, |
| 100 | series: [{ | 142 | series: [{ |
| 101 | - data: yData, | ||
| 102 | type: 'bar', | 143 | type: 'bar', |
| 144 | + barWidth:25, | ||
| 145 | + data: [ | ||
| 146 | + { | ||
| 147 | + name: xData[0], | ||
| 148 | + value: yData[0], | ||
| 149 | + label: { | ||
| 150 | + show: true, | ||
| 151 | + position: 'top', | ||
| 152 | + textStyle: { | ||
| 153 | + fontSize: 14, | ||
| 154 | + color: '#01AEFE' | ||
| 155 | + } | ||
| 156 | + }, | ||
| 157 | + itemStyle: { | ||
| 158 | + normal: { | ||
| 159 | + color: new echarts.graphic.LinearGradient( | ||
| 160 | + 0, 0, 0, 1, | ||
| 161 | + [ | ||
| 162 | + { offset: 0, color: '#635BE6' }, | ||
| 163 | + { offset: 1, color: '#6DB7EF' } | ||
| 164 | + ] | ||
| 165 | + ) | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + }, | ||
| 169 | + { | ||
| 170 | + name: xData[1], | ||
| 171 | + value: yData[1], | ||
| 172 | + label: { | ||
| 173 | + show: true, | ||
| 174 | + position: 'top', | ||
| 175 | + textStyle: { | ||
| 176 | + fontSize: 14, | ||
| 177 | + color: '#FFB700' | ||
| 178 | + } | ||
| 179 | + }, | ||
| 180 | + itemStyle: { | ||
| 181 | + normal: { | ||
| 182 | + color: new echarts.graphic.LinearGradient( | ||
| 183 | + 0, 0, 0, 1, | ||
| 184 | + [ | ||
| 185 | + { offset: 0, color: '#F9B205' }, | ||
| 186 | + { offset: 1, color: '#F2E34A' } | ||
| 187 | + ] | ||
| 188 | + ) | ||
| 189 | + } | ||
| 190 | + } | ||
| 191 | + }, | ||
| 192 | + { | ||
| 193 | + name: xData[2], | ||
| 194 | + value: yData[2], | ||
| 195 | + label: { | ||
| 196 | + show: true, | ||
| 197 | + position: 'top', | ||
| 198 | + textStyle: { | ||
| 199 | + fontSize: 14, | ||
| 200 | + color: '#FD4B15' | ||
| 201 | + } | ||
| 202 | + }, | ||
| 203 | + itemStyle: { | ||
| 204 | + normal: { | ||
| 205 | + color: new echarts.graphic.LinearGradient( | ||
| 206 | + 0, 0, 0, 1, | ||
| 207 | + [ | ||
| 208 | + { offset: 0, color: '#F36C00' }, | ||
| 209 | + { offset: 1, color: '#F4C5A8' } | ||
| 210 | + ] | ||
| 211 | + ) | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + ] | ||
| 103 | }] | 216 | }] |
| 104 | }) | 217 | }) |
| 105 | }, | 218 | }, |
| 106 | initChart() { | 219 | initChart() { |
| 107 | - this.chart = echarts.init(this.$el, 'macarons') | 220 | + this.chart = echarts.init(this.$el) |
| 108 | this.setOptions(this.chartData) | 221 | this.setOptions(this.chartData) |
| 109 | } | 222 | } |
| 110 | } | 223 | } |
src/views/pdasection.vue
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <div> | 2 | <div> |
| 3 | <titlesection title="PDA"></titlesection> | 3 | <titlesection title="PDA"></titlesection> |
| 4 | <totalsection :totalNum="totalVal"></totalsection> | 4 | <totalsection :totalNum="totalVal"></totalsection> |
| 5 | - <bar-chart :chart-data="lineChartData" class="flexfm"/> | 5 | + <bar-chart :chart-data="barChartData" class="flexfm"/> |
| 6 | </div> | 6 | </div> |
| 7 | </template> | 7 | </template> |
| 8 | 8 | ||
| @@ -12,9 +12,9 @@ import totalsection from '../components/total' | @@ -12,9 +12,9 @@ import totalsection from '../components/total' | ||
| 12 | import barChart from '../components/barChart' | 12 | import barChart from '../components/barChart' |
| 13 | import {fetchList} from '../api/api' | 13 | import {fetchList} from '../api/api' |
| 14 | 14 | ||
| 15 | -const lineChartData = { | ||
| 16 | - newVisitis: { | ||
| 17 | - yData: [100, 120, 161], | 15 | +const barChartData = { |
| 16 | + data: { | ||
| 17 | + yData: [100, 80, 21], | ||
| 18 | xData: ['正常', '异常', '故障'] | 18 | xData: ['正常', '异常', '故障'] |
| 19 | } | 19 | } |
| 20 | } | 20 | } |
| @@ -29,7 +29,7 @@ export default { | @@ -29,7 +29,7 @@ export default { | ||
| 29 | data() { | 29 | data() { |
| 30 | return { | 30 | return { |
| 31 | totalVal: '213734', | 31 | totalVal: '213734', |
| 32 | - lineChartData: lineChartData.newVisitis | 32 | + barChartData: barChartData.data |
| 33 | } | 33 | } |
| 34 | }, | 34 | }, |
| 35 | created() { | 35 | created() { |