@@ -132,7 +132,7 @@ export default function TreeMap({
132132 height,
133133 isHomePageDesktopView,
134134 minimumBarHeight,
135- openSearchPage = ( ) => { } ,
135+ searchPageURL ,
136136 categoriesColors,
137137 allCategories,
138138 // function prop received from ChartDownloader that binds the svg element to allow
@@ -289,51 +289,60 @@ export default function TreeMap({
289289 />
290290 < AnimatedDataset
291291 dataset = { datasetStackedByCategory }
292- tag = "rect"
293- init = { {
294- opacity : 0 ,
295- [ chartWidthDimension ] : chartWidthPaddingBefore ,
296- [ chartLengthDimension ] : isMobile ? chartLength - chartLengthPaddingAfter : 0 ,
297- [ chartWidthTitle ] : chartWidth - ( chartWidthPaddingBefore + chartWidthPaddingAfter ) ,
298- [ chartLengthTitle ] : 0 ,
299- } }
292+ tag = "a"
300293 attrs = { {
301- opacity : 1 ,
302- [ chartWidthDimension ] : chartWidthPaddingBefore ,
303- [ chartLengthDimension ] : ( d ) => chartLength - lengthScale ( d . startingPoint ) ,
304- [ chartWidthTitle ] : chartWidth - ( chartWidthPaddingBefore + chartWidthPaddingAfter ) ,
305- [ chartLengthTitle ] : ( d ) => computeBarHeight ( d . startingPoint , d . endPoint ) ,
306- fill : ( d ) =>
307- hoveredElement === d . category || hoveredElement === null
308- ? d . numberOfIncidents === 0
309- ? 'white'
310- : findColor ( d . category )
311- : 'white' ,
312- stroke : ( d ) => ( hoveredElement === d . category ? findColor ( d . category ) : 'black' ) ,
313- strokeWidth : isHomePageDesktopView ? borderWidth . normal : borderWidth . mobile ,
314- cursor : 'pointer' ,
315- pointerEvents : ( d ) => ( d . numberOfIncidents === 0 ? 'none' : null ) ,
316- shapeRendering : 'crispEdges' ,
294+ href : d => searchPageURL ( d . category ) ,
295+ role : "link" ,
296+ ariaLabel : d => d . category ,
317297 } }
318- events = { {
319- // In a future, if we update our version of d3-selection the first
320- // argument will be a MouseEvent, eliminating the need for d3event here
321- onMouseMove : ( ) => {
322- updateTooltipPosition ( d3event )
323- } ,
324- onMouseLeave : ( ) => {
325- setTooltipPosition ( { x : 0 , y : 0 } )
326- setHoveredElement ( null )
327- } ,
328- // In a future, if we update our version of d3-selection this may
329- // need to be updated to take arguments (MouseEvent, d) instead
330- onMouseEnter : d => setHoveredElement ( d . category ) ,
331- onMouseUp : d => openSearchPage ( d . category ) ,
332- } }
333- durationByAttr = { { fill : 0 , stroke : 0 } }
334298 keyFn = { ( d ) => d . category }
335- duration = { 250 }
336- />
299+ >
300+ < AnimatedDataset
301+ tag = "rect"
302+ init = { {
303+ opacity : 0 ,
304+ [ chartWidthDimension ] : chartWidthPaddingBefore ,
305+ [ chartLengthDimension ] : isMobile ? chartLength - chartLengthPaddingAfter : 0 ,
306+ [ chartWidthTitle ] : chartWidth - ( chartWidthPaddingBefore + chartWidthPaddingAfter ) ,
307+ [ chartLengthTitle ] : 0 ,
308+ } }
309+ attrs = { {
310+ opacity : 1 ,
311+ [ chartWidthDimension ] : chartWidthPaddingBefore ,
312+ [ chartLengthDimension ] : ( d ) => chartLength - lengthScale ( d . startingPoint ) ,
313+ [ chartWidthTitle ] : chartWidth - ( chartWidthPaddingBefore + chartWidthPaddingAfter ) ,
314+ [ chartLengthTitle ] : ( d ) => computeBarHeight ( d . startingPoint , d . endPoint ) ,
315+ fill : ( d ) =>
316+ hoveredElement === d . category || hoveredElement === null
317+ ? d . numberOfIncidents === 0
318+ ? 'white'
319+ : findColor ( d . category )
320+ : 'white' ,
321+ stroke : ( d ) => ( hoveredElement === d . category ? findColor ( d . category ) : 'black' ) ,
322+ strokeWidth : isHomePageDesktopView ? borderWidth . normal : borderWidth . mobile ,
323+ cursor : 'pointer' ,
324+ pointerEvents : ( d ) => ( d . numberOfIncidents === 0 ? 'none' : null ) ,
325+ shapeRendering : 'crispEdges' ,
326+ } }
327+ events = { {
328+ // In a future, if we update our version of d3-selection the first
329+ // argument will be a MouseEvent, eliminating the need for d3event here
330+ onMouseMove : ( ) => {
331+ updateTooltipPosition ( d3event )
332+ } ,
333+ onMouseLeave : ( ) => {
334+ setTooltipPosition ( { x : 0 , y : 0 } )
335+ setHoveredElement ( null )
336+ } ,
337+ // In a future, if we update our version of d3-selection this may
338+ // need to be updated to take arguments (MouseEvent, d) instead
339+ onMouseEnter : d => setHoveredElement ( d . category ) ,
340+ } }
341+ durationByAttr = { { fill : 0 , stroke : 0 } }
342+ keyFn = { ( d ) => d . category }
343+ duration = { 250 }
344+ />
345+ </ AnimatedDataset >
337346 < AnimatedDataset
338347 dataset = { datasetStackedByCategory }
339348 tag = "line"
0 commit comments