Skip to content

Commit 308c521

Browse files
committed
chore: remove redundant chart legend code
1 parent 1532e53 commit 308c521

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

src/components/EnergyConsumptionChart.tsx

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
import type { Lang } from "@/lib/types"
2323

2424
import { wrapLabel } from "@/lib/utils/charts"
25-
import { isMobile } from "@/lib/utils/isMobile"
2625
import { isLangRightToLeft } from "@/lib/utils/translations"
2726

2827
// ChartDataLabels required to display y-labels on top of bars
@@ -176,23 +175,9 @@ const EnergyConsumptionChart = () => {
176175
} as any, // casted to avoid TS issue,
177176
color: useColorModeValue("#333333", "#F2F2F2"),
178177
},
179-
// bottom legend styles
178+
// legend styles
180179
legend: {
181-
display: false,
182-
position: "bottom" as any, // casted to avoid TS issue
183-
align: "center" as any, // casted to avoid TS issue
184-
labels: {
185-
textAlign: "center" as any, // casted to avoid TS issue
186-
font: {
187-
weight: "bold",
188-
size: "16px",
189-
} as any, // casted to avoid TS issue
190-
color: useColorModeValue("#333333", "#F2F2F2"),
191-
boxWidth: 0,
192-
boxHeight: 40,
193-
},
194-
rtl: isRtl,
195-
onClick: () => null, // disable onClick data visibility
180+
display: false, // hide chart top legend
196181
},
197182
title: {
198183
display: false, // hide chart title
@@ -228,22 +213,11 @@ const EnergyConsumptionChart = () => {
228213
},
229214
}
230215

231-
// chart custom legend
232-
const chartLegend = wrapLabel(
233-
t("page-what-is-ethereum-energy-consumption-chart-legend"),
234-
isMobile()
235-
? { width: 30 }
236-
: {
237-
width: t("page-what-is-ethereum-energy-consumption-chart-legend")
238-
.length,
239-
}
240-
)
241-
242216
const chartData = {
243217
labels: rawData?.map((item) => wrapLabel(item.name)),
244218
datasets: [
245219
{
246-
label: chartLegend as any, // casted to avoid TS issue
220+
label: undefined, // don't remove, needs some value provided to render properly
247221
data: rawData?.map((item) => item.amount) || [],
248222
},
249223
],

0 commit comments

Comments
 (0)