Chart functions moved to /api.js

This commit is contained in:
2020-03-10 00:50:55 +01:00
parent 035b129c9f
commit e5319662b8
3 changed files with 22 additions and 16 deletions
+17
View File
@@ -29,6 +29,21 @@ const overallWineStatistics = () => {
}
const chartWinsByColor = () => {
const url = new URL("/api/purchase/statistics/color", BASE_URL)
return fetch(url.href)
.then(resp => resp.json())
}
const chartPurchaseByColor = () => {
const url = new URL("/api/purchase/statistics", BASE_URL)
return fetch(url.href)
.then(resp => resp.json())
}
const prelottery = () => {
const url = new URL("/api/wines/prelottery", BASE_URL)
@@ -150,6 +165,8 @@ export {
colorStatistics,
highscoreStatistics,
overallWineStatistics,
chartWinsByColor,
chartPurchaseByColor,
prelottery,
log,
logWines,
+2 -7
View File
@@ -7,18 +7,13 @@
<script>
import Chartjs from "chart.js";
import { chartPurchaseByColor } from "@/api";
export default {
async mounted() {
let canvas = this.$refs["purchase-chart"].getContext("2d");
let _response = undefined;
if (process.env.NODE_ENV == "development") {
_response = await fetch("http://localhost:30030/api/purchase/statistics");
} else {
_response = await fetch("/api/purchase/statistics");
}
let response = await _response.json();
let response = await chartPurchaseByColor();
let labels = [];
let blue = {
label: "Blå",
+3 -9
View File
@@ -5,19 +5,13 @@
</template>
<script>
import { chartWinsByColor } from "@/api";
export default {
async mounted() {
let canvas = this.$refs["win-chart"].getContext("2d");
let _response = undefined;
if (process.env.NODE_ENV == "development") {
_response = await fetch(
"http://localhost:30030/api/purchase/statistics/color"
);
} else {
_response = await fetch("/api/purchase/statistics/color");
}
let response = await _response.json();
let response = await chartWinsByColor();
let labels = ["Vunnet"];
let blue = {
label: "Blå",