Skip to content

Commit

Permalink
feat(results): Add results-graph and display it in results summary page
Browse files Browse the repository at this point in the history
  • Loading branch information
CaedenPH committed Jul 15, 2024
1 parent 59b91e1 commit 544fd86
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Binary file added src/assets/results_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions src/routes/results.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import axios from "axios";
import { Application, Container, Graphics, Point, Sprite, Text } from "pixi.js";
import { Application, Container, Graphics, Point, Sprite, Text, Texture } from "pixi.js";

import { PDFDocument, rgb, StandardFonts } from "pdf-lib";
import { table } from "table";
import { CogSpeedGraphicsHandler } from "../ui/handler";
import { startUp } from "../main";
import { Config } from "../types/Config";

import resultsGraph from "../assets/results_graph.png";

export class ProcessResultsPage {
public resultsGraphTexture: Texture | undefined;

constructor(private app: Application, private ui: CogSpeedGraphicsHandler) {}

private formatKey(key: string, capitalise: boolean = false): string {
Expand Down Expand Up @@ -231,7 +235,7 @@ export class ProcessResultsPage {
wordWrapWidth: this.app.screen.width * 0.8
});
textSummary.position.set(this.app.screen.width * 0.5,
this.app.screen.height * 0.15);
this.app.screen.height * 0.18);

textSummary.anchor.set(0.5);
this.app.stage.addChild(textSummary);
Expand All @@ -247,16 +251,27 @@ export class ProcessResultsPage {
this.ui.removeAllStageChildren();
this.show(data, config, {shouldLoad: false});
});

if (!this.resultsGraphTexture) {
throw new Error("Results graph texture is not loaded.");
}

const graphSprite = new Sprite(this.resultsGraphTexture);
graphSprite.position.set(this.app.screen.width * 0.5, this.app.screen.height * 0.55)
graphSprite.scale.set(0.7);
graphSprite.anchor.set(0.5, 0.5)

this.app.stage.addChild(graphSprite);
this.app.stage.addChild(backButtonContainer);
}

public async show(data: { [key: string]: any }, config: Config, args: { shouldLoad: boolean} = {shouldLoad: true}) {
let loadingContainer;
if (args.shouldLoad) {
loadingContainer = this.loadingScreen();
this.resultsGraphTexture = Texture.from(resultsGraph);
}


const [geolocation, normalizedLocation] = await this.getCurrentPosition();
data.location = {
geolocation,
Expand Down

0 comments on commit 544fd86

Please sign in to comment.