Skip to content

Commit

Permalink
analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
mukilan2815 committed Jun 26, 2024
1 parent 63f6d54 commit 2141d58
Show file tree
Hide file tree
Showing 10 changed files with 648 additions and 53 deletions.
266 changes: 259 additions & 7 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.2",
"chart.js": "^4.4.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"faker": "^6.6.6",
"install": "^0.13.0",
"npm": "^10.8.1",
"react": "^18.3.1",
"react-bootstrap": "^2.10.3",
"react-chartjs-2": "^5.2.0",
"react-chatbot-kit": "^2.2.2",
"react-dom": "^18.3.1",
"react-router-dom": "^6.23.1",
"react-scripts": "5.0.1",
Expand Down
3 changes: 3 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import AdminOB from "./Pages/Admin/AdminOB";
import AdminMC from "./Pages/Admin/AdminMC";

import Home from "./Pages/Admin/Home";
import Analysis from "./Pages/Admin/Analysis";
function App() {
return (
<Router>
Expand All @@ -36,6 +37,8 @@ function App() {
<Route path="/adminao" element={<AdminAO />} />
<Route path="/adminceo" element={<AdminCEO />} />
<Route path="/adminob" element={<AdminOB />} />

<Route path="/analysis" element={<Analysis />} />
</Routes>
</div>
</Router>
Expand Down
10 changes: 6 additions & 4 deletions src/Pages/Admin/AdminAO.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react";
import React from 'react'

const AdminAO = () => {
return <div>AdminAO</div>;
};
return (
<div>AdminAO</div>
)
}

export default AdminAO;
export default AdminAO
182 changes: 182 additions & 0 deletions src/Pages/Admin/Analysis.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import React, { useEffect, useState } from "react";
import { Bar, Doughnut, Line, Pie } from "react-chartjs-2";
import {
Chart as ChartJS,
ArcElement,
CategoryScale,
LinearScale,
BarElement,
LineElement,
PointElement,
Title,
Tooltip,
Legend,
} from "chart.js";
import "react-chatbot-kit/build/main.css";

ChartJS.register(
ArcElement,
CategoryScale,
LinearScale,
BarElement,
LineElement,
PointElement,
Title,
Tooltip,
Legend
);

const Dashboard = () => {
const [formData, setFormData] = useState(null);
const [selectedChart, setSelectedChart] = useState("bar");

useEffect(() => {
const storedFormData = JSON.parse(localStorage.getItem("completeFormData"));
setFormData(storedFormData);
}, []);

if (!formData) {
return <div>Loading...</div>;
}

const chartTypes = ["bar", "line", "pie", "doughnut"];

const chartComponents = {
bar: Bar,
line: Line,
pie: Pie,
doughnut: Doughnut,
};

const ChartComponent = chartComponents[selectedChart];

const getChartData = (data, labels, title) => ({
labels,
datasets: [
{
label: title,
data,
backgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56",
"#4BC0C0",
"#9966FF",
"#FF9F40",
"#FF6384",
"#36A2EB",
"#FFCE56",
"#4BC0C0",
],
borderColor: "rgba(75, 192, 192, 1)",
borderWidth: 1,
},
],
});

const chartOptions = {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
},
},
};

const charts = [
{
title: "Constitution",
data: getChartData(
Object.values(formData.constitution).map((v) => (v ? 1 : 0)),
Object.keys(formData.constitution),
"Constitution"
),
},
{
title: "Industry Classification",
data: getChartData(
Object.values(formData.industryClassification).map((v) => (v ? 1 : 0)),
Object.keys(formData.industryClassification),
"Industry Classification"
),
},
{
title: "Annual Turnover",
data: getChartData(
Object.values(formData.annualTurnover).map((v) => parseFloat(v) || 0),
Object.keys(formData.annualTurnover),
"Annual Turnover"
),
},
{
title: "Employment Details",
data: getChartData(
Object.values(formData.employmentDetails).map((v) => parseInt(v) || 0),
Object.keys(formData.employmentDetails),
"Employment Details"
),
},
{
title: "Market Catering",
data: getChartData(
[
formData.marketCatering.domestic ? 1 : 0,
formData.marketCatering.global ? 1 : 0,
formData.marketCatering.both ? 1 : 0,
parseFloat(formData.marketCatering.percentExports) || 0,
parseFloat(formData.marketCatering.percentImports) || 0,
],
["Domestic", "Global", "Both", "% Exports", "% Imports"],
"Market Catering"
),
},
{
title: "Welfare Obligations",
data: getChartData(
Object.values(formData.welfareObligations).map(
(v) => parseFloat(v) || 0
),
Object.keys(formData.welfareObligations),
"Welfare Obligations"
),
},
];

return (
<div className="bg-gray-100 p-6">
<h1 className="flex items-center justify-center font-bold text-4xl mb-10">
Dashboard
</h1>
<div className="mb-4">
<label htmlFor="chartType" className="mr-2">
Select Chart Type:
</label>
<select
id="chartType"
value={selectedChart}
onChange={(e) => setSelectedChart(e.target.value)}
className="p-2 border rounded"
>
{chartTypes.map((type) => (
<option key={type} value={type}>
{type.charAt(0).toUpperCase() + type.slice(1)}
</option>
))}
</select>
</div>
<div className="grid grid-cols-2 gap-6">
{charts.map((chart, index) => (
<div key={index} className="bg-white rounded-lg shadow-md p-4">
<h3 className="text-lg font-semibold mb-4">{chart.title}</h3>
<div className="h-64">
<ChartComponent data={chart.data} options={chartOptions} />
</div>
</div>
))}
</div>
</div>
);
};

export default Dashboard;
3 changes: 2 additions & 1 deletion src/Pages/Admin/Home.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { useNavigate } from "react-router-dom";
import "../../index.css";
import Navbar from "./Navbar";
function Home() {
const navigate = useNavigate();

Expand All @@ -10,7 +11,7 @@ function Home() {

return (
<div>
{/* <Navbar className="z-10" /> */}
<Navbar />
<div className=" z-0 overflow-x-hidden bg-slate-900 h-screen relative pt-40 pb-20 lg:pt-44">
<div className="relative xl:container m-auto px-6 md:px-12 lg:px-6">
<div className="w-10 h-10 bg-transparent border-4 border-blue-600 animate-spin1"></div>
Expand Down
71 changes: 71 additions & 0 deletions src/Pages/Admin/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from "react";
import icci from "../../Assets/icci.jpg";
const Navbar = () => {
return (
<nav class="bg-white border-gray-200 dark:bg-gray-900">
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
<a
href="https://iccicbe.com/"
class="flex items-center space-x-3 rtl:space-x-reverse"
>
<img src={icci} class="h-16" alt="Flowbite Logo" />
</a>
<button
data-collapse-toggle="navbar-default"
type="button"
class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600"
aria-controls="navbar-default"
aria-expanded="false"
>
<span class="sr-only">Open main menu</span>
<svg
class="w-5 h-5"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 17 14"
>
<path
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M1 1h15M1 7h15M1 13h15"
/>
</svg>
</button>
<div class="hidden w-full md:block md:w-auto" id="navbar-default">
<ul class="font-medium flex flex-col p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:flex-row md:space-x-8 rtl:space-x-reverse md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
<li>
<a
href="/admin"
class="block py-2 px-3 text-white bg-blue-700 rounded md:bg-transparent md:text-blue-700 md:p-0 dark:text-white md:dark:text-blue-500"
aria-current="page"
>
Home
</a>
</li>
<li>
<a
href="/table"
class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent"
>
Admin
</a>
</li>
<li>
<a
href="/analysis"
class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent"
>
Analysis
</a>
</li>
</ul>
</div>
</div>
</nav>
);
};

export default Navbar;
Loading

0 comments on commit 2141d58

Please sign in to comment.