Guest User

Untitled

a guest
Oct 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. export default {
  2. mounted: function() {
  3. this.$nextTick(function() {
  4. this.create();
  5. })
  6. },
  7. methods: {
  8. pie: function(rating) {
  9. // Does not responds
  10. console.log(rating);
  11. let ctx = document.getElementById('history');
  12. let data = {
  13. datasets: [{
  14. data: [rating.length]
  15. }],
  16. labels: [
  17. 'Empty.'
  18. ]
  19. };
  20.  
  21. let chart = new Chart(ctx, {
  22. type: 'pie',
  23. data: data
  24. });
  25. },
  26.  
  27. create: function() {
  28. Axios.get('/rating/pastSixMonth')
  29. .then(function(response) {
  30. response.data.forEach(function(element) {
  31. // method call
  32. this.pie(element.rating);
  33. })
  34. })
  35. .catch(function(error) {
  36. console.log(error);
  37. });
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment