From c1b42b0ef7e6d02b074cb5f0d4c8131bdc9661d7 Mon Sep 17 00:00:00 2001 From: Cadence Banulis Date: Fri, 8 Nov 2024 13:14:40 +0100 Subject: [PATCH] refactor: rename BreakdownChart to OriginChart (#7384) --- ...downChart.stories.ts => OriginChart.stories.ts} | 4 ++-- .../charts/{BreakdownChart.tsx => OriginChart.tsx} | 14 +++++--------- ...BreakdownChartData.ts => useOriginChartData.ts} | 2 +- .../features/panels/zone/AreaGraphContainer.tsx | 4 ++-- 4 files changed, 10 insertions(+), 14 deletions(-) rename web/src/features/charts/{BreakdownChart.stories.ts => OriginChart.stories.ts} (99%) rename web/src/features/charts/{BreakdownChart.tsx => OriginChart.tsx} (93%) rename web/src/features/charts/hooks/{useBreakdownChartData.ts => useOriginChartData.ts} (99%) diff --git a/web/src/features/charts/BreakdownChart.stories.ts b/web/src/features/charts/OriginChart.stories.ts similarity index 99% rename from web/src/features/charts/BreakdownChart.stories.ts rename to web/src/features/charts/OriginChart.stories.ts index d382f6b1c8..34ae71a595 100644 --- a/web/src/features/charts/BreakdownChart.stories.ts +++ b/web/src/features/charts/OriginChart.stories.ts @@ -6,10 +6,10 @@ import { colors } from '../../hooks/colors'; import { getCo2ColorScale } from '../../hooks/theme'; import { TimeAverages } from '../../utils/constants'; import AreaGraph from './elements/AreaGraph'; -import { getLayerFill } from './hooks/useBreakdownChartData'; +import { getLayerFill } from './hooks/useOriginChartData'; const meta: Meta = { - title: 'charts/BreakdownChart', + title: 'charts/OriginChart', component: AreaGraph, }; diff --git a/web/src/features/charts/BreakdownChart.tsx b/web/src/features/charts/OriginChart.tsx similarity index 93% rename from web/src/features/charts/BreakdownChart.tsx rename to web/src/features/charts/OriginChart.tsx index 9c864676bb..2326477eda 100644 --- a/web/src/features/charts/BreakdownChart.tsx +++ b/web/src/features/charts/OriginChart.tsx @@ -10,25 +10,21 @@ import { isConsumptionAtom, isHourlyAtom } from 'utils/state/atoms'; import { ChartTitle } from './ChartTitle'; import AreaGraph from './elements/AreaGraph'; import { getBadgeTextAndIcon, getGenerationTypeKey, noop } from './graphUtils'; -import useBreakdownChartData from './hooks/useBreakdownChartData'; +import useOriginChartData from './hooks/useOriginChartData'; import { NotEnoughDataMessage } from './NotEnoughDataMessage'; import ProductionSourceLegendList from './ProductionSourceLegendList'; import { RoundedCard } from './RoundedCard'; import BreakdownChartTooltip from './tooltips/BreakdownChartTooltip'; import { AreaGraphElement } from './types'; -interface BreakdownChartProps { +interface OriginChartProps { displayByEmissions: boolean; datetimes: Date[]; timeAverage: TimeAverages; } -function BreakdownChart({ - displayByEmissions, - datetimes, - timeAverage, -}: BreakdownChartProps) { - const { data } = useBreakdownChartData(); +function OriginChart({ displayByEmissions, datetimes, timeAverage }: OriginChartProps) { + const { data } = useOriginChartData(); const isConsumption = useAtomValue(isConsumptionAtom); const { t } = useTranslation(); const isHourly = useAtomValue(isHourlyAtom); @@ -105,7 +101,7 @@ function BreakdownChart({ ); } -export default BreakdownChart; +export default OriginChart; function getProductionSourcesInChart(chartData: AreaGraphElement[]) { const productionSources = new Set(); diff --git a/web/src/features/charts/hooks/useBreakdownChartData.ts b/web/src/features/charts/hooks/useOriginChartData.ts similarity index 99% rename from web/src/features/charts/hooks/useBreakdownChartData.ts rename to web/src/features/charts/hooks/useOriginChartData.ts index 0a2a5657d9..769bec5c91 100644 --- a/web/src/features/charts/hooks/useBreakdownChartData.ts +++ b/web/src/features/charts/hooks/useOriginChartData.ts @@ -38,7 +38,7 @@ export const getLayerFill = co2ColorScale(d.data.meta.exchangeCo2Intensities?.[key]); }; -export default function useBreakdownChartData() { +export default function useOriginChartData() { const { data: zoneData, isLoading, isError } = useGetZone(); const co2ColorScale = useCo2ColorScale(); const { zoneId } = useParams(); diff --git a/web/src/features/panels/zone/AreaGraphContainer.tsx b/web/src/features/panels/zone/AreaGraphContainer.tsx index 1ecc4a1640..c39cc81fe8 100644 --- a/web/src/features/panels/zone/AreaGraphContainer.tsx +++ b/web/src/features/panels/zone/AreaGraphContainer.tsx @@ -1,8 +1,8 @@ import { HorizontalDivider } from 'components/Divider'; -import BreakdownChart from 'features/charts/BreakdownChart'; import CarbonChart from 'features/charts/CarbonChart'; import EmissionChart from 'features/charts/EmissionChart'; import NetExchangeChart from 'features/charts/NetExchangeChart'; +import OriginChart from 'features/charts/OriginChart'; import PriceChart from 'features/charts/PriceChart'; import { TimeAverages } from 'utils/constants'; @@ -22,7 +22,7 @@ export default function AreaGraphContainer({ ) : ( )} -