<template>
<div :style="{ padding: '0 0 32px 32px' }">
<v-chart :forceFit="true" :height="height" :data="dataSource" :scale="scale" :padding="padding">
<v-tooltip/>
<v-axis/>
<v-bar position="x*y" />
</v-chart>
</div>
</template>
<script>
import { triggerWindowResizeEvent } from '@/utils/util'
export default {
name: 'Bar',
props: {
dataSource: {
type: Array,
required: true
},
yaxisText: {
type: String,
default: 'y'
},
height: {
type: Number,
default: 254
}
},
data() {
return {
padding: ['auto', 'auto', '40', '50'],
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0,
pointWidth: 30
}
}
}
},
computed: {
scale() {
return [{
dataKey: 'y',
alias: this.yaxisText
}]
}
},
mounted() {
triggerWindowResizeEvent()
}
}
</script>
如果把这个柱形图的每一条宽度固定 让它变小
barData:【{x:陈天阳,y:100}…】