Skip to content

Commit

Permalink
Merge pull request #82 from uchicago-dsi/todd_nief/fixing_issues
Browse files Browse the repository at this point in the history
Todd nief/fixing issues
  • Loading branch information
NickRoss authored Sep 17, 2024
2 parents 7116c8a + 9092a03 commit 022f392
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 92 deletions.
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

0 comments on commit 022f392

Please sign in to comment.