Created
January 26, 2019 04:43
-
-
Save evan4/34832094d192cf817ad1f07acddd74e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="small"> | |
<line-chart :chart-data="datacollection" :options="options"></line-chart> | |
</div> | |
</template> | |
<script> | |
import LineChart from './LineChart.js' | |
export default { | |
components: { | |
LineChart | |
}, | |
data () { | |
return { | |
datacollection: null, | |
options: { | |
legend: { | |
display: true, | |
position: "left", | |
fullWidth: true, | |
labels: { | |
boxWidth: 10, | |
fontSize: 14 | |
} | |
}, | |
responsive: true, | |
maintainAspectRatio: false | |
} | |
} | |
}, | |
mounted () { | |
this.fillData() | |
}, | |
methods: { | |
randomColor(len) { | |
let arr = []; | |
for (let index = 0; index < len; index++) { | |
const r = () => Math.floor(256 * Math.random()); | |
arr.push(`rgba(${r()}, ${r()}, ${r()}, .3)`); | |
} | |
return arr; | |
}, | |
fillData () { | |
this.datacollection = { | |
labels: [ | |
'Программист', | |
'Разработчик', | |
'Тестер', | |
'Тимлид', | |
'Фронтенд', | |
'Бекенд', | |
], | |
datasets: [{ | |
data: [1, 2, 3, 4, 5, 6], | |
backgroundColor: this.randomColor(6) | |
}], | |
} | |
}, | |
} | |
} | |
</script> | |
<style> | |
.small { | |
max-width: 600px; | |
margin: 150px auto; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment