Skip to content

Commit 1214022

Browse files
Improve DAU chart view (coder#4172)
1 parent 8738755 commit 1214022

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

site/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
"axios": "0.26.1",
4040
"can-ndjson-stream": "1.0.2",
4141
"chart.js": "^3.5.0",
42+
"chartjs-adapter-date-fns": "2.0.0",
4243
"cron-parser": "4.6.0",
4344
"cronstrue": "2.11.0",
45+
"date-fns": "2.29.3",
4446
"dayjs": "1.11.4",
4547
"emoji-mart": "^5.2.1",
4648
"eventsourcemock": "^2.0.0",

site/src/components/WorkspaceSection/WorkspaceSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface WorkspaceSectionProps {
1111
*/
1212
action?: React.ReactNode
1313
contentsProps?: HTMLProps<HTMLDivElement>
14-
title?: string
14+
title?: string | JSX.Element
1515
}
1616

1717
export const WorkspaceSection: React.FC<React.PropsWithChildren<WorkspaceSectionProps>> = ({

site/src/pages/TemplatePage/DAUChart.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import useTheme from "@material-ui/styles/useTheme"
22

33
import { Theme } from "@material-ui/core/styles"
44
import {
5-
BarElement,
65
CategoryScale,
76
Chart as ChartJS,
87
ChartOptions,
@@ -11,9 +10,11 @@ import {
1110
LinearScale,
1211
LineElement,
1312
PointElement,
13+
TimeScale,
1414
Title,
1515
Tooltip,
1616
} from "chart.js"
17+
import "chartjs-adapter-date-fns"
1718
import { Stack } from "components/Stack/Stack"
1819
import { HelpTooltip, HelpTooltipText, HelpTooltipTitle } from "components/Tooltips/HelpTooltip"
1920
import { WorkspaceSection } from "components/WorkspaceSection/WorkspaceSection"
@@ -25,8 +26,8 @@ import * as TypesGen from "../../api/typesGenerated"
2526
ChartJS.register(
2627
CategoryScale,
2728
LinearScale,
29+
TimeScale,
2830
PointElement,
29-
BarElement,
3031
LineElement,
3132
Title,
3233
Tooltip,
@@ -81,23 +82,31 @@ export const DAUChart: FC<DAUChartProps> = ({ templateDAUs: templateMetricsData
8182
},
8283
x: {
8384
ticks: {},
85+
type: "time",
86+
time: {
87+
unit: "day",
88+
stepSize: 2,
89+
},
8490
},
8591
},
8692
aspectRatio: 10 / 1,
8793
} as ChartOptions
8894

8995
return (
9096
<>
91-
<WorkspaceSection>
92-
<Stack direction="row" spacing={1} alignItems="center">
93-
<h3>{Language.chartTitle}</h3>
94-
<HelpTooltip size="small">
95-
<HelpTooltipTitle>How do we calculate DAUs?</HelpTooltipTitle>
96-
<HelpTooltipText>
97-
We use all workspace connection traffic to calculate DAUs.
98-
</HelpTooltipText>
99-
</HelpTooltip>
100-
</Stack>
97+
<WorkspaceSection
98+
title={
99+
<Stack direction="row" spacing={1} alignItems="center">
100+
{Language.chartTitle}
101+
<HelpTooltip size="small">
102+
<HelpTooltipTitle>How do we calculate DAUs?</HelpTooltipTitle>
103+
<HelpTooltipText>
104+
We use all workspace connection traffic to calculate DAUs.
105+
</HelpTooltipText>
106+
</HelpTooltip>
107+
</Stack>
108+
}
109+
>
101110
<Line
102111
data={{
103112
labels: labels,

site/yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5442,6 +5442,11 @@ chart.js@^3.5.0:
54425442
resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-3.9.1.tgz#3abf2c775169c4c71217a107163ac708515924b8"
54435443
integrity sha512-Ro2JbLmvg83gXF5F4sniaQ+lTbSv18E+TIf2cOeiH1Iqd2PGFOtem+DUufMZsCJwFE7ywPOpfXFBwRTGq7dh6w==
54445444

5445+
chartjs-adapter-date-fns@2.0.0:
5446+
version "2.0.0"
5447+
resolved "https://registry.yarnpkg.com/chartjs-adapter-date-fns/-/chartjs-adapter-date-fns-2.0.0.tgz#5e53b2f660b993698f936f509c86dddf9ed44c6b"
5448+
integrity sha512-rmZINGLe+9IiiEB0kb57vH3UugAtYw33anRiw5kS2Tu87agpetDDoouquycWc9pRsKtQo5j+vLsYHyr8etAvFw==
5449+
54455450
chokidar@^2.1.8:
54465451
version "2.1.8"
54475452
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917"
@@ -6243,6 +6248,11 @@ data-urls@^2.0.0:
62436248
whatwg-mimetype "^2.3.0"
62446249
whatwg-url "^8.0.0"
62456250

6251+
date-fns@2.29.3:
6252+
version "2.29.3"
6253+
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
6254+
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==
6255+
62466256
dayjs@1.11.4:
62476257
version "1.11.4"
62486258
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.4.tgz#3b3c10ca378140d8917e06ebc13a4922af4f433e"

0 commit comments

Comments
 (0)