borsha06

diagramm.js

May 14th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Doughnut} from 'vue-chartjs'
  2. export default {
  3.    name: 'diagram',
  4.     extends: Doughnut,
  5.     data: () => ({
  6.         message: {
  7.  
  8.            datasets: [
  9.                 {}
  10.             ]
  11.         },
  12.  
  13.     }),
  14.     created(){
  15.       score_func();
  16.         this.$http({
  17.             method: 'get',
  18.             url: this.base_url + '/exam/api/' + 'score/' + this.$store.state.user.id + '/',
  19.  
  20.             auth: {
  21.                 username: 'l360_mobile_app',
  22.                 password: 'itsd321#'
  23.             },
  24.         }).then(res => {
  25.  
  26.             console.log(res);
  27.             if (res.status == '200') {
  28.                 console.log(res.data);
  29.                 this.score = res.data;
  30.                 for (let v  in  this.score) {
  31.                     this.value.push(this.score[v]);
  32.                 }
  33.                 for (let key  in  this.score) {
  34.                     this.keys.push(key);
  35.                 }
  36.  
  37.  
  38.                 console.log(this.keys);
  39.                 console.log(this.value);
  40.             }
  41.         });
  42.        
  43.  
  44.     },
  45.     mounted () {
  46.  
  47.  
  48.         // Overwriting base render method with actual data.
  49.                 this.renderChart({
  50.             labels: this.keys,
  51.                    
  52.             datasets: [
  53.                 {
  54.                     backgroundColor: [
  55.                         '#41B883',
  56.                         '#E46651',
  57.                         '#00D8FF',
  58.                         '#DD1B16',
  59.                         '#aeff53',
  60.                         '#245dff',
  61.                         '#ff539a',
  62.                         '#d18945',
  63.                         '#ff1e98',
  64.                         '#3eff94',
  65.                         '#ff907f',
  66.                         '#ffd02a',
  67.                         '#ffc79b',
  68.                         '#ff2551',
  69.                     ],
  70.                  
  71.                     data:this.value
  72.                 }
  73.             ]
  74.         }, {
  75.             responsive: true,
  76.             maintainAspectRatio: false,
  77.            // pieceLabel: {
  78.              //   mode: 'percentage',
  79.                // precision: 1
  80.             //}
  81.         })
  82.     },
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment