@@ -227,19 +227,36 @@ export const MainGraph = ({
227227 drawLine ( {
228228 svg,
229229 datum : remappedData ,
230- isDefined : ( d ) => d . timeLabel !== null ,
230+ isDefined : ( d ) => d . timeLabel !== null && ! d . isPartial ,
231231 xAccessor : ( _d , index ) => x ( index ) ,
232232 yAccessor : ( d ) => y ( d . value ! ) ,
233- className : mainPathClass
233+ className : classNames ( mainPathClass , roundedPathClass )
234234 } )
235235
236+ const firstPartialIndex = remappedData . findIndex (
237+ ( d ) => d . timeLabel !== null && d . isPartial
238+ )
239+ if ( firstPartialIndex > 1 ) {
240+ const partialPathStartIndex = firstPartialIndex - 1
241+ drawLine ( {
242+ svg,
243+ datum : remappedData ,
244+ isDefined : ( d , index ) =>
245+ d . timeLabel !== null &&
246+ ( ! ! d . isPartial || index === partialPathStartIndex ) ,
247+ xAccessor : ( _d , index ) => x ( index ) ,
248+ yAccessor : ( d ) => y ( d . value ! ) ,
249+ className : classNames ( mainPathClass , dashedPathClass )
250+ } )
251+ }
252+
236253 drawLine ( {
237254 svg,
238255 datum : remappedData ,
239256 isDefined : ( d ) => d . comparisonTimeLabel !== null ,
240257 xAccessor : ( _d , index ) => x ( index ) ,
241258 yAccessor : ( d ) => y ( d . comparisonValue ! ) ,
242- className : comparisonPathClass
259+ className : classNames ( comparisonPathClass , roundedPathClass )
243260 } )
244261
245262 const dot = drawDot ( { svg, className : mainDotClass } )
@@ -283,8 +300,8 @@ export const MainGraph = ({
283300 }
284301 setTooltip ( {
285302 selectedIndex : closestIndexToPointer ,
286- x : xPointer ,
287- y : yPointer
303+ x : Math . floor ( xPointer ) ,
304+ y : Math . floor ( yPointer )
288305 } )
289306 }
290307 } )
@@ -400,16 +417,12 @@ const GraphTooltip = ({
400417 < div
401418 style = { {
402419 left : x ,
403- top : y
420+ top : y ,
421+ transform : `translateY(-100%) translateY(-4px) translateX(${ { right : '0%' , left : '-100%' } [ position ] } ) translateX(${ { right : '4px' , left : '-4px' } [ position ] } )`
404422 } }
405423 className = { classNames (
406424 tooltipWidthClass ,
407- 'absolute bg-gray-800 dark:bg-gray-950 py-3 px-4 rounded-md z-[100] pointer-events-none shadow shadow-gray-200 dark:shadow-gray-850' ,
408- '-translate-y-full' ,
409- {
410- 'translate-x-0' : position === 'right' ,
411- '-translate-x-full' : position === 'left'
412- }
425+ 'absolute bg-gray-800 dark:bg-gray-950 py-3 px-4 rounded-md z-[100] pointer-events-none shadow shadow-gray-200 dark:shadow-gray-850'
413426 ) }
414427 >
415428 < aside className = "text-sm font-normal text-gray-100 flex flex-col gap-1.5" >
@@ -757,9 +770,11 @@ const tickClass = 'fill-gray-500 dark:fill-gray-400 text-xs'
757770const mainDotClass = 'fill-indigo-500 dark:fill-indigo-400'
758771const comparisonDotClass = 'fill-indigo-500/20 dark:fill-indigo-400/20'
759772
760- const sharedPathClass = 'stroke-2'
773+ const sharedPathClass = 'fill-none stroke-2'
761774const mainPathClass = 'stroke-indigo-500 dark:stroke-indigo-400 z-2'
762775const comparisonPathClass = 'stroke-indigo-500/20 dark:stroke-indigo-400/20 z-1'
776+ const roundedPathClass = '[stroke-linecap:round] [stroke-linejoin:round]'
777+ const dashedPathClass = '[stroke-dasharray:3,3]'
763778
764779const METRIC_LABELS = {
765780 visitors : 'Visitors' ,
@@ -822,7 +837,7 @@ const drawAreaUnderLine = ({
822837} : {
823838 svg : SelectedSVG
824839 gradientId : string
825- isDefined : ( d : GraphDatum ) => boolean
840+ isDefined : ( d : GraphDatum , index : number ) => boolean
826841 xAccessor : ( d : GraphDatum , index : number ) => number
827842 y0Accessor : number
828843 y1Accessor : ( d : GraphDatum , index : number ) => number
@@ -853,7 +868,7 @@ const drawLine = ({
853868} : {
854869 svg : SelectedSVG
855870 datum : GraphDatum [ ]
856- isDefined : ( d : GraphDatum ) => boolean
871+ isDefined : ( d : GraphDatum , index : number ) => boolean
857872 xAccessor : ( d : GraphDatum , index : number ) => number
858873 yAccessor : ( d : GraphDatum , index : number ) => number
859874 className ?: string
@@ -866,10 +881,7 @@ const drawLine = ({
866881
867882 svg
868883 . append ( 'path' )
869- . attr ( 'fill' , 'none' )
870884 . attr ( 'class' , classNames ( sharedPathClass , className ) )
871- . attr ( 'stroke-linejoin' , 'round' )
872- . attr ( 'stroke-linecap' , 'round' )
873885 . datum ( datum )
874886 . attr ( 'd' , line )
875887}
0 commit comments