change graph to normal
- add absorbance graph
This commit is contained in:
@@ -100,7 +100,7 @@ body {
|
||||
}
|
||||
|
||||
.last-update {
|
||||
margin-right: 0.3vw;
|
||||
margin-right: 10vw;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 320px) {
|
||||
|
||||
12
src/App.js
12
src/App.js
@@ -7,7 +7,7 @@ import { getAnalytics } from "firebase/analytics";
|
||||
import { getFirestore, collection, getDocs, doc, onSnapshot, query } from "firebase/firestore";
|
||||
import Card from './components/Card';
|
||||
|
||||
// dev and test
|
||||
// /* dev and test */
|
||||
// const firebaseConfig = {
|
||||
// apiKey: "AIzaSyBFl_YkJ5PMIvMY3G70313SyrqemjFnUv8",
|
||||
// authDomain: "hpos-af3cc.firebaseapp.com",
|
||||
@@ -19,7 +19,7 @@ import Card from './components/Card';
|
||||
// };
|
||||
|
||||
|
||||
// prod
|
||||
/* prod */
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyBF4pLZReAedU4dWX1eRJNFNIaOIz2xk4s",
|
||||
authDomain: "hpos-prod.firebaseapp.com",
|
||||
@@ -41,6 +41,7 @@ function App() {
|
||||
const [totalScreened, setTotalScreened] = useState(0);
|
||||
const [males, setMales] = useState(0);
|
||||
const [females, setFemales] = useState(0);
|
||||
const [normal, setNormal] = useState(0);
|
||||
const [positives, setPositives] = useState(0);
|
||||
const [traits, setTraits] = useState(0);
|
||||
const [diseases, setDiseases] = useState(0);
|
||||
@@ -77,12 +78,16 @@ function App() {
|
||||
|
||||
const unsub = onSnapshot(q, (querySnapshot) => {
|
||||
const hposTests = [];
|
||||
let normalCount = 0;
|
||||
let traitCount = 0;
|
||||
let diseaseCount = 0;
|
||||
querySnapshot.forEach((document) => {
|
||||
const hposTestData = document.data();
|
||||
hposTests.push(hposTestData);
|
||||
const { result } = hposTestData;
|
||||
if (result === "NORMAL") {
|
||||
normalCount++;
|
||||
}
|
||||
if (result === 'SICKLECELLTRAIT') {
|
||||
traitCount++;
|
||||
}
|
||||
@@ -90,6 +95,7 @@ function App() {
|
||||
diseaseCount++;
|
||||
}
|
||||
});
|
||||
setNormal(normalCount);
|
||||
setPositives(traitCount + diseaseCount);
|
||||
setTraits(traitCount);
|
||||
setDiseases(diseaseCount);
|
||||
@@ -128,7 +134,7 @@ function App() {
|
||||
</div>
|
||||
|
||||
<div className='cards-row'>
|
||||
<Card title={"Tested Positive"} counter={positives} backgroundColor={'rgb(244,137, 137)'} />
|
||||
<Card title={"Normal"} counter={normal} backgroundColor={'rgb(192,233, 199)'} />
|
||||
<Card title={"Trait"} counter={traits} backgroundColor={'rgb(237, 190, 190)'} />
|
||||
<Card title={"Disease"} counter={diseases} backgroundColor={'rgb(249, 195, 195)'} />
|
||||
</div>
|
||||
|
||||
14
src/components/DeviceGraph.css
Normal file
14
src/components/DeviceGraph.css
Normal file
@@ -0,0 +1,14 @@
|
||||
.line {
|
||||
fill: none;
|
||||
stroke: #009EDC;
|
||||
stroke-width: 5px;
|
||||
}
|
||||
|
||||
.graph-card {
|
||||
width: 80vw;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.graph-title {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -1,11 +1,130 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { Component } from 'react';
|
||||
import * as d3 from 'd3';
|
||||
import './DeviceGraph.css';
|
||||
|
||||
function DeviceGraph() {
|
||||
return (
|
||||
<div>
|
||||
Hi
|
||||
</div>
|
||||
)
|
||||
class DeviceGraph extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
this.drawChart();
|
||||
}
|
||||
|
||||
drawChart() {
|
||||
var margin = { top: 20, right: 20, bottom: 30, left: 50 },
|
||||
width = 960 - margin.left - margin.right,
|
||||
height = 500 - margin.top - margin.bottom;
|
||||
|
||||
// set the ranges
|
||||
var x = d3.scaleTime().range([0, width]);
|
||||
var y = d3.scaleLinear().range([height, 0]);
|
||||
|
||||
// define the line
|
||||
var valueline = d3.line()
|
||||
.x(function (d) { return x(d.wavelength); })
|
||||
.y(function (d) { return y(d.calculation); });
|
||||
|
||||
// append the svg obgect to the body of the page
|
||||
// appends a 'group' element to 'svg'
|
||||
// moves the 'group' element to the top left margin
|
||||
var svg = d3.select("#wavelength-graph").append("svg")
|
||||
.attr("width", width + margin.left + margin.right)
|
||||
.attr("height", height + margin.top + margin.bottom)
|
||||
.append("g").attr("transform",
|
||||
"translate(" + margin.left + "," + margin.top + ")");
|
||||
|
||||
// d3.csv("https://thingproxy.freeboard.io/fetch/https://firebasestorage.googleapis.com/v0/b/hpos-af3cc.appspot.com/o/255668896558B%204DDG%2FHPOSSC_255668896558B%204DDG.csv?alt=media&token=d63d0e5f-0845-4cb6-98c6-cbfb6904cfd7", function (error, data) {
|
||||
// alert(data.length)
|
||||
// // var data = [
|
||||
// // {
|
||||
// // "year": 2006,
|
||||
// // "population": 40
|
||||
// // },
|
||||
// // {
|
||||
// // "year": 2008,
|
||||
// // "population": 45
|
||||
// // },
|
||||
// // {
|
||||
// // "year": 2010,
|
||||
// // "population": 48
|
||||
// // },
|
||||
// // {
|
||||
// // "year": 2012,
|
||||
// // "population": 51
|
||||
// // },
|
||||
// // {
|
||||
// // "year": 2014,
|
||||
// // "population": 53
|
||||
// // },
|
||||
// // {
|
||||
// // "year": 2016,
|
||||
// // "population": 57
|
||||
// // },
|
||||
// // {
|
||||
// // "year": 2017,
|
||||
// // "population": 62
|
||||
// // }
|
||||
// // ];
|
||||
// // console.log(data);
|
||||
// // // if (error) throw error;
|
||||
// // // format the data
|
||||
// // data.forEach(function (d) {
|
||||
// // d.year = d.year;
|
||||
// // d.population = +d.population;
|
||||
// // });
|
||||
|
||||
// // // Scale the range of the data
|
||||
// // x.domain(d3.extent(data, function (d) { return d.year; }));
|
||||
// // y.domain([0, d3.max(data, function (d) { return d.population; })]);
|
||||
|
||||
// // // Add the valueline path.
|
||||
// // svg.append("path")
|
||||
// // .data([data])
|
||||
// // .attr("class", "line")
|
||||
// // .attr("d", valueline);
|
||||
|
||||
// // // Add the X Axis
|
||||
// // svg.append("g")
|
||||
// // .attr("transform", "translate(0," + height + ")")
|
||||
// // .call(d3.axisBottom(x));
|
||||
|
||||
// // // Add the Y Axis
|
||||
// // svg.append("g")
|
||||
// // .call(d3.axisLeft(y));
|
||||
// });
|
||||
|
||||
|
||||
|
||||
/* test graph */
|
||||
const testData = require('./testData.json').filter(x => { if (x.NM > 397 && x.NM < 580) return x; });
|
||||
|
||||
testData.forEach(function (d) {
|
||||
d.wavelength = d.NM;
|
||||
d.calculation = +d.CA;
|
||||
});
|
||||
|
||||
x.domain(d3.extent(testData, function (d) { return d.wavelength; }));
|
||||
y.domain([0, d3.max(testData, function (d) { return d.calculation; })]);
|
||||
|
||||
svg.append("path")
|
||||
.data([testData])
|
||||
.attr("class", "line")
|
||||
.attr("d", valueline);
|
||||
|
||||
svg.append("g")
|
||||
.attr("transform", "translate(0," + height + ")")
|
||||
.call(d3.axisBottom(x));
|
||||
|
||||
svg.append("g")
|
||||
.call(d3.axisLeft(y));
|
||||
}
|
||||
|
||||
render() {
|
||||
return (<div>
|
||||
<div className='graph-card'>
|
||||
<div id="wavelength-graph" style={{ margin: '1em' }}>
|
||||
</div>
|
||||
<div className='graph-title'>wavelength vs absorbance</div>
|
||||
</div>
|
||||
</div>);
|
||||
}
|
||||
}
|
||||
|
||||
export default DeviceGraph;
|
||||
@@ -16,7 +16,7 @@ const router = createBrowserRouter([
|
||||
element: <App />,
|
||||
},
|
||||
{
|
||||
path: "/devices",
|
||||
path: "/absorbance",
|
||||
element: <DeviceGraph />,
|
||||
}
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user