|
@@ -2,7 +2,10 @@
|
|
|
<section>
|
|
|
<div class="control">
|
|
|
<el-row type="flex" align="middle">
|
|
|
- <el-col :span="4" :offset="20" class="col-flex-end">
|
|
|
+ <el-col :span="6">
|
|
|
+ <div class="total">需求总数 <span>{{ total }}</span> 个</div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="10" :offset="8" class="col-flex-end">
|
|
|
<div class="bar-pie" :class="[barOrPie==='bar'?'active':'']" @click="changeBarOrPie('bar')">柱状图</div>
|
|
|
<div class="bar-pie" :class="[barOrPie==='pie'?'active':'']" @click="changeBarOrPie('pie')">饼图</div>
|
|
|
</el-col>
|
|
@@ -37,12 +40,16 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
echartsOption: null,
|
|
|
- barOrPie: 'bar' // 柱状图or饼图
|
|
|
+ barOrPie: 'bar', // 柱状图or饼图
|
|
|
+ total: 0
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
chartData: {
|
|
|
handler(newV) {
|
|
|
+ if (newV) {
|
|
|
+ this.total = this.chartData.yaxis[0].data.reduce((prev, curr) => prev + curr)
|
|
|
+ }
|
|
|
this.changeBarOrPie(this.barOrPie)
|
|
|
},
|
|
|
deep: true,
|
|
@@ -64,7 +71,7 @@ export default {
|
|
|
color: ['#3AA1FF'],
|
|
|
tooltip: { trigger: 'axis', axisPointer: { type: 'line' }}, // 默认为直线,可选为:'line' | 'shadow'
|
|
|
grid: { left: '0', right: '0', top: '10%', bottom: '0', containLabel: true },
|
|
|
- xAxis: [{ type: 'category', data: this.chartData.xaxis, axisLabel: { interval: 0, rotate: 0 }, axisTick: { alignWithLabel: true }}],
|
|
|
+ xAxis: [{ type: 'category', data: this.chartData.xaxis, axisLabel: { interval: 0, rotate: 15 }, axisTick: { alignWithLabel: true }}],
|
|
|
yAxis: [{ type: 'value', axisLine: { show: false }, splitLine: { lineStyle: { type: 'dashed' }}}],
|
|
|
series: [{
|
|
|
name: '数量', type: 'bar', barWidth: '20px', data: this.chartData.yaxis[0] && this.chartData.yaxis[0].data || [],
|
|
@@ -105,9 +112,14 @@ export default {
|
|
|
margin: auto;
|
|
|
margin-top: 20px;
|
|
|
}
|
|
|
+.col-flex-end {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+}
|
|
|
.bar-pie {
|
|
|
font-size: 14px;
|
|
|
width: 40%;
|
|
|
+ max-width: 100px;
|
|
|
display: inline-block;
|
|
|
padding: 6px 10px;
|
|
|
margin-left: 5%;
|
|
@@ -121,4 +133,10 @@ export default {
|
|
|
color: #ffffff;
|
|
|
background: #50A6FF;
|
|
|
}
|
|
|
+.total {
|
|
|
+ color: #333333;
|
|
|
+ span {
|
|
|
+ color: #61AFFF;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|