add plots
This commit is contained in:
@@ -8,11 +8,12 @@ import ImageDownloader from './ImageDownloader';
|
|||||||
function CurveFit({ show }) {
|
function CurveFit({ show }) {
|
||||||
const [showCardInfo, setShowCardInfo] = useState(false);
|
const [showCardInfo, setShowCardInfo] = useState(false);
|
||||||
const [svgData, setSvgData] = useState(null);
|
const [svgData, setSvgData] = useState(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
const fetchSvg = () => {
|
const fetchSvg = () => {
|
||||||
axios({
|
axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: "https://asia-south1-hpos-qa.cloudfunctions.net/curvefit",
|
url: "https://asia-south1-hpos-af3cc.cloudfunctions.net/crdboxplot",
|
||||||
data: {
|
data: {
|
||||||
"_id": "id",
|
"_id": "id",
|
||||||
"underMedication": false,
|
"underMedication": false,
|
||||||
@@ -28,29 +29,37 @@ function CurveFit({ show }) {
|
|||||||
})
|
})
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
// setMessage(`${id} is being created`);
|
setSvgData(data?.plot?.replace('\"', '').replace('\n', '').replace('"', "'"));
|
||||||
// setSvgData(data?.plot?.replace('\"', '').replace('\n', '').replace('"', "'"));
|
setLoading(false); // Set loading to false once data is fetched
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
// setMessage(`error: ${err?.message}`);
|
setLoading(false); // Set loading to false in case of an error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!svgData) {
|
if (!svgData) {
|
||||||
// fetchSvg();
|
fetchSvg();
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>Curve Fit</h1>
|
<h1>Plots</h1>
|
||||||
{/* <img alt='' src={ svgData }/>; */}
|
|
||||||
<img src="https://asia-south1-hpos-qa.cloudfunctions.net/curvefit" width="450" height="340" />
|
{loading ? (
|
||||||
|
<div className="spinner-container">
|
||||||
|
{/* Add your spinner component here or use a simple text */}
|
||||||
|
<p>Loading...</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<img src={`https://asia-south1-${process.env.REACT_APP_FIREBASE_PROJECT_ID}.cloudfunctions.net/crdboxplot`} width="450" height="340" />
|
||||||
|
)}
|
||||||
|
|
||||||
{/* <ImageDownloader /> */}
|
{/* <ImageDownloader /> */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default CurveFit;
|
|
||||||
|
export default CurveFit;
|
||||||
|
|||||||
@@ -114,15 +114,15 @@ const appRoutes = [
|
|||||||
icon: <FaChartLine />
|
icon: <FaChartLine />
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// path: "/curvefit",
|
path: "/plots",
|
||||||
// element: <CurveFit />,
|
element: <CurveFit />,
|
||||||
// state: "curvefit",
|
state: "plots",
|
||||||
// sidebarProps: {
|
sidebarProps: {
|
||||||
// displayText: "Linear Fit",
|
displayText: "Plots",
|
||||||
// icon: <FaBezierCurve />
|
icon: <FaBezierCurve />
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
path: "/chat",
|
path: "/chat",
|
||||||
element: <Gemini />,
|
element: <Gemini />,
|
||||||
|
|||||||
Reference in New Issue
Block a user