Skip to content

Commit

Permalink
refactor: rename BreakdownChart to OriginChart (#7384)
Browse files Browse the repository at this point in the history
  • Loading branch information
cadeban authored Nov 8, 2024
1 parent 711c817 commit c1b42b0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof AreaGraph> = {
title: 'charts/BreakdownChart',
title: 'charts/OriginChart',
component: AreaGraph,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -105,7 +101,7 @@ function BreakdownChart({
);
}

export default BreakdownChart;
export default OriginChart;

function getProductionSourcesInChart(chartData: AreaGraphElement[]) {
const productionSources = new Set<ElectricityModeType>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions web/src/features/panels/zone/AreaGraphContainer.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -22,7 +22,7 @@ export default function AreaGraphContainer({
) : (
<CarbonChart datetimes={datetimes} timeAverage={timeAverage} />
)}
<BreakdownChart
<OriginChart
displayByEmissions={displayByEmissions}
datetimes={datetimes}
timeAverage={timeAverage}
Expand Down

0 comments on commit c1b42b0

Please sign in to comment.