Skip to content

refactor: Improve DAU chart view #4172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
"axios": "0.26.1",
"can-ndjson-stream": "1.0.2",
"chart.js": "^3.5.0",
"chartjs-adapter-date-fns": "2.0.0",
"cron-parser": "4.6.0",
"cronstrue": "2.11.0",
"date-fns": "2.29.3",
"dayjs": "1.11.4",
"emoji-mart": "^5.2.1",
"eventsourcemock": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/WorkspaceSection/WorkspaceSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface WorkspaceSectionProps {
*/
action?: React.ReactNode
contentsProps?: HTMLProps<HTMLDivElement>
title?: string
title?: string | JSX.Element
}

export const WorkspaceSection: React.FC<React.PropsWithChildren<WorkspaceSectionProps>> = ({
Expand Down
33 changes: 21 additions & 12 deletions site/src/pages/TemplatePage/DAUChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import useTheme from "@material-ui/styles/useTheme"

import { Theme } from "@material-ui/core/styles"
import {
BarElement,
CategoryScale,
Chart as ChartJS,
ChartOptions,
Expand All @@ -11,9 +10,11 @@ import {
LinearScale,
LineElement,
PointElement,
TimeScale,
Title,
Tooltip,
} from "chart.js"
import "chartjs-adapter-date-fns"
import { Stack } from "components/Stack/Stack"
import { HelpTooltip, HelpTooltipText, HelpTooltipTitle } from "components/Tooltips/HelpTooltip"
import { WorkspaceSection } from "components/WorkspaceSection/WorkspaceSection"
Expand All @@ -25,8 +26,8 @@ import * as TypesGen from "../../api/typesGenerated"
ChartJS.register(
CategoryScale,
LinearScale,
TimeScale,
PointElement,
BarElement,
LineElement,
Title,
Tooltip,
Expand Down Expand Up @@ -81,23 +82,31 @@ export const DAUChart: FC<DAUChartProps> = ({ templateDAUs: templateMetricsData
},
x: {
ticks: {},
type: "time",
time: {
unit: "day",
stepSize: 2,
},
},
},
aspectRatio: 10 / 1,
} as ChartOptions

return (
<>
<WorkspaceSection>
<Stack direction="row" spacing={1} alignItems="center">
<h3>{Language.chartTitle}</h3>
<HelpTooltip size="small">
<HelpTooltipTitle>How do we calculate DAUs?</HelpTooltipTitle>
<HelpTooltipText>
We use all workspace connection traffic to calculate DAUs.
</HelpTooltipText>
</HelpTooltip>
</Stack>
<WorkspaceSection
title={
<Stack direction="row" spacing={1} alignItems="center">
{Language.chartTitle}
<HelpTooltip size="small">
<HelpTooltipTitle>How do we calculate DAUs?</HelpTooltipTitle>
<HelpTooltipText>
We use all workspace connection traffic to calculate DAUs.
</HelpTooltipText>
</HelpTooltip>
</Stack>
}
>
<Line
data={{
labels: labels,
Expand Down
10 changes: 10 additions & 0 deletions site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5442,6 +5442,11 @@ chart.js@^3.5.0:
resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-3.9.1.tgz#3abf2c775169c4c71217a107163ac708515924b8"
integrity sha512-Ro2JbLmvg83gXF5F4sniaQ+lTbSv18E+TIf2cOeiH1Iqd2PGFOtem+DUufMZsCJwFE7ywPOpfXFBwRTGq7dh6w==

chartjs-adapter-date-fns@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/chartjs-adapter-date-fns/-/chartjs-adapter-date-fns-2.0.0.tgz#5e53b2f660b993698f936f509c86dddf9ed44c6b"
integrity sha512-rmZINGLe+9IiiEB0kb57vH3UugAtYw33anRiw5kS2Tu87agpetDDoouquycWc9pRsKtQo5j+vLsYHyr8etAvFw==

chokidar@^2.1.8:
version "2.1.8"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917"
Expand Down Expand Up @@ -6243,6 +6248,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"

date-fns@2.29.3:
version "2.29.3"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==

dayjs@1.11.4:
version "1.11.4"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.4.tgz#3b3c10ca378140d8917e06ebc13a4922af4f433e"
Expand Down