Skip to content

Commit

Permalink
fixed new house vs depreacited house plot
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele Granello committed Dec 12, 2024
1 parent 228dc29 commit c2908d4
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 9 deletions.
24 changes: 17 additions & 7 deletions app/components/graphs/UpfrontComparisonBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ const chartConfig = {
label: "Land",
color: "hsl(var(--chart-1))",
},
house: {
label: "House",
newHouse: {
label: "NewHouse",
color: "hsl(var(--chart-2))",
},
depreciatedHouse: {
label: "DepreciatedHouse",
color: "hsl(var(--chart-3))",
},
} satisfies ChartConfig;

import React from "react";
Expand All @@ -53,17 +57,17 @@ const UpfrontComparisonBarChart: React.FC<StackedBarChartProps> = ({
{
tenure: "market: purchase",
land: data[0].marketPurchase,
house: data[1].marketPurchase,
newHouse: data[1].marketPurchase,
},
{
tenure: "fairhold: land purchase",
land: data[0].fairholdLandPurchase,
house: data[1].fairholdLandPurchase,
depreciatedHouse: data[2].fairholdLandPurchase,
},
{
tenure: "fairhold: land rent",
land: data[0].fairholdLandRent,
house: data[1].fairholdLandRent,
depreciatedHouse: data[2].fairholdLandRent,
},
];

Expand Down Expand Up @@ -93,9 +97,15 @@ const UpfrontComparisonBarChart: React.FC<StackedBarChartProps> = ({
radius={[0, 0, 4, 4]}
/>
<Bar
dataKey="house"
dataKey="newHouse"
stackId="a"
fill="var(--color-newHouse)"
radius={[4, 4, 0, 0]}
/>
<Bar
dataKey="depreciatedHouse"
stackId="a"
fill="var(--color-house)"
fill="var(--color-depreciatedHouse)"
radius={[4, 4, 0, 0]}
/>
</BarChart>
Expand Down
10 changes: 8 additions & 2 deletions app/components/graphs/UpfrontComparisonWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,23 @@ const UpfrontComparisonWrapper: React.FC<UpfrontComparisonWrapperProps> = ({
const formatData = (household: Household) => {
return [
{
category: "Land price",
category: "LandPrice",
marketPurchase: household.property.landPrice || 0,
fairholdLandPurchase:
household.tenure.fairholdLandPurchase?.discountedLandPrice || 0,
fairholdLandRent: 0,
},
{
category: "House price",
category: "NewHouse price",
marketPurchase:
household.property.averageMarketPrice -
household.property.landPrice || 0,
fairholdLandPurchase: 0,
fairholdLandRent: 0,
},
{
category: "DepreciatedHouse price",
marketPurchase: 0,
fairholdLandPurchase: household.property.depreciatedBuildPrice || 0,
fairholdLandRent: household.property.depreciatedBuildPrice || 0,
},
Expand Down
45 changes: 45 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c2908d4

Please sign in to comment.