-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract utility and data building functions, tool tip and constants
- Loading branch information
1 parent
0b1ebd9
commit f57e751
Showing
6 changed files
with
302 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
heat-stack/app/components/ui/heat/CaseSummaryComponents/Graphs/HeatLoadGraphToolTip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react' | ||
|
||
/** | ||
* CustomTooltip renders a tooltip for the heat load chart. | ||
* @param {object} props - The props containing data for the tooltip. | ||
* @returns {JSX.Element} - The rendered tooltip element. | ||
*/ | ||
export const HeatLoadGraphToolTip = (props: any): JSX.Element => { | ||
const { payload } = props | ||
const temperature = payload ? payload?.temperature : null | ||
const value = payload ? payload?.value : null | ||
const name = payload ? payload?.name : '' | ||
|
||
if (temperature !== null) { | ||
// Return formatted output, ensuring the temperature is shown in color below the heat load value | ||
return ( | ||
<div className="tooltip-content"> | ||
<div>{`${Number(value).toLocaleString()} BTU/h`}</div> | ||
<div>{`${temperature}°F ${name.replace('Line', ' Heat Load').replace('Point', ' at Design Temperature')}`}</div> | ||
</div> | ||
) | ||
} | ||
|
||
// Fallback in case the temperature is not available | ||
return ( | ||
<div className="tooltip-content"> | ||
<div>{`${Number(value).toLocaleString()} BTU/h`}</div> | ||
<div> | ||
{name | ||
.replace('Line', ' Heat Load') | ||
.replace('Point', ' at Design Temperature')} | ||
</div> | ||
</div> | ||
) | ||
} |
55 changes: 55 additions & 0 deletions
55
heat-stack/app/components/ui/heat/CaseSummaryComponents/HeatLoadGrid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react' | ||
|
||
type HeatLoadGridProps = { | ||
setPoint: number | ||
averageHeatLoad: number | ||
maxHeatLoad: number | ||
} | ||
|
||
/** | ||
* HeatLoadGrid is a stateless functional component that displays key summary data | ||
* in a grid format. The grid includes the set point temperature, maximum heat load, | ||
* and average heat load values. | ||
* | ||
* @component | ||
* @param {ChartGridProps} props - The props for the HeatLoadGrid component. | ||
* @param {number} props.setPoint - The set point temperature in degrees Fahrenheit. | ||
* @param {number} props.averageHeatLoad - The average heat load in BTU/h. | ||
* @param {number} props.maxHeatLoad - The maximum heat load in BTU/h. | ||
* @returns {JSX.Element} - A styled grid displaying the set point, max heat load, and average heat load. | ||
*/ | ||
export const HeatLoadGrid = ({ | ||
setPoint, | ||
averageHeatLoad, | ||
maxHeatLoad, | ||
}: ChartGridProps) => { | ||
return ( | ||
<div className="container mx-auto p-4"> | ||
<div className="grid grid-cols-3 gap-4"> | ||
{/* Grid Item 1 */} | ||
<div className="flex items-center justify-center border-r-2 border-gray-300 p-6"> | ||
<div className="flex flex-col items-center"> | ||
<div className="text-gray-500">Set Point</div> | ||
<div className="font-semibold">{`${setPoint} °F`}</div> | ||
</div> | ||
</div> | ||
|
||
{/* Grid Item 2 */} | ||
<div className="flex items-center justify-center border-r-2 border-gray-300 p-6"> | ||
<div className="flex flex-col items-center"> | ||
<div className="text-gray-500">Max Heat Load</div> | ||
<div className="font-semibold">{`${maxHeatLoad} BTU/h`}</div> | ||
</div> | ||
</div> | ||
|
||
{/* Grid Item 3 */} | ||
<div className="flex items-center justify-center p-6"> | ||
<div className="flex flex-col items-center"> | ||
<div className="text-gray-500">Average Heat Load</div> | ||
<div className="font-semibold">{`${averageHeatLoad} BTU/h`}</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
6 changes: 6 additions & 0 deletions
6
heat-stack/app/components/ui/heat/CaseSummaryComponents/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Constants for chart styling | ||
export const COLOR_ORANGE = '#FF5733' | ||
export const COLOR_BLUE = '#8884d8' | ||
export const COLOR_GREY = '#999999' | ||
export const COLOR_GREY_LIGHT = '#f5f5f5' | ||
export const COLOR_WHITE = '#fff' |
Oops, something went wrong.