Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 45fa169

Browse files
miroslavstastnylevithomason
authored andcommitted
chore(Perf): Skip undef values in perf charts (#2177)
1 parent 62e0a57 commit 45fa169

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

docs/src/components/ComponentDoc/PerfChart/PerfChart.tsx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,18 @@ const PerfChart: React.FC<PerfChartProps> = ({ perfData, withExtremes }) => {
5151
<LineSeries
5252
{...props}
5353
key={chartName + key}
54-
data={perfData.map(sample => ({
55-
x: sampleToXAxis(sample),
56-
y: _.get(sample, `performance.${chartName}.${data}`, 0),
57-
}))}
58-
{...(index === 0 && {
59-
onNearestX: (d: { x: number }) => {
60-
setNearestX(d.x)
61-
},
62-
})}
54+
data={_.filter(
55+
perfData.map(sample => {
56+
const y = _.get(sample, `performance.${chartName}.${data}`)
57+
if (_.isUndefined(y)) {
58+
return undefined
59+
}
60+
return {
61+
x: sampleToXAxis(sample),
62+
y,
63+
}
64+
}),
65+
)}
6366
/>
6467
))
6568

@@ -149,6 +152,18 @@ const PerfChart: React.FC<PerfChartProps> = ({ perfData, withExtremes }) => {
149152
strokeWidth: '2px',
150153
})}
151154

155+
<LineSeries
156+
opacity={0}
157+
key="vertical-axis-hack"
158+
data={perfData.map(sample => ({
159+
x: sampleToXAxis(sample),
160+
y: 0,
161+
}))}
162+
onNearestX={(d: { x: number }) => {
163+
setNearestX(d.x)
164+
}}
165+
/>
166+
152167
{nearestX && (
153168
<PerfChartTooltip
154169
x={nearestX}

0 commit comments

Comments
 (0)