@@ -15,20 +15,32 @@ const ONE_DAY = 24 * 60 * 60 * 1000;
15
15
16
16
export default class DownloadGraph extends Component {
17
17
@service chartjs ;
18
+ @service colorScheme ;
18
19
19
20
@action loadChartJs ( ) {
20
21
waitForPromise ( this . chartjs . loadTask . perform ( ) ) . catch ( ( ) => {
21
22
// Ignore Promise rejections. We'll handle them through the derived state properties.
22
23
} ) ;
23
24
}
24
25
26
+ get fontColor ( ) {
27
+ return this . colorScheme . isDark ? '#ADBABD' : '#666' ;
28
+ }
29
+
30
+ get borderColor ( ) {
31
+ return this . colorScheme . isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)' ;
32
+ }
33
+
25
34
@action createChart ( element ) {
26
35
let Chart = this . chartjs . loadTask . lastSuccessful . value ;
27
36
37
+ let { fontColor : color , borderColor } = this ;
38
+
28
39
this . chart = new Chart ( element , {
29
40
type : 'line' ,
30
41
data : this . data ,
31
42
options : {
43
+ color,
32
44
maintainAspectRatio : false ,
33
45
layout : {
34
46
padding : 10 ,
@@ -37,9 +49,15 @@ export default class DownloadGraph extends Component {
37
49
x : {
38
50
type : 'time' ,
39
51
time : { tooltipFormat : 'MMM d' , unit : 'day' } ,
40
- ticks : { maxTicksLimit : 13 } ,
52
+ ticks : { maxTicksLimit : 13 , color } ,
53
+ grid : { color : borderColor } ,
54
+ } ,
55
+ y : {
56
+ beginAtZero : true ,
57
+ stacked : true ,
58
+ ticks : { precision : 0 , color } ,
59
+ grid : { color : borderColor } ,
41
60
} ,
42
- y : { beginAtZero : true , stacked : true , ticks : { precision : 0 } } ,
43
61
} ,
44
62
interaction : {
45
63
mode : 'index' ,
@@ -50,6 +68,20 @@ export default class DownloadGraph extends Component {
50
68
} ) ;
51
69
}
52
70
71
+ @action updateColorScheme ( ) {
72
+ let { chart } = this ;
73
+
74
+ if ( chart ) {
75
+ let { fontColor, borderColor } = this ;
76
+ chart . options . color = fontColor ;
77
+ chart . options . scales . x . ticks . color = fontColor ;
78
+ chart . options . scales . x . grid . color = borderColor ;
79
+ chart . options . scales . y . ticks . color = fontColor ;
80
+ chart . options . scales . y . grid . color = borderColor ;
81
+ chart . update ( ) ;
82
+ }
83
+ }
84
+
53
85
@action updateChart ( ) {
54
86
let { chart } = this ;
55
87
0 commit comments