Skip to content

Commit ed25f14

Browse files
authored
refactor: use a line graph for DAUChart (coder#9758)
1 parent f85aa44 commit ed25f14

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

site/src/components/DAUChart/DAUChart.tsx

+17-13
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import {
77
Chart as ChartJS,
88
ChartOptions,
99
defaults,
10+
Filler,
1011
Legend,
1112
LinearScale,
12-
BarElement,
13+
LineElement,
1314
TimeScale,
1415
Title,
1516
Tooltip,
17+
PointElement,
1618
} from "chart.js";
1719
import "chartjs-adapter-date-fns";
1820
import {
@@ -22,13 +24,15 @@ import {
2224
} from "components/HelpTooltip/HelpTooltip";
2325
import dayjs from "dayjs";
2426
import { FC } from "react";
25-
import { Bar } from "react-chartjs-2";
27+
import { Line } from "react-chartjs-2";
2628

2729
ChartJS.register(
2830
CategoryScale,
2931
LinearScale,
3032
TimeScale,
31-
BarElement,
33+
LineElement,
34+
PointElement,
35+
Filler,
3236
Title,
3337
Tooltip,
3438
Legend,
@@ -52,7 +56,7 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
5256
defaults.font.family = theme.typography.fontFamily as string;
5357
defaults.color = theme.palette.text.secondary;
5458

55-
const options: ChartOptions<"bar"> = {
59+
const options: ChartOptions<"line"> = {
5660
responsive: true,
5761
plugins: {
5862
legend: {
@@ -70,11 +74,12 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
7074
},
7175
scales: {
7276
y: {
73-
min: 0,
77+
suggestedMin: 0,
7478
ticks: {
7579
precision: 0,
7680
},
7781
},
82+
7883
x: {
7984
ticks: {
8085
stepSize: daus.entries.length > 10 ? 2 : undefined,
@@ -89,20 +94,19 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
8994
};
9095

9196
return (
92-
<Bar
97+
<Line
9398
data-chromatic="ignore"
9499
data={{
95100
labels: labels,
96101
datasets: [
97102
{
98103
label: "Daily Active Users",
99104
data: data,
100-
backgroundColor: theme.palette.secondary.dark,
101-
borderColor: theme.palette.secondary.dark,
102-
barThickness: 8,
103-
borderWidth: 2,
104-
borderRadius: Number.MAX_VALUE,
105-
borderSkipped: false,
105+
pointBackgroundColor: theme.palette.info.light,
106+
pointBorderColor: theme.palette.info.light,
107+
borderColor: theme.palette.info.light,
108+
backgroundColor: theme.palette.info.dark,
109+
fill: "origin",
106110
},
107111
],
108112
}}
@@ -120,7 +124,7 @@ export const DAUTitle = () => {
120124
How do we calculate daily active users?
121125
</HelpTooltipTitle>
122126
<HelpTooltipText>
123-
When a connection is initiated to a user{"'"}s workspace they are
127+
When a connection is initiated to a user&apos;s workspace they are
124128
considered a daily active user. e.g. apps, web terminal, SSH
125129
</HelpTooltipText>
126130
</HelpTooltip>

0 commit comments

Comments
 (0)