1
1
/* External dependencies */
2
2
import { Line } from "react-chartjs-2" ;
3
- import { CategoryScale , Chart , LineController , LineElement , LinearScale , PointElement , TimeScale , Colors , Legend } from "chart.js" ;
3
+ import { CategoryScale , Chart , LineController , LineElement , LinearScale , PointElement , TimeScale , Colors , Legend , Tooltip } from "chart.js" ;
4
4
import "chartjs-adapter-moment" ;
5
5
import PropTypes from "prop-types" ;
6
6
import { noop } from "lodash" ;
7
+ import moment from "moment" ;
7
8
8
- Chart . register ( CategoryScale , LineController , LineElement , PointElement , LinearScale , TimeScale , Colors , Legend ) ;
9
+ Chart . register ( CategoryScale , LineController , LineElement , PointElement , LinearScale , TimeScale , Colors , Legend , Tooltip ) ;
9
10
10
11
/**
11
12
* Renders the Wincher ranking history chart.
@@ -26,9 +27,10 @@ export default function WincherRankingHistoryChart( { datasets, isChartShown } )
26
27
y : value ,
27
28
} ) ) ,
28
29
lineTension : 0 ,
29
- pointRadius : 0 ,
30
- pointHoverRadius : 0 ,
30
+ pointRadius : 1 ,
31
+ pointHoverRadius : 4 ,
31
32
borderWidth : 2 ,
33
+ pointHitRadius : 6 ,
32
34
} ) ) ;
33
35
34
36
return (
@@ -50,6 +52,20 @@ export default function WincherRankingHistoryChart( { datasets, isChartShown } )
50
52
} ,
51
53
onClick : noop ,
52
54
} ,
55
+ tooltip : {
56
+ enabled : true ,
57
+ callbacks : {
58
+ title : ( x ) => moment ( x [ 0 ] . raw . x ) . utc ( ) . format ( "YYYY-MM-DD" ) ,
59
+ } ,
60
+ titleAlign : "center" ,
61
+ intersect : false ,
62
+ mode : "point" ,
63
+ position : "nearest" ,
64
+ usePointStyle : true ,
65
+ boxHeight : 7 ,
66
+ boxWidth : 7 ,
67
+ boxPadding : 2 ,
68
+ } ,
53
69
} ,
54
70
scales : {
55
71
x : {
0 commit comments