123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <!-- 饼图统计 -->
- <template>
- <div>
- <boxTop :title="title" />
- <div class="cakeBox flex">
- <div class="chartsdom" id="cake"></div>
- <div class="panel">
- <div class="panelitem flex space_around">
- <div v-if="data.年移栽数量">
- <div class="number">{{ data.年移栽数量 }}</div>
- <div class="text">
- <img class="img1" src="../../assets/img/rectangle.png" alt="" />
- 年移栽数量
- </div>
- </div>
- <div v-if="data.年移栽面积">
- <div class="number">{{ data.年移栽面积 }}</div>
- <div class="text">
- <img
- class="img1"
- src="../../assets/img/rectangle.png"
- alt=""
- />年移栽面积
- </div>
- </div>
- </div>
- <div class="panelitem">
- <div v-if="data.移栽区域数" class="flex space_between secondItem">
- <img class="img" src="../../assets/img/tree.png" alt="" />
- <div>移栽区域数</div>
- <div>{{ data.移栽区域数 }}</div>
- </div>
- <div v-if="data.烟农数量" class="flex space_between secondItem">
- <img class="img" src="../../assets/img/head.png" alt="" />
- <div>烟农数量</div>
- <div>{{ data.烟农数量 }}</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import boxTop from '@/components/boxTop/index.vue'
- export default {
- data() {
- return {
- option: null,
- information: {},
- }
- },
- components: {
- boxTop,
- },
- props: {
- data: {
- type: Object,
- },
- title: {
- type: String,
- default: ``,
- },
- titleEn: {
- type: String,
- default: `Tongren Tobacco Planting Digital Management Platform`,
- },
- },
- async mounted() {
- this.getEchart()
- },
- watch: {
- data() {
- this.getEchart()
- },
- },
- methods: {
- getEchart() {
- let myChart = echarts.init(document.getElementById(`cake`))
- const title = `目标完成率`
- const value = this.data.目标完成率
- const splitLineLength = `19%`
- const splitLineDistance = -5
- const splitLineWidth = 2
- const int = value.toFixed(1).split(`.`)[0]
- const float = value.toFixed(1).split(`.`)[1]
- this.option = {
- title: {
- text: `{a|` + int + `}{b|.` + float + `%}\n{c|` + title + `}`,
- x: `center`,
- y: `center`,
- textStyle: {
- rich: {
- a: {
- fontSize: 36,
- color: `#fff`,
- },
- b: {
- fontSize: 20,
- color: `#96A2BC`,
- padding: [2, 0, 0, 0],
- },
- c: {
- fontSize: 16,
- color: `#96A2BC`,
- padding: [2, 0, 0, 0],
- },
- },
- },
- },
- series: [
- {
- type: `pie`,
- radius: [`84%`, `70%`],
- silent: true,
- clockwise: false,
- startAngle: 90,
- z: 0,
- zlevel: 0,
- data: [
- {
- value: value,
- itemStyle: {
- color: {
- type: `linear`,
- x: 1,
- y: 0,
- x2: 0,
- y2: 1,
- colorStops: [
- {
- offset: 0,
- color: `#DFFFFF`, // 0% 处的颜色
- },
- {
- offset: 1,
- color: `#0E7E7D`, // 100% 处的颜色
- },
- ],
- global: false, // 缺省为 false
- },
- },
- label: {
- show: false,
- },
- },
- {
- value: 100 - value,
- label: {
- show: false,
- },
- itemStyle: {
- normal: {
- color: `rgba(15, 31, 52,1)`,
- },
- },
- },
- ],
- },
- {
- name: ``,
- type: `gauge`,
- radius: `88%`,
- center: [`50%`, `50%`],
- startAngle: 0,
- endAngle: 360,
- splitNumber: 100,
- hoverAnimation: true,
- axisTick: {
- show: false,
- },
- splitLine: {
- length: splitLineLength,
- distance: splitLineDistance,
- lineStyle: {
- width: splitLineWidth,
- color: `#000`,
- },
- },
- axisLabel: {
- show: false,
- },
- pointer: {
- show: false,
- },
- axisLine: {
- show: false,
- },
- },
- {
- name: `外边框`,
- type: `pie`,
- clockwise: false, // 顺时加载
- emphasis: {
- scale: false, // 鼠标移入变大
- },
- center: [`50%`, `50%`],
- radius: [`88%`, `88%`],
- label: {
- show: false,
- },
- data: [
- {
- value: 0,
- name: ``,
- itemStyle: {
- borderWidth: 2,
- borderColor: `#24FFFD`,
- },
- },
- ],
- },
- ],
- }
- myChart.setOption(this.option)
- },
- },
- }
- </script>
- <style lang="less" scoped>
- .cakeBox {
- width: 401px;
- height: 234px;
- .chartsdom {
- width: 80%;
- height: 90%;
- }
- .panel {
- width: 80%;
- height: 80%;
- .panelitem {
- border-top: 2px solid rgba(255, 255, 255, 0.3);
- box-sizing: border-box;
- height: 50%;
- margin: 0 10px;
- .secondItem {
- font-size: 16px;
- margin: 21px 0;
- }
- }
- }
- }
- .flex {
- display: flex;
- }
- .img {
- height: 25px;
- margin-right: 3px;
- }
- .img1 {
- height: 17px;
- width: 3px;
- margin-right: 3px;
- }
- .l-height {
- line-height: 100%;
- }
- .space_around {
- justify-content: space-around;
- align-items: center;
- }
- .space_between {
- justify-content: space-between;
- align-items: center;
- }
- .number {
- font-size: 22px;
- padding: 4px 0;
- margin: 3px 0;
- }
- .text {
- font-size: 14px;
- color: #888888;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .column_reverse {
- flex-direction: column-reverse;
- }
- </style>
|