File tree 1 file changed +19
-9
lines changed
site/src/components/DAUChart
1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change 9
9
defaults ,
10
10
Legend ,
11
11
LinearScale ,
12
- LineElement ,
13
- PointElement ,
12
+ BarElement ,
14
13
TimeScale ,
15
14
Title ,
16
15
Tooltip ,
@@ -23,14 +22,13 @@ import {
23
22
} from "components/Tooltips/HelpTooltip"
24
23
import dayjs from "dayjs"
25
24
import { FC } from "react"
26
- import { Line } from "react-chartjs-2"
25
+ import { Bar } from "react-chartjs-2"
27
26
28
27
ChartJS . register (
29
28
CategoryScale ,
30
29
LinearScale ,
31
30
TimeScale ,
32
- PointElement ,
33
- LineElement ,
31
+ BarElement ,
34
32
Title ,
35
33
Tooltip ,
36
34
Legend ,
@@ -54,12 +52,21 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
54
52
defaults . font . family = theme . typography . fontFamily as string
55
53
defaults . color = theme . palette . text . secondary
56
54
57
- const options : ChartOptions < "line " > = {
55
+ const options : ChartOptions < "bar " > = {
58
56
responsive : true ,
59
57
plugins : {
60
58
legend : {
61
59
display : false ,
62
60
} ,
61
+ tooltip : {
62
+ displayColors : false ,
63
+ callbacks : {
64
+ title : ( context ) => {
65
+ const date = new Date ( context [ 0 ] . parsed . x )
66
+ return date . toLocaleDateString ( )
67
+ } ,
68
+ } ,
69
+ } ,
63
70
} ,
64
71
scales : {
65
72
y : {
@@ -70,7 +77,7 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
70
77
} ,
71
78
x : {
72
79
ticks : {
73
- stepSize : 2 ,
80
+ stepSize : daus . entries . length > 10 ? 2 : undefined ,
74
81
} ,
75
82
type : "time" ,
76
83
time : {
@@ -82,17 +89,20 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
82
89
}
83
90
84
91
return (
85
- < Line
92
+ < Bar
86
93
data-chromatic = "ignore"
87
94
data = { {
88
95
labels : labels ,
89
96
datasets : [
90
97
{
91
98
label : "Daily Active Users" ,
92
99
data : data ,
93
- tension : 1 / 4 ,
94
100
backgroundColor : theme . palette . secondary . dark ,
95
101
borderColor : theme . palette . secondary . dark ,
102
+ barThickness : 8 ,
103
+ borderWidth : 2 ,
104
+ borderRadius : Number . MAX_VALUE ,
105
+ borderSkipped : false ,
96
106
} ,
97
107
] ,
98
108
} }
You can’t perform that action at this time.
0 commit comments