Skip to content

Commit

Permalink
My name is Todd and I'm fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
NickRoss committed Sep 17, 2024
1 parent 7116c8a commit d94d5f3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
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

0 comments on commit d94d5f3

Please sign in to comment.