Browse Source

Update chart

pull/10/head
Hironsan 6 years ago
parent
commit
1e7b846c47
2 changed files with 20 additions and 11 deletions
  1. 2
      app/server/static/bundle/stats.js
  2. 29
      app/server/static/js/stats.js

2
app/server/static/bundle/stats.js

@ -2193,7 +2193,7 @@ eval("module.exports = function(module) {\n\tif (!module.webpackPolyfill) {\n\t\
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue_chartjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue-chartjs */ \"./node_modules/vue-chartjs/es/index.js\");\n\nconst {\n reactiveProp,\n reactiveData\n} = vue_chartjs__WEBPACK_IMPORTED_MODULE_0__[\"mixins\"]\n\naxios.defaults.xsrfCookieName = 'csrftoken';\naxios.defaults.xsrfHeaderName = 'X-CSRFToken';\nvar base_url = window.location.href.split('/').slice(3, 5).join('/');\nconst HTTP = axios.create({\n baseURL: `/api/${base_url}/`,\n})\n\n\nVue.component('line-chart', {\n extends: vue_chartjs__WEBPACK_IMPORTED_MODULE_0__[\"HorizontalBar\"],\n mixins: [reactiveProp],\n props: ['chartData'],\n mounted() {\n this.renderChart(this.chartData, {\n scales: {\n yAxes: [{\n barPercentage: 0.3\n }],\n },\n maintainAspectRatio: false\n })\n }\n})\n\nvar vm = new Vue({\n el: '#mail-app',\n delimiters: ['[[', ']]'],\n data: {\n labelData: null,\n userData: null\n },\n\n methods: {\n makeData(data, labels, label) {\n console.log(data);\n console.log(label);\n var data = {\n labels: labels,\n datasets: [{\n label: label,\n backgroundColor: '#00d1b2',\n data: data\n }]\n }\n return data\n }\n },\n\n created: function () {\n HTTP.get('stats').then(response => {\n this.labelData = this.makeData(response.data.label.data, response.data.label.labels, 'Label stats');\n this.userData = this.makeData(response.data.user.data, response.data.user.users, 'User stats');\n })\n }\n})\n\n//# sourceURL=webpack:///./static/js/stats.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue_chartjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue-chartjs */ \"./node_modules/vue-chartjs/es/index.js\");\n\nconst {\n reactiveProp,\n reactiveData\n} = vue_chartjs__WEBPACK_IMPORTED_MODULE_0__[\"mixins\"]\n\naxios.defaults.xsrfCookieName = 'csrftoken';\naxios.defaults.xsrfHeaderName = 'X-CSRFToken';\nvar base_url = window.location.href.split('/').slice(3, 5).join('/');\nconst HTTP = axios.create({\n baseURL: `/api/${base_url}/`,\n})\n\n\nVue.component('line-chart', {\n extends: vue_chartjs__WEBPACK_IMPORTED_MODULE_0__[\"HorizontalBar\"],\n mixins: [reactiveProp],\n props: ['chartData'],\n data: function () {\n return {\n options: {\n scales: {\n yAxes: [{\n barPercentage: 0.3,\n }],\n xAxes: [{\n ticks: {\n beginAtZero: true,\n min: 0\n }\n }]\n },\n maintainAspectRatio: false,\n }\n }\n },\n mounted() {\n this.renderChart(this.chartData, this.options)\n }\n})\n\nvar vm = new Vue({\n el: '#mail-app',\n delimiters: ['[[', ']]'],\n data: {\n labelData: null,\n userData: null\n },\n\n methods: {\n makeData(data, labels, label) {\n var data = {\n labels: labels,\n datasets: [{\n label: label,\n backgroundColor: '#00d1b2',\n data: data\n }]\n }\n return data\n }\n },\n\n created: function () {\n HTTP.get('stats').then(response => {\n this.labelData = this.makeData(response.data.label.data, response.data.label.labels, 'Label stats');\n this.userData = this.makeData(response.data.user.data, response.data.user.users, 'User stats');\n })\n }\n})\n\n//# sourceURL=webpack:///./static/js/stats.js?");
/***/ })

29
app/server/static/js/stats.js

@ -19,15 +19,26 @@ Vue.component('line-chart', {
extends: HorizontalBar,
mixins: [reactiveProp],
props: ['chartData'],
data: function () {
return {
options: {
scales: {
yAxes: [{
barPercentage: 0.3,
}],
xAxes: [{
ticks: {
beginAtZero: true,
min: 0
}
}]
},
maintainAspectRatio: false,
}
}
},
mounted() {
this.renderChart(this.chartData, {
scales: {
yAxes: [{
barPercentage: 0.3
}],
},
maintainAspectRatio: false
})
this.renderChart(this.chartData, this.options)
}
})
@ -41,8 +52,6 @@ var vm = new Vue({
methods: {
makeData(data, labels, label) {
console.log(data);
console.log(label);
var data = {
labels: labels,
datasets: [{

Loading…
Cancel
Save