Skip to content

Commit

Permalink
memo chart and fix issue with localizing values
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov committed Jul 4, 2024
1 parent 94817b7 commit 35885df
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/ui/BundleTrendChart/BundleTrendChart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { format } from 'date-fns'
import { memo } from 'react'
import {
createContainer,
VictoryAccessibleGroup,
Expand All @@ -9,10 +10,7 @@ import {
VictoryTooltip,
} from 'victory'

import {
formatSizeToString,
localizeBundleSize,
} from 'shared/utils/bundleAnalysis'
import { formatSizeToString } from 'shared/utils/bundleAnalysis'

import './chart.css'
import NoBundleData from './NoBundleData'
Expand Down Expand Up @@ -82,7 +80,11 @@ interface BundleTrendChartProps {
}
}

export function BundleTrendChart({ title, desc, data }: BundleTrendChartProps) {
export const BundleTrendChart = memo(function ({
title,
desc,
data,
}: BundleTrendChartProps) {
return (
<>
<svg data-testid="bundle-trend-chart" style={{ height: 0 }}>
Expand Down Expand Up @@ -211,7 +213,7 @@ export function BundleTrendChart({ title, desc, data }: BundleTrendChartProps) {
y="size"
data={data.measurements.map(({ size, date }) => ({
date,
size: localizeBundleSize(size),
size: size / data.multiplier,
}))}
style={{
data: {
Expand All @@ -225,4 +227,6 @@ export function BundleTrendChart({ title, desc, data }: BundleTrendChartProps) {
</VictoryChart>
</>
)
}
})

BundleTrendChart.displayName = 'BundleTrendChart'

0 comments on commit 35885df

Please sign in to comment.