@@ -15,6 +15,7 @@ export default class HistoryGraph extends React.Component {
15
15
this . state = { } ;
16
16
this . mobileWidth = 0 ;
17
17
this . graphRef = React . createRef ( ) ;
18
+ this . onHandleDataPointClicked = this . onHandleDataPointClicked . bind ( this ) ;
18
19
}
19
20
20
21
componentDidMount ( ) {
@@ -58,6 +59,23 @@ export default class HistoryGraph extends React.Component {
58
59
return 300 ;
59
60
}
60
61
62
+ onHandleDataPointClicked ( ) {
63
+ const { challengeId, href } = this . state ;
64
+ fetch ( `${ config . API . V5 } /challenges?legacyId=${ challengeId } ` )
65
+ . then ( result => result . json ( ) )
66
+ . then ( ( dataResponse ) => {
67
+ if ( dataResponse . length > 0 ) {
68
+ const challenge = dataResponse [ 0 ] ;
69
+ window . location . href = `${ config . URL . CHALLENGES_URL } /${ challenge . id } ` ;
70
+ } else {
71
+ window . location . href = href ;
72
+ }
73
+ } ) . catch ( ( ) => {
74
+ window . location . href = href ;
75
+ } ) ;
76
+ }
77
+
78
+
61
79
draw ( ) {
62
80
const $scope = this ;
63
81
const { history : wrapper , track, subTrack } = this . props ;
@@ -247,6 +265,7 @@ export default class HistoryGraph extends React.Component {
247
265
show : true ,
248
266
left : e . pageX ,
249
267
top : e . pageY ,
268
+ challengeId : d . challengeId ,
250
269
challengeName : d . challengeName ,
251
270
challengeData : moment ( d . ratingDate ) . format ( 'MMM DD, YYYY' ) ,
252
271
rating : d . newRating ,
@@ -259,7 +278,18 @@ export default class HistoryGraph extends React.Component {
259
278
render ( ) {
260
279
return (
261
280
< div styleName = "history-graph" ref = { this . graphRef } >
262
- < ChartTooltip { ...this . state } />
281
+ < ChartTooltip
282
+ { ...this . state }
283
+ onClick = { ( ) => {
284
+ const { track } = this . props ;
285
+ const { href } = this . state ;
286
+ if ( track === 'DATA_SCIENCE' ) {
287
+ this . onHandleDataPointClicked ( ) ;
288
+ } else {
289
+ window . location . href = href ;
290
+ }
291
+ } }
292
+ />
263
293
</ div >
264
294
) ;
265
295
}
0 commit comments