@@ -3,6 +3,7 @@ import { axisLeft, axisTop } from 'd3-axis'
33import { scaleOrdinal , scaleTime } from 'd3-scale'
44import { timeMonth , timeYear } from 'd3-time'
55import { select } from 'd3-selection'
6+
67import beeswarm from './Beeswarm'
78import type { PinboardLink } from './types'
89
@@ -11,7 +12,7 @@ type Props = {
1112}
1213
1314const DAYS_OF_HISTORY = 365
14- const START_DATE = new Date ( new Date ( ) . getTime ( ) - DAYS_OF_HISTORY * 24 * 3600 * 1000 )
15+ const START_DATE = new Date ( Date . now ( ) - DAYS_OF_HISTORY * 24 * 3600 * 1000 )
1516
1617const CATEGORY_LANES = {
1718 typescript : - 0.3 ,
@@ -25,7 +26,7 @@ const renderTimeline = async (svg: SVGSVGElement, links: Array<PinboardLink>) =>
2526 const { width, height, display } = getComputedStyle ( svg )
2627 if ( display === 'none' ) return // Don't do expensive rendering on mobile (svg is hidden)
2728
28- const [ svgWidth , svgHeight ] = [ parseInt ( width ) , parseInt ( height ) ]
29+ const [ svgWidth , svgHeight ] = [ parseInt ( width , 10 ) , parseInt ( height , 10 ) ]
2930 const margin = { top : 30 , right : 0 , left : 0 , bottom : 10 }
3031 const leavePadding = `translate(${ svgWidth / 2 } , ${ margin . top } )`
3132
@@ -58,8 +59,7 @@ const renderTimeline = async (svg: SVGSVGElement, links: Array<PinboardLink>) =>
5859 . call ( makeAxis ( ) . ticks ( nonZeroMonths ) as any )
5960
6061 // Divide links into tag group "buckets":
61- const getGroupForLink = ( link : PinboardLink ) =>
62- TAGS . find ( ( t ) => link . t && link . t . includes ( t ) ) || 'other'
62+ const getGroupForLink = ( link : PinboardLink ) => TAGS . find ( ( t ) => link ?. t ?. includes ( t ) ) || 'other'
6363
6464 const linkChartData = links . map ( ( l : PinboardLink ) => {
6565 const group = getGroupForLink ( l )
@@ -86,12 +86,13 @@ const LinksTimeline = ({ links }: Props) => {
8686 const timelineRef = useRef < SVGSVGElement | null > ( null )
8787
8888 useEffect ( ( ) => {
89- if ( ! timelineRef || ! links ) return
90- renderTimeline ( timelineRef . current ! , links )
89+ if ( ! timelineRef . current || ! links ) return
90+ renderTimeline ( timelineRef . current , links )
9191 } , [ links ] )
9292
9393 return (
94- < svg ref = { timelineRef } className = "timelineChart" width = "350" height = "1400" >
94+ < svg ref = { timelineRef } className = "timelineChart" width = "350" height = "1000" >
95+ < title > Links Timeline</ title >
9596 < g className = "categoryAxis" > </ g >
9697 < g className = "yearAxis" > </ g >
9798 < g className = "monthAxis" > </ g >
0 commit comments