@@ -21,7 +21,7 @@ import { DoubleCircleIcon } from "../../common/icons/DoubleCircleIcon";
2121import { DurationChange , isChangeMeaningfulEnough } from "../DurationChange" ;
2222import { InsightCard } from "../InsightCard" ;
2323import { Description } from "../styles" ;
24- import { HistogramBarData , Trace } from "../types" ;
24+ import { HistogramBarData , NormalizedHistogramBarData , Trace } from "../types" ;
2525import { ReferenceLineLabel } from "./ReferenceLineLabel" ;
2626import { XAxisTick } from "./XAxisTick" ;
2727import { DIVIDER } from "./constants" ;
@@ -31,6 +31,8 @@ import { DurationInsightProps, TickData } from "./types";
3131const LAST_CALL_TIME_DISTANCE_LIMIT = 60 * 1000 ; // in milliseconds
3232
3333// in pixels
34+ const MIN_BAR_HEIGHT = 5 ;
35+ const MAX_BAR_HEIGHT = 80 ;
3436const BAR_WIDTH = 5 ;
3537const MIN_X_AXIS_PADDING = 80 ;
3638const MIN_CHART_CONTAINER_HEIGHT = 120 ;
@@ -268,6 +270,17 @@ export const DurationInsight = (props: DurationInsightProps) => {
268270 chartContainerHeight += CHART_Y_MARGIN * 2 ;
269271 }
270272
273+ const maxCount = Math . max ( ...notEmptyBars . map ( ( x ) => x . count ) ) ;
274+ const normalizedChartData : NormalizedHistogramBarData [ ] = chartData . map (
275+ ( x ) => ( {
276+ ...x ,
277+ normalizedCount :
278+ x . count > 0
279+ ? Math . max ( ( maxCount / MAX_BAR_HEIGHT ) * MIN_BAR_HEIGHT , x . count )
280+ : 0
281+ } )
282+ ) ;
283+
271284 return (
272285 < InsightCard
273286 data = { props . insight }
@@ -358,14 +371,14 @@ export const DurationInsight = (props: DurationInsightProps) => {
358371 left : 0
359372 } }
360373 barSize = { BAR_WIDTH }
361- data = { chartData }
374+ data = { normalizedChartData }
362375 >
363376 < Bar
364- dataKey = { "count " }
377+ dataKey = { "normalizedCount " }
365378 radius = { BAR_WIDTH / 2 }
366379 isAnimationActive = { false }
367380 >
368- { chartData . map ( ( entry , index ) => (
381+ { normalizedChartData . map ( ( entry , index ) => (
369382 < Cell
370383 key = { `cell-${ index } ` }
371384 fill = { getBarColor ( entry . end , p50 , p95 ) }
0 commit comments