-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added abatement potencial and total cost chart columns
- Loading branch information
Showing
6 changed files
with
152 additions
and
19 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
client/src/components/ui/bar-chart/single-stacked-bar-chart/index.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,39 @@ | ||
import { FC } from "react"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
||
interface SingleStackedBarChartProps { | ||
total: Segment; | ||
segments: Segment[]; | ||
} | ||
interface Segment { | ||
id: string; | ||
value: number; | ||
colorClass: string; | ||
} | ||
|
||
const getSize = (value: number, total: number) => { | ||
const percentage = (value / total) * 100; | ||
return `${Math.max(percentage, 0)}%`; | ||
}; | ||
|
||
const SingleStackedBarChart: FC<SingleStackedBarChartProps> = ({ | ||
total, | ||
segments, | ||
}) => { | ||
return ( | ||
<div className={cn("flex h-2 w-full", total.colorClass)}> | ||
{segments.map((s) => ( | ||
<div | ||
key={s.id} | ||
className={s.colorClass} | ||
style={{ | ||
width: getSize(s.value, total.value), | ||
}} | ||
></div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default SingleStackedBarChart; |
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
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
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
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
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