From 90c46092f466ee2e88ed35307b2351a708ffdeab Mon Sep 17 00:00:00 2001 From: Nalvazhuthi Date: Wed, 28 May 2025 18:16:58 +0530 Subject: [PATCH] feat: integrate new chart types and update layout in ComparisonResult component --- .../ui/compareVersion/ComparisonResult.tsx | 121 +++++++++++------- app/src/pages/Project.tsx | 3 +- app/src/styles/layout/compareLayout.scss | 70 ++++++---- 3 files changed, 124 insertions(+), 70 deletions(-) diff --git a/app/src/components/ui/compareVersion/ComparisonResult.tsx b/app/src/components/ui/compareVersion/ComparisonResult.tsx index 85d1c6c..0f91a36 100644 --- a/app/src/components/ui/compareVersion/ComparisonResult.tsx +++ b/app/src/components/ui/compareVersion/ComparisonResult.tsx @@ -1,57 +1,89 @@ import React, { useMemo } from "react"; import PerformanceResult from "./result-card/PerformanceResult"; import EnergyUsage from "./result-card/EnergyUsage"; -import { Bar } from "react-chartjs-2"; +import { Bar, Line } from "react-chartjs-2"; const ComparisonResult = () => { - const defaultData = { - labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], - datasets: [ - { - label: "Dataset", - data: [12, 19, 3, 5, 2, 3], - backgroundColor: ["#6f42c1"], - borderColor: "#b392f0", - borderWidth: 1, - }, - ], - }; - - // Memoize Chart Options const options = useMemo( () => ({ responsive: true, maintainAspectRatio: false, plugins: { - title: { - display: true, - }, - legend: { - display: false, - }, + title: { display: false }, + legend: { display: false }, }, scales: { - x: { - display: false, // Hide x-axis - grid: { - display: false, - }, - }, - y: { - display: false, // Hide y-axis - grid: { - display: false, - }, - }, + x: { display: false, grid: { display: false } }, + y: { display: false, grid: { display: false } }, }, }), [] ); + + // Color palette + const purpleDark = "#6a0dad"; + const purpleLight = "#b19cd9"; + + const throughputData = { + labels: ["Layout 1", "Layout 2"], + datasets: [ + { + label: "Throughput (units/hr)", + data: [500, 550], + backgroundColor: [purpleDark, purpleLight], + borderColor: [purpleDark, purpleLight], + borderWidth: 1, + }, + ], + }; + + const cycleTimeData = { + labels: ["Layout 1", "Layout 2"], + datasets: [ + { + label: "Cycle Time (sec)", + data: [110, 110], + backgroundColor: [purpleLight], + borderColor: purpleDark, + borderWidth: 2, + tension: 0.4, + fill: false, + }, + ], + }; + + const downtimeData = { + labels: ["Layout 1", "Layout 2"], + datasets: [ + { + label: "Downtime (mins)", + data: [17, 12], + backgroundColor: [purpleDark, purpleLight], + borderColor: [purpleDark, purpleLight], + borderWidth: 1, + }, + ], + }; + + const scrapRateData = { + labels: ["Layout 1", "Layout 2"], + datasets: [ + { + label: "Scrap Rate (tons)", + data: [2.7, 1.9], + backgroundColor: [purpleDark, purpleLight], + borderColor: [purpleDark, purpleLight], + borderWidth: 1, + }, + ], + }; + return (
Performance Comparison
+

Throughput (units/hr)

@@ -64,8 +96,11 @@ const ComparisonResult = () => {
550/ hr
-
+
+ +
+
Cycle Time
@@ -81,12 +116,16 @@ const ComparisonResult = () => {
Layout 2
110 Sec
- 19.6%1.6% + 1.6%
+
+ +
+
Overall Downtime
@@ -101,10 +140,7 @@ const ComparisonResult = () => {
-
-
-
-
+
@@ -114,16 +150,15 @@ const ComparisonResult = () => {
Layout 1
-
- Total scrap produced by -
+
Total scrap produced by
2.7 ton
- +
+ diff --git a/app/src/pages/Project.tsx b/app/src/pages/Project.tsx index 7369842..2462f94 100644 --- a/app/src/pages/Project.tsx +++ b/app/src/pages/Project.tsx @@ -39,7 +39,6 @@ import RegularDropDown from "../components/ui/inputs/RegularDropDown"; import VersionSaved from "../components/layout/sidebarRight/versionHisory/VersionSaved"; import SimulationPlayer from "../components/ui/simulation/simulationPlayer"; import { useProductStore } from "../store/simulation/useProductStore"; -import ThreadChat from "../components/ui/collaboration/ThreadChat"; import ComparisonResult from "../components/ui/compareVersion/ComparisonResult"; const Project: React.FC = () => { @@ -181,7 +180,7 @@ const Project: React.FC = () => { /> - {true && } + {false && } )} diff --git a/app/src/styles/layout/compareLayout.scss b/app/src/styles/layout/compareLayout.scss index e17f227..078f779 100644 --- a/app/src/styles/layout/compareLayout.scss +++ b/app/src/styles/layout/compareLayout.scss @@ -251,6 +251,7 @@ display: flex; } } + .metric-value { padding-top: 6px; font-size: var(--font-size-xlarge); @@ -286,6 +287,7 @@ top: -57%; left: 220%; } + &::after { content: ""; position: absolute; @@ -297,21 +299,19 @@ background-color: #b7b7c6; // Custom polygon shape (adjust if needed) - clip-path: polygon( - 96% 52%, - 96% 54%, - 45% 53%, - 3% 100%, - 0 100%, - 42% 52% - ); + clip-path: polygon(96% 52%, + 96% 54%, + 45% 53%, + 3% 100%, + 0 100%, + 42% 52%); z-index: 0; // Behind any inner content } } // Optional: content above the shape - > * { + >* { position: relative; z-index: 1; } @@ -319,12 +319,14 @@ &:nth-child(2) { grid-column-start: 1; grid-row-start: 2; + .metric-label { white-space: normal; width: 50px; left: 230%; } } + &:nth-child(3) { grid-row: span 2 / span 2; grid-column-start: 2; @@ -364,21 +366,19 @@ height: 100%; background: var(--background-color, wheat); - clip-path: polygon( - 25% 0%, - 75% 0%, - 100% 50%, - 75% 100%, - 25% 100%, - 0% 50% - ); + clip-path: polygon(25% 0%, + 75% 0%, + 100% 50%, + 75% 100%, + 25% 100%, + 0% 50%); filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.25)); z-index: 0; } // Content stays above the shape - > * { + >* { position: relative; z-index: 1; } @@ -461,6 +461,8 @@ width: 100%; display: flex; justify-content: space-between; + position: relative; + z-index: 10; .layer-wrapper { display: flex; @@ -473,24 +475,29 @@ } .chart { - height: 90%; + height: 60%; + width: 40%; position: absolute; - bottom: 0; - left: 0; + bottom: 10px; + left: 50%; + transform: translate(-50%, 0%); } } .cycle-time-container { + flex-direction: column; + .cycle-main { - display: flex; + // display: flex; justify-content: space-between; height: 100%; .layers-wrapper { - height: 100%; + height: 90%; display: flex; - flex-direction: column; + // flex-direction: column; justify-content: space-between; + padding-top: 6px; .layers { display: flex; @@ -513,9 +520,22 @@ color: #14ca44; } } + + &:nth-child(2) { + justify-content: flex-end; + } } } } + + .chart { + width: 90%; + height: 90%; + position: absolute; + top: 50%; + transform: translate(-50%, -50%); + left: 50%; + } } .overallDowntime-container { @@ -583,4 +603,4 @@ position: relative; } } -} +} \ No newline at end of file