Skip to content

Commit c39ebaa

Browse files
committed
Update energy consumption estimates [Fixes #10371]
1 parent 22e5c91 commit c39ebaa

File tree

2 files changed

+96
-148
lines changed

2 files changed

+96
-148
lines changed

src/components/EnergyConsumptionChart.tsx

Lines changed: 72 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from "react"
2-
import { Box, Center, useBreakpointValue, useToken } from "@chakra-ui/react"
2+
import { Box, Center, useToken } from "@chakra-ui/react"
33
import {
44
BarChart,
55
Bar,
66
Cell,
77
XAxis,
8+
YAxis,
89
Text,
910
LabelList,
1011
ResponsiveContainer,
@@ -20,12 +21,6 @@ interface ITickProps {
2021
payload: { value: number | string }
2122
}
2223

23-
type Data = Array<{
24-
name: string
25-
amount: number
26-
color: string
27-
}>
28-
2924
const CustomTick: React.FC<ITickProps> = ({ x, y, payload }) => {
3025
const textColor = useToken("colors", "text")
3126

@@ -52,132 +47,82 @@ const EnergyConsumptionChart: React.FC = () => {
5247

5348
const textColor = useToken("colors", "text")
5449

55-
const data = useBreakpointValue<Data>({
56-
base: [
57-
{
58-
name: t("energy-consumption-chart-global-data-centers-label"),
59-
amount: 200,
60-
color: "#FF0000",
61-
},
62-
{
63-
name: t("energy-consumption-chart-btc-pow-label"),
64-
amount: 131,
65-
color: "#F2A900",
66-
},
67-
{
68-
name: t("energy-consumption-chart-eth-pow-label"),
69-
amount: 78,
70-
color: "#C1B6F5",
71-
},
72-
{
73-
name: t("energy-consumption-chart-gaming-us-label"),
74-
amount: 34,
75-
color: "#71BB8A",
76-
},
77-
{
78-
name: t("energy-consumption-chart-eth-pos-label"),
79-
amount: 0.0026,
80-
color: "#C1B6F5",
81-
},
82-
],
83-
sm: [
84-
{
85-
name: t("energy-consumption-chart-global-data-centers-label"),
86-
amount: 200,
87-
color: "#FF0000",
88-
},
89-
{
90-
name: t("energy-consumption-gold-mining-cbeci-label"),
91-
amount: 131,
92-
color: "#F2A900",
93-
},
94-
{
95-
name: t("energy-consumption-chart-btc-pow-label"),
96-
amount: 131,
97-
color: "#D7B14A",
98-
},
99-
{
100-
name: t("energy-consumption-chart-eth-pow-label"),
101-
amount: 78,
102-
color: "#C1B6F5",
103-
},
104-
{
105-
name: t("energy-consumption-chart-netflix-label"),
106-
amount: 0.451,
107-
color: "#E50914",
108-
},
109-
{
110-
name: t("energy-consumption-chart-eth-pos-label"),
111-
amount: 0.0026,
112-
color: "#C1B6F5",
113-
},
114-
],
115-
md: [
116-
{
117-
name: t("energy-consumption-chart-global-data-centers-label"),
118-
amount: 200,
119-
color: "#FF0000",
120-
},
121-
{
122-
name: t("energy-consumption-gold-mining-cbeci-label"),
123-
amount: 131,
124-
color: "#D7B14A",
125-
},
126-
{
127-
name: t("energy-consumption-chart-btc-pow-label"),
128-
amount: 131,
129-
color: "#D7B14A",
130-
},
131-
{
132-
name: t("energy-consumption-chart-eth-pow-label"),
133-
amount: 78,
134-
color: "#C1B6F5",
135-
},
136-
{
137-
name: t("energy-consumption-chart-gaming-us-label"),
138-
amount: 34,
139-
color: "#71BB8A",
140-
},
141-
{
142-
name: t("energy-consumption-chart-netflix-label"),
143-
amount: 0.451,
144-
color: "#E50914",
145-
},
146-
{
147-
name: t("energy-consumption-chart-paypal-label"),
148-
amount: 0.26,
149-
color: "#C1B6F5",
150-
},
151-
{
152-
name: "AirBnB",
153-
amount: 0.02,
154-
color: "#E50914",
155-
},
156-
{
157-
name: t("energy-consumption-chart-eth-pos-label"),
158-
amount: 0.0026,
159-
color: "#C1B6F5",
160-
},
161-
],
162-
})
50+
const data = [
51+
{
52+
name: "Banking system",
53+
amount: 239,
54+
color: "#C1B6F5",
55+
},
56+
{
57+
name: "Global data centers",
58+
amount: 190,
59+
color: "#C1B6F5",
60+
},
61+
{
62+
name: "Bitcoin",
63+
amount: 139,
64+
color: "#C1B6F5",
65+
},
66+
{
67+
name: "Gold mining",
68+
amount: 131,
69+
color: "#C1B6F5",
70+
},
71+
{
72+
name: "Gaming in USA",
73+
amount: 34,
74+
color: "#C1B6F5",
75+
},
76+
{
77+
name: "PoW Ethereum",
78+
amount: 21,
79+
color: "#C1B6F5",
80+
},
81+
{
82+
name: "Google",
83+
amount: 19,
84+
color: "#C1B6F5",
85+
},
86+
{
87+
name: "Netflix",
88+
amount: 0.457,
89+
color: "#C1B6F5",
90+
},
91+
{
92+
name: "PayPal",
93+
amount: 0.26,
94+
color: "#C1B6F5",
95+
},
96+
{
97+
name: "Airbnb",
98+
amount: 0.02,
99+
color: "#C1B6F5",
100+
},
101+
{
102+
name: "PoS Ethereum",
103+
amount: 0.0026,
104+
color: "#C1B6F5",
105+
},
106+
]
163107

164108
return (
165109
<Center w="full">
166110
<Box maxW="500px" w="full">
167-
<ResponsiveContainer height={500}>
111+
<ResponsiveContainer height={550}>
168112
<BarChart
169-
margin={{ top: 30, right: 30, bottom: 30, left: 30 }}
170-
barGap={15}
171-
barSize={38}
113+
margin={{ top: 30, right: 40, bottom: 30, left: 20 }}
172114
data={data}
115+
barGap={20}
116+
barSize={30}
117+
layout={"vertical"}
173118
>
174-
<XAxis
175-
dataKey="name"
176-
tickLine={false}
177-
axisLine={false}
178-
// @ts-ignore
179-
tick={<CustomTick />}
180-
interval={0}
119+
<XAxis type={"number"} orientation={"bottom"} />
120+
<YAxis
121+
type={"category"}
122+
orientation={"left"}
123+
dataKey={"name"}
124+
tick={{ fontSize: 14 }}
125+
width={120}
181126
/>
182127
<Legend
183128
content={
@@ -193,7 +138,7 @@ const EnergyConsumptionChart: React.FC = () => {
193138
isAnimationActive={false}
194139
>
195140
<LabelList
196-
position="top"
141+
position="right"
197142
fill={textColor}
198143
fontSize={14}
199144
offset={10}

0 commit comments

Comments
 (0)