Chart functions moved to /api.js
This commit is contained in:
17
src/api.js
17
src/api.js
@@ -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 prelottery = () => {
|
||||||
const url = new URL("/api/wines/prelottery", BASE_URL)
|
const url = new URL("/api/wines/prelottery", BASE_URL)
|
||||||
|
|
||||||
@@ -150,6 +165,8 @@ export {
|
|||||||
colorStatistics,
|
colorStatistics,
|
||||||
highscoreStatistics,
|
highscoreStatistics,
|
||||||
overallWineStatistics,
|
overallWineStatistics,
|
||||||
|
chartWinsByColor,
|
||||||
|
chartPurchaseByColor,
|
||||||
prelottery,
|
prelottery,
|
||||||
log,
|
log,
|
||||||
logWines,
|
logWines,
|
||||||
|
|||||||
@@ -7,18 +7,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Chartjs from "chart.js";
|
import Chartjs from "chart.js";
|
||||||
|
import { chartPurchaseByColor } from "@/api";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async mounted() {
|
async mounted() {
|
||||||
let canvas = this.$refs["purchase-chart"].getContext("2d");
|
let canvas = this.$refs["purchase-chart"].getContext("2d");
|
||||||
|
|
||||||
let _response = undefined;
|
let response = await chartPurchaseByColor();
|
||||||
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 labels = [];
|
let labels = [];
|
||||||
let blue = {
|
let blue = {
|
||||||
label: "Blå",
|
label: "Blå",
|
||||||
|
|||||||
@@ -5,19 +5,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { chartWinsByColor } from "@/api";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async mounted() {
|
async mounted() {
|
||||||
let canvas = this.$refs["win-chart"].getContext("2d");
|
let canvas = this.$refs["win-chart"].getContext("2d");
|
||||||
|
|
||||||
let _response = undefined;
|
let response = await chartWinsByColor();
|
||||||
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 labels = ["Vunnet"];
|
let labels = ["Vunnet"];
|
||||||
let blue = {
|
let blue = {
|
||||||
label: "Blå",
|
label: "Blå",
|
||||||
|
|||||||
Reference in New Issue
Block a user