Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Doughnut} from 'vue-chartjs'
- export default {
- name: 'diagram',
- extends: Doughnut,
- data: () => ({
- message: {
- datasets: [
- {}
- ]
- },
- }),
- created(){
- score_func();
- this.$http({
- method: 'get',
- url: this.base_url + '/exam/api/' + 'score/' + this.$store.state.user.id + '/',
- auth: {
- username: 'l360_mobile_app',
- password: 'itsd321#'
- },
- }).then(res => {
- console.log(res);
- if (res.status == '200') {
- console.log(res.data);
- this.score = res.data;
- for (let v in this.score) {
- this.value.push(this.score[v]);
- }
- for (let key in this.score) {
- this.keys.push(key);
- }
- console.log(this.keys);
- console.log(this.value);
- }
- });
- },
- mounted () {
- // Overwriting base render method with actual data.
- this.renderChart({
- labels: this.keys,
- datasets: [
- {
- backgroundColor: [
- '#41B883',
- '#E46651',
- '#00D8FF',
- '#DD1B16',
- '#aeff53',
- '#245dff',
- '#ff539a',
- '#d18945',
- '#ff1e98',
- '#3eff94',
- '#ff907f',
- '#ffd02a',
- '#ffc79b',
- '#ff2551',
- ],
- data:this.value
- }
- ]
- }, {
- responsive: true,
- maintainAspectRatio: false,
- // pieceLabel: {
- // mode: 'percentage',
- // precision: 1
- //}
- })
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment