Skip to content

Commit 752070b

Browse files
refactor(site): use bar chart for DAUs (#9127)
1 parent ff9252c commit 752070b

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

site/src/components/DAUChart/DAUChart.tsx

+19-9
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {
99
defaults,
1010
Legend,
1111
LinearScale,
12-
LineElement,
13-
PointElement,
12+
BarElement,
1413
TimeScale,
1514
Title,
1615
Tooltip,
@@ -23,14 +22,13 @@ import {
2322
} from "components/Tooltips/HelpTooltip"
2423
import dayjs from "dayjs"
2524
import { FC } from "react"
26-
import { Line } from "react-chartjs-2"
25+
import { Bar } from "react-chartjs-2"
2726

2827
ChartJS.register(
2928
CategoryScale,
3029
LinearScale,
3130
TimeScale,
32-
PointElement,
33-
LineElement,
31+
BarElement,
3432
Title,
3533
Tooltip,
3634
Legend,
@@ -54,12 +52,21 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
5452
defaults.font.family = theme.typography.fontFamily as string
5553
defaults.color = theme.palette.text.secondary
5654

57-
const options: ChartOptions<"line"> = {
55+
const options: ChartOptions<"bar"> = {
5856
responsive: true,
5957
plugins: {
6058
legend: {
6159
display: false,
6260
},
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+
},
6370
},
6471
scales: {
6572
y: {
@@ -70,7 +77,7 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
7077
},
7178
x: {
7279
ticks: {
73-
stepSize: 2,
80+
stepSize: daus.entries.length > 10 ? 2 : undefined,
7481
},
7582
type: "time",
7683
time: {
@@ -82,17 +89,20 @@ export const DAUChart: FC<DAUChartProps> = ({ daus }) => {
8289
}
8390

8491
return (
85-
<Line
92+
<Bar
8693
data-chromatic="ignore"
8794
data={{
8895
labels: labels,
8996
datasets: [
9097
{
9198
label: "Daily Active Users",
9299
data: data,
93-
tension: 1 / 4,
94100
backgroundColor: theme.palette.secondary.dark,
95101
borderColor: theme.palette.secondary.dark,
102+
barThickness: 8,
103+
borderWidth: 2,
104+
borderRadius: Number.MAX_VALUE,
105+
borderSkipped: false,
96106
},
97107
],
98108
}}

0 commit comments

Comments
 (0)