@@ -14,6 +14,8 @@ export const ActivityDotPlot: React.FC<ActivityDisplayComponentProps> = ({tracke
14
14
15
15
const [ state , setState ] = React . useState < SimpleUser [ ] [ ] > ( [ ] ) ;
16
16
17
+ const MIN_HORIZONTAL_RANGE = 20 ;
18
+
17
19
React . useEffect ( ( ) => {
18
20
19
21
const updateCounts = ( notebook : Notebook ) => {
@@ -59,17 +61,17 @@ export const ActivityDotPlot: React.FC<ActivityDisplayComponentProps> = ({tracke
59
61
state . forEach ( ( userArray , cellIndex ) => {
60
62
61
63
userArray . forEach ( ( user , userIndex ) => {
62
- yValues . push ( - cellIndex ) ;
64
+ yValues . push ( - cellIndex - 1 ) ;
63
65
xValues . push ( userIndex + 1 ) ;
64
66
hoverText . push ( `${ user . name } on cell ${ cellIndex } ` ) ;
65
67
} ) ;
66
68
67
69
} ) ;
68
70
69
71
const maxCellIndex = state . length > 0 ? state . length - 1 : 0
70
- const tickvals = Array . from ( Array ( maxCellIndex + 1 ) . keys ( ) ) . map ( index => - index ) ;
71
- const ticktext = Array . from ( Array ( maxCellIndex + 1 ) . keys ( ) ) . map ( index => index . toString ( ) ) ;
72
-
72
+ const tickvals = Array . from ( Array ( maxCellIndex + 2 ) . keys ( ) ) . map ( index => - index ) ;
73
+ const ticktext = Array . from ( Array ( maxCellIndex + 2 ) . keys ( ) ) . map ( index => ( index - 1 ) . toString ( ) ) ;
74
+ const maxXvalue = Math . max ( ... xValues , MIN_HORIZONTAL_RANGE ) ;
73
75
74
76
const data = [ {
75
77
y : yValues ,
@@ -87,12 +89,12 @@ export const ActivityDotPlot: React.FC<ActivityDisplayComponentProps> = ({tracke
87
89
height : 500 ,
88
90
xaxis : {
89
91
title : 'Active users' ,
90
- range : [ 1 , Math . max ( ... xValues ) + 1 ]
92
+ range : [ 0.5 , maxXvalue ]
91
93
} ,
92
94
yaxis : {
93
95
title : 'Cell' ,
94
96
autorange : false ,
95
- range : [ - maxCellIndex , 0 ] ,
97
+ range : [ - maxCellIndex - 1.5 , - 0.5 ] ,
96
98
tickvals : tickvals ,
97
99
ticktext : ticktext
98
100
} ,
0 commit comments