Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Todd nief/fixing issues #82

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env*
.local.env
service-account-key-base64.txt
compostable-428115-5dde0b40960b.json
data/*
Expand Down
67 changes: 36 additions & 31 deletions dashboard/components/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"use client";
import React from "react";
import Alert from "@/components/Alert";
import { col2material } from "@/lib/constants";
import state from "@/lib/state";
import Plot from "react-plotly.js";
import { useSnapshot } from "valtio";
import state from "@/lib/state";
import { col2material } from "@/lib/constants";
import Alert from "@/components/Alert";

export default function Dashboard() {
const snap = useSnapshot(state);
Expand Down Expand Up @@ -47,31 +46,34 @@ export default function Dashboard() {
const plotData =
Object.keys(snap.data).length > 0
? snap.data.data.map((d) => {
console.log(d);
const materialClass = d["Material Class I"];
const color = class2color[materialClass] || "#000";
const countDisplay =
snap.filters["testMethod"] === "Mesh Bag"
? ` (n=${d["count"]})`
: "";
// Replace "Positive" with "Pos." in labels and append count
const name = `${d["aggCol"]}${countDisplay}`.replace(
"Positive",
"Pos."
);
const wrappedName = wrapLabel(name);

return {
type: "box",
name: wrappedName,
y: [d.min, d.q1, d.median, d.q3, d.max],
marker: { color },
boxmean: true,
line: { width: 3.25 },
};
})
const materialClass = d["Material Class I"];
const color = class2color[materialClass] || "#000";
const countDisplay =
snap.filters["testMethod"] === "Mesh Bag"
? ` (n=${d["count"]})`
: "";
// Replace "Positive" with "Pos." in labels and append count
const name = `${d["aggCol"]}${countDisplay}`.replace(
"Positive",
"Pos."
);
const wrappedName = wrapLabel(name);

return {
type: "box",
name: wrappedName,
y: [d.min, d.q1, d.median, d.q3, d.max],
marker: { color },
boxmean: true,
line: { width: 3.25 },
};
})
: [];

const cleanDisplayCol = snap.filters.displayResiduals === "Disintegrated"
? snap.filters.displayCol.replace("Residuals", "Disintegrated")
: snap.filters.displayCol

function generateYAxisTitle(displayCol, cap) {
let yAxisTitle = `${displayCol}`;
if (cap) {
Expand All @@ -80,16 +82,19 @@ export default function Dashboard() {
return yAxisTitle;
}
const yAxisTitle = generateYAxisTitle(
snap.filters.displayCol,
cleanDisplayCol,
!snap.filters.uncapResults
);

function generateTitle(displayCol, aggCol, num_trials) {
return `${displayCol} by ${col2material[aggCol]} - ${num_trials} Trial(s)`;


function generateTitle(cleanDisplayCol, aggCol, num_trial) {
return `${cleanDisplayCol} by ${col2material[aggCol]} - ${num_trial} Trial(s)`;
}


const title = generateTitle(
snap.filters.displayCol,
cleanDisplayCol,
snap.filters.aggCol,
snap.data.numTrials
);
Expand Down
7 changes: 3 additions & 4 deletions dashboard/components/DashboardDisplayControls.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"use client";
import React from "react";
import RadioSingleSelect from "./RadioSingleSelect";
import { material2col, residuals2col, display2col } from "@/lib/constants";
import { useSnapshot } from "valtio";
import { display2col, material2col, residuals2col } from "@/lib/constants";
import state from "@/lib/state";
import { InformationCircleIcon } from "@heroicons/react/24/solid";
import { useSnapshot } from "valtio";
import RadioSingleSelect from "./RadioSingleSelect";

export default function DashboardDisplayControls() {
const snap = useSnapshot(state);
Expand Down
Loading
Loading