@@ -79,17 +79,56 @@ const BarGraph = props => {
79
79
} ) ;
80
80
81
81
const HorizontalGraph = ( ) => {
82
+ // data.barStack =
83
+ // [{snapshot: 1.0,
84
+ // box1: 5.4,
85
+ // box2: 3.7
86
+ // box3: 2.3
87
+ // box4: 5.9,
88
+ // box5: 3.5
89
+ // box6: 2.9
90
+ // }]
91
+
92
+ // width = 50
93
+ // -xxxxx-xxxxx
82
94
const BarArray = [ ] ;
95
+ // []
96
+ //-----------:: :: 3 4
83
97
let i = 0 ;
98
+ let barWidth = ( xMax / ( Object . keys ( data . barStack [ 0 ] ) . length ) + 5 ) ;
99
+ console . log ( data , '<-- data from snapshot' ) ;
84
100
for ( const [ key , value ] of Object . entries ( data . barStack [ 0 ] ) ) {
85
101
if ( key !== 'snapshotId' && key !== 'route' ) {
86
102
console . log ( `${ key } : ${ value } ` ) ;
87
103
BarArray . push ( < Bar
88
- x = { 10 + 30 * i }
89
- y = { 10 }
104
+ x = { 10 + 10 * i + barWidth * i }
105
+ y = { yMax - value * 25 }
90
106
height = { value * 25 }
91
- width = { 20 }
107
+ key = { key }
108
+ width = { barWidth }
92
109
fill = "rgba(23, 233, 217, .5)"
110
+ onMouseLeave = { ( ) => {
111
+ dispatch (
112
+ onHoverExit ( data . componentData [ key ] . rtid ) ,
113
+ ( tooltipTimeout = window . setTimeout ( ( ) => {
114
+ hideTooltip ( ) ;
115
+ } , 300 ) ) ,
116
+ ) ;
117
+ } }
118
+ // Cursor position in window updates position of the tool tip.
119
+ onMouseMove = { event => {
120
+ console . log ( event , '<-- event from onMouseMove' )
121
+ console . log ( key , '<--key from onMouseMove' ) ;
122
+ dispatch ( onHover ( data . componentData [ key ] . rtid ) ) ;
123
+ if ( tooltipTimeout ) clearTimeout ( tooltipTimeout ) ;
124
+ const top = event . clientY - margin . top - value * 25 ;
125
+ const left = 10 + 10 * i + barWidth * i + barWidth / 2 ;
126
+ showTooltip ( {
127
+ tooltipData : value ,
128
+ tooltipTop : top ,
129
+ tooltipLeft : left ,
130
+ } ) ;
131
+ } }
93
132
/> ) ;
94
133
}
95
134
i ++ ;
@@ -105,11 +144,11 @@ const BarGraph = props => {
105
144
const getSnapshotId = ( d : snapshot ) => {
106
145
//d coming from data.barstack post filtered data
107
146
//Object.keys(data.barStack[0]).map(keys => if ())
108
- console . log ( 'snapshot object here: ' , d ) ;
147
+ console . log ( 'snapshot object here from getSnapshotId : ' , d ) ;
109
148
return d . snapshotId ;
110
149
} ;
111
150
const getComponentKeys = d => {
112
- console . log ( 'snapshot object here: ' , d ) ;
151
+ console . log ( 'snapshot object here from getComponentKeys : ' , d ) ;
113
152
return d . snapshotId ;
114
153
} ;
115
154
const formatSnapshotId = id => `Snapshot ID: ${ id } ` ;
@@ -188,7 +227,10 @@ const BarGraph = props => {
188
227
< select
189
228
labelId = "demo-simple-select-label"
190
229
id = "routes-select"
191
- onChange = { e => setRoute ( e . target . value ) }
230
+ onChange = { e => {
231
+ setSnapshot ( 'All Snapshots' ) ;
232
+ setRoute ( e . target . value ) ;
233
+ } }
192
234
>
193
235
< option >
194
236
All Routes
@@ -205,7 +247,7 @@ const BarGraph = props => {
205
247
< select
206
248
labelId = "demo-simple-select-label"
207
249
id = "routes-select"
208
- onChange = { e => setSnapshot ( e . target . value ) }
250
+ onChange = { e => setSnapshot ( e . target . value ) }
209
251
>
210
252
< option >
211
253
All Snapshots
@@ -238,8 +280,8 @@ const BarGraph = props => {
238
280
strokeOpacity = { 0.1 }
239
281
xOffset = { snapshotIdScale . bandwidth ( ) / 2 }
240
282
/>
283
+ { console . log ( 'this is from the BarStack graph' ) }
241
284
< Group top = { margin . top } left = { margin . left } >
242
-
243
285
{ data . barStack . length > 1 ? (
244
286
< BarStack
245
287
data = { data . barStack }
@@ -251,7 +293,7 @@ const BarGraph = props => {
251
293
>
252
294
{ barStacks => barStacks . map ( barStack => barStack . bars . map ( ( bar , idx ) => {
253
295
console . log ( filteredSnapshots , '<-- filtered snap shots' ) ;
254
- console . log ( data , '<-- data' ) ;
296
+ console . log ( data , '<-- data from barStacks ' ) ;
255
297
console . log ( data . barStack , '<-- data.barstack' ) ;
256
298
console . log ( barStacks , '<--barStacks' ) ;
257
299
console . log ( width , '<-- width' ) ;
@@ -299,9 +341,7 @@ const BarGraph = props => {
299
341
: (
300
342
HorizontalGraph ( )
301
343
)
302
- }
303
-
304
-
344
+ }
305
345
</ Group >
306
346
< AxisLeft
307
347
top = { margin . top }
0 commit comments