Skip to content

Commit

Permalink
feat: add chart-bar components
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwa committed Sep 24, 2018
1 parent 8cdc88b commit a9c200a
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/components/ChartBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Bar } from 'vue-chartjs'

export default {
extends: Bar,
props: {
labels: {
type: Array | String,
default () {
return []
}
},

datasets: {
type: Array,
default () {
return []
}
},

options: {
type: Object,
default () {
return {
responsive: true,
maintainAspectRatio: false // 保持长宽比
}
}
}
},

mounted () {
this.renderChart({
labels: this.labels,
datasets: [
{
backgroundColor: `#2693f8`,
data: this.datasets
}
]
}, {
// hide data label
legend: {
display: false
},

// hide axis and its labels
scales: {
xAxes: [{
display: false
}],
yAxes: [{
display: false
}]
},
scaleShowLabels: false,
...this.options
})
}
}

0 comments on commit a9c200a

Please sign in to comment.