<template> <v-card dense height="400" class="elevation-0" > <v-toolbar class="elevation-0 " dense > <v-toolbar-title>통계</v-toolbar-title> <v-spacer></v-spacer> </v-toolbar> <div v-if="result.length !== 0" class=" pa-0 ma-0"> <DoughnutChart class="mt-3 pa-0 ma-0" :chart-data="totalColl" :height="220" :percent="percent" /> </div> </v-card> </template> <script> import DoughnutChart from '../../components/DoughnutChart.vue' export default { data () { return { total:0, totalColl:{}, success:0, fail:0, percent:0 } }, props: { step:Number, wpo:String, infos:Array, project:Object, result:Array, counter:Number }, mounted(){ this.totalColl = { labels: ['성공','실패'], datasets: [ { backgroundColor: ['#4CAF50' ,'#F44336'], data: [ this.success ,this.fail], } ], } }, components: { DoughnutChart, }, watch:{ result(current){ if(current.length !== 0){ this.total = this.total + current[current.length-1]['time'] current[current.length-1]['result'] === 0 ? ++ this.fail : ++this.success this.percent = Math.round((100 * this.success ) / this.counter) this.totalColl = { labels: ['성공','실패'], datasets: [ { backgroundColor: ['#4CAF50' ,'#F44336'], data: [ this.success ,this.fail], } ], } } }, step(current){ if(current === 1){ this.total = 0, this.totalColl ={}, this.success = 0, this.fail = 0, this.percent = 0 } } } } </script> <style> </style>