<template>
  <div class="aswdbox">
    <div v-for="(item,index) in data" :key="index" class="aswlist">
      <div class="bl">
        <p>{{ item.num }}</p>
        <p>（{{ (item.num*100/item.total).toFixed(2) }}%）</p>
      </div>
      <div class="bar">
        <div class="barbg" />
        <div v-if="item.right!=-1" class="colorbar" :class="item.right==1?'green':'red'" :style="'height:'+(item.num*100/item.total).toFixed(2)+'%'" />
        <div v-else class="colorbar gary" :style="'height:'+(item.num*100/item.total).toFixed(2)+'%'" />
      </div>
      <div class="asw">
        <p>{{ item.answer }}</p>
      </div>
    </div>
  </div>

</template>
<script>
export default {
  name: 'Aswdetail',
  props: {
    data: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      contnet: ''
    }
  }
}
</script>
<style scoped>

.aswlist{
    float:left;
    width:100px;
}
.bl{
    text-align: center;
}
.bl p{
    margin:0;
}
.asw{
    text-align: center
}
.asw p{
    word-wrap: break-word;
}
.bar{
    width:100px;
    height:200px;
    position: relative;
    border-bottom:1px solid #ccc;
}
.barbg{
    width:20px;
    height:100%;
    margin: 0 auto;
    background: #ccc;
    border-radius:10px 10px 0 0;
}
.colorbar{
    width:20px;
    height:100px;
    border-radius: 10px 10px 0 0;
    position: absolute;
    left:40px;
    bottom:0;
}
.red{
    background: #f00;
}
.green{
    background: #0f0;
}
.gary{
    background: #888;
}
</style>
