Blame view
src/components/widgets/chart/BoxChart.vue
3.28 KB
ade01719f
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
<template> <v-card :color="cardColor" :dark="computeCardDark"> <v-card-title> <div class="layout row ma-0"> <div class="subheading">{{title}}</div> <v-spacer></v-spacer> <div class="caption"> <v-icon>trending_up</v-icon> {{subTitle}}</div> </div> </v-card-title> <v-card-media class="white--text"> <e-chart :path-option="computeChartOption" height="308px" width="100%" > </e-chart> </v-card-media> </v-card> </template> <script> import EChart from '@/components/chart/echart'; import Material from 'vuetify/es5/util/colors'; export default { components: { EChart }, props: { title: String, gradient: { type: Boolean, default: false, }, subTitle: String, icon: String, cardColor: { type: String, default: 'white' }, iconColor: { type: String, default: 'success', }, type: String, chartColor: Array, data: Array, }, data () { return { defaultOption: [ ['dataset.source', this.data], ['xAxis.show', false], ['yAxis.show', false], ['grid.top', '15%'], ['grid.left', '0'], ['grid.bottom', '0'], ['grid.right', '0'], ['color', this.chartColor], ] }; }, computed: { computeCardDark () { return this.cardColor !== 'white'; }, computeChartOption () { switch (this.type) { case 'bar': this.defaultOption.push(['series[0].type', 'bar']); this.defaultOption.push(['series[0].barWidth', '50%']); // add shadow series // this.defaultOption.push(['series[1].type', 'bar']); break; case 'stack-bar': // set stacked bar // this.defaultOption.push(['series[0].data', StackBarData]); this.defaultOption.push(['series[0].type', 'bar']); this.defaultOption.push(['series[0].itemStyle.normar.color', 'rgba(0,0,0,0.05)']); this.defaultOption.push(['series[0].barGap', '-100%']); // set main series // this.defaultOption.push(['series[1].data', StackData]); this.defaultOption.push(['series[1].type', 'bar']); break; case 'area': this.defaultOption.push(['series[0].type', 'line']); this.defaultOption.push(['series[0].smooth', true]); this.defaultOption.push(['xAxis.boundaryGap', false]); this.defaultOption.push(['series[0].areaStyle', {}]); if (this.gradient) { this.defaultOption.push(['series[0].areaStyle', { normal: { color: new window.echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: this.chartColor[0], }, { offset: 1, color: this.chartColor[1], } ]) } }]); } break; default: // line this.defaultOption.push(['series[0].smooth', true]); this.defaultOption.push(['xAxis.boundaryGap', false]); break; } return this.defaultOption; } } }; </script> <style> </style> |