-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TM-1342] Trees planted graph (#559)
* [TM-1342] start up stacked bar chart * [TM-1342] edit position img * [TM-1342] resize chart for trees planted section * [TM-1342] edit position treeBackground * [TM-1342] edit position treeBackground * [TM-1342] use fixed values for width to keep same dimension for trees planted chart --------- Co-authored-by: Dotty <[email protected]>
- Loading branch information
1 parent
93e7ec5
commit 881bc98
Showing
11 changed files
with
316 additions
and
42 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,38 @@ | ||
import React from "react"; | ||
import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from "recharts"; | ||
|
||
const HorizontalStackedBarChart = ({ data, className }: { data: any; className?: string }) => { | ||
const totalValue = data[0].value; | ||
const enterpriseValue = data[1].value; | ||
const nonProfitValue = data[2].value; | ||
const remainingValue = totalValue - enterpriseValue - nonProfitValue; | ||
|
||
const chartData = [ | ||
{ | ||
nonProfit: nonProfitValue, | ||
enterprise: enterpriseValue, | ||
remaining: remainingValue | ||
} | ||
]; | ||
|
||
return ( | ||
<div className={`absolute inset-0 right-0 ${className}`}> | ||
<ResponsiveContainer width="100%" height="100%"> | ||
<BarChart | ||
layout="vertical" | ||
data={chartData} | ||
margin={{ top: 1, right: 0, left: 0, bottom: 1 }} | ||
barCategoryGap="0%" | ||
> | ||
<XAxis type="number" hide={true} domain={[0, totalValue]} /> | ||
<YAxis type="category" hide={true} /> | ||
<Bar dataKey="nonProfit" stackId="a" fill="#7BBD31" /> | ||
<Bar dataKey="enterprise" stackId="a" fill="#27A9E0" /> | ||
<Bar dataKey="remaining" stackId="a" fill="#DDDDDD" /> | ||
</BarChart> | ||
</ResponsiveContainer> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HorizontalStackedBarChart; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const formatNumberUS = (value: number) => | ||
value ? (value >= 1000000 ? `${(value / 1000000).toFixed(2)}M` : value.toLocaleString("en-US")) : ""; |
Oops, something went wrong.