Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit752070b

Browse files
refactor(site): use bar chart for DAUs (#9127)
1 parentff9252c commit752070b

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

‎site/src/components/DAUChart/DAUChart.tsx

Lines changed: 19 additions & 9 deletions
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
importdayjsfrom"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.fontFamilyasstring
5553
defaults.color=theme.palette.text.secondary
5654

57-
constoptions:ChartOptions<"line">={
55+
constoptions:ChartOptions<"bar">={
5856
responsive:true,
5957
plugins:{
6058
legend:{
6159
display:false,
6260
},
61+
tooltip:{
62+
displayColors:false,
63+
callbacks:{
64+
title:(context)=>{
65+
constdate=newDate(context[0].parsed.x)
66+
returndate.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)

[8]ページ先頭

©2009-2025 Movatter.jp