@@ -38,13 +38,13 @@ const toolTip = tip.attr('class', 'd3-tip')
38
38
} )
39
39
40
40
function appendLegend ( svg ) {
41
- const legendBoxLength = 10
42
- const legendBoxTextInterval = 15
41
+ const legendBoxLength = 13
42
+ const legendBoxTextInterval = 20
43
43
const legendInterval = 20
44
44
const legendY = - 50
45
45
46
46
const legendLabels = [
47
- [ 'Resources I haven\'t viewed' , notAccessedResourceColor ] ,
47
+ [ 'Resources I haven\'t viewed' , 'url(#notAccessedPattern)' ] ,
48
48
[ 'Resources I\'ve viewed' , accessedResourceColor ]
49
49
]
50
50
@@ -190,7 +190,7 @@ function createResourceAccessChart ({ data, width, height, domElement }) {
190
190
. attr ( 'class' , 'bar' )
191
191
. attr ( 'fill' , d => d . self_access_count > 0
192
192
? accessedResourceColor
193
- : notAccessedResourceColor
193
+ : 'url(#notAccessedPattern)'
194
194
)
195
195
. on ( 'focus' , ( e , d ) => {
196
196
moveBrushOnFocus ( e , d . resource_name )
@@ -210,7 +210,7 @@ function createResourceAccessChart ({ data, width, height, domElement }) {
210
210
. enter ( )
211
211
. append ( 'text' )
212
212
. attr ( 'class' , 'label' )
213
- . attr ( 'x' , d => mainXScale ( d . total_percent ) + 3 + mainMargin . left )
213
+ . attr ( 'x' , d => mainXScale ( d . total_percent ) + 40 + mainMargin . left )
214
214
. attr ( 'y' , d => mainYScale ( d . resource_name ) + mainYScale . bandwidth ( ) / 2 + mainMargin . top )
215
215
. attr ( 'dx' , - 10 )
216
216
. attr ( 'dy' , '.35em' )
@@ -286,7 +286,7 @@ function createResourceAccessChart ({ data, width, height, domElement }) {
286
286
d3 . select ( '.miniGroup' ) . selectAll ( '.bar' )
287
287
. style ( 'fill' , d => d . self_access_count > 0
288
288
? accessedResourceColor
289
- : notAccessedResourceColor
289
+ : 'url(#notAccessedPattern)'
290
290
)
291
291
. style ( 'opacity' , d => selected . includes ( d . resource_name )
292
292
? 1
@@ -393,15 +393,35 @@ function createResourceAccessChart ({ data, width, height, domElement }) {
393
393
. on ( 'mousedown.brush' , brushcenter )
394
394
. on ( 'touchstart.brush' , brushcenter , { passive : true } )
395
395
396
+ const svgDefinitions = svg . append ( 'defs' )
397
+
396
398
// Clips
397
- svg . append ( 'defs' )
399
+ svgDefinitions
398
400
. append ( 'clipPath' )
399
401
. attr ( 'id' , 'clip' )
400
402
. append ( 'rect' )
401
403
. attr ( 'x' , - mainMargin . left )
402
404
. attr ( 'width' , mainWidth + mainMargin . left )
403
405
. attr ( 'height' , mainHeight )
404
406
407
+ // Pattern for not accessed: black stripes on gray background
408
+ svgDefinitions
409
+ . append ( 'pattern' )
410
+ . attr ( 'id' , 'notAccessedPattern' )
411
+ . attr ( 'width' , 10 )
412
+ . attr ( 'height' , 10 )
413
+ . attr ( 'patternUnits' , 'userSpaceOnUse' )
414
+ . attr ( 'patternTransform' , 'rotate(45)' )
415
+ . append ( 'rect' )
416
+ . attr ( 'width' , 10 )
417
+ . attr ( 'height' , 10 )
418
+ . attr ( 'fill' , notAccessedResourceColor )
419
+ svgDefinitions . select ( '#notAccessedPattern' )
420
+ . append ( 'rect' )
421
+ . attr ( 'width' , 2 )
422
+ . attr ( 'height' , 10 )
423
+ . attr ( 'fill' , 'black' )
424
+
405
425
// Inject data
406
426
// Domain
407
427
mainXScale . domain ( [ 0 , d3 . max ( resourceData , d => d . total_percent ) ] )
@@ -445,7 +465,7 @@ function createResourceAccessChart ({ data, width, height, domElement }) {
445
465
. attr ( 'class' , 'bar' )
446
466
. attr ( 'fill' , d => d . self_access_count > 0
447
467
? accessedResourceColor
448
- : notAccessedResourceColor
468
+ : 'url(#notAccessedPattern)'
449
469
)
450
470
451
471
// Add brush to main chart
0 commit comments