1
+ import Box from "@mui/material/Box"
1
2
import { Theme } from "@mui/material/styles"
2
3
import useTheme from "@mui/styles/useTheme"
3
4
import * as TypesGen from "api/typesGenerated"
@@ -15,13 +16,11 @@ import {
15
16
Tooltip ,
16
17
} from "chart.js"
17
18
import "chartjs-adapter-date-fns"
18
- import { Stack } from "components/Stack/Stack"
19
19
import {
20
20
HelpTooltip ,
21
- HelpTooltipText ,
22
21
HelpTooltipTitle ,
22
+ HelpTooltipText ,
23
23
} from "components/Tooltips/HelpTooltip"
24
- import { WorkspaceSection } from "components/WorkspaceSection/WorkspaceSection"
25
24
import dayjs from "dayjs"
26
25
import { FC } from "react"
27
26
import { Line } from "react-chartjs-2"
@@ -40,24 +39,10 @@ ChartJS.register(
40
39
export interface DAUChartProps {
41
40
daus : TypesGen . DAUsResponse
42
41
}
43
- export const Language = {
44
- loadingText : "DAU stats are loading. Check back later." ,
45
- chartTitle : "Daily Active Users" ,
46
- }
47
42
48
43
export const DAUChart : FC < DAUChartProps > = ( { daus } ) => {
49
44
const theme : Theme = useTheme ( )
50
45
51
- if ( daus . entries . length === 0 ) {
52
- return (
53
- // We generate hidden element to prove this path is taken in the test
54
- // and through site inspection.
55
- < div style = { { display : "none" } } >
56
- < p > { Language . loadingText } </ p >
57
- </ div >
58
- )
59
- }
60
-
61
46
const labels = daus . entries . map ( ( val ) => {
62
47
return dayjs ( val . date ) . format ( "YYYY-MM-DD" )
63
48
} )
@@ -92,42 +77,39 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
92
77
} ,
93
78
} ,
94
79
} ,
95
- aspectRatio : 10 / 1 ,
80
+ maintainAspectRatio : false ,
96
81
}
97
82
98
83
return (
99
- < >
100
- < WorkspaceSection
101
- title = {
102
- < Stack direction = "row" spacing = { 1 } alignItems = "center" >
103
- { Language . chartTitle }
104
- < HelpTooltip size = "small" >
105
- < HelpTooltipTitle > How do we calculate DAUs?</ HelpTooltipTitle >
106
- < HelpTooltipText >
107
- We use all workspace connection traffic to calculate DAUs.
108
- </ HelpTooltipText >
109
- </ HelpTooltip >
110
- </ Stack >
111
- }
112
- >
113
- < Line
114
- data-chromatic = "ignore"
115
- data = { {
116
- labels : labels ,
117
- datasets : [
118
- {
119
- label : "Daily Active Users" ,
120
- data : data ,
121
- tension : 1 / 4 ,
122
- backgroundColor : theme . palette . secondary . dark ,
123
- borderColor : theme . palette . secondary . dark ,
124
- } ,
125
- ] ,
126
- } }
127
- options = { options }
128
- height = { 400 }
129
- />
130
- </ WorkspaceSection >
131
- </ >
84
+ < Line
85
+ data-chromatic = "ignore"
86
+ data = { {
87
+ labels : labels ,
88
+ datasets : [
89
+ {
90
+ label : "Daily Active Users" ,
91
+ data : data ,
92
+ tension : 1 / 4 ,
93
+ backgroundColor : theme . palette . secondary . dark ,
94
+ borderColor : theme . palette . secondary . dark ,
95
+ } ,
96
+ ] ,
97
+ } }
98
+ options = { options }
99
+ />
100
+ )
101
+ }
102
+
103
+ export const DAUTitle = ( ) => {
104
+ return (
105
+ < Box sx = { { display : "flex" , alignItems : "center" , gap : 1 } } >
106
+ Daily Active Users
107
+ < HelpTooltip size = "small" >
108
+ < HelpTooltipTitle > How do we calculate DAUs?</ HelpTooltipTitle >
109
+ < HelpTooltipText >
110
+ We use all workspace connection traffic to calculate DAUs.
111
+ </ HelpTooltipText >
112
+ </ HelpTooltip >
113
+ </ Box >
132
114
)
133
115
}
0 commit comments