Skip to content

Commit 56ce0e3

Browse files
committed
Make bar graph
1 parent ce78218 commit 56ce0e3

File tree

2 files changed

+112
-138
lines changed

2 files changed

+112
-138
lines changed

app/routes/user/$userId.tsx

+29-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LoaderFunction, useLoaderData } from "remix";
2-
import { ChartProvider, LineSeries, Tooltip, XAxis, YAxis } from "rough-charts";
2+
import { BarSeries, ChartProvider, Tooltip, XAxis, YAxis } from "rough-charts";
33
import { ArticleProcessedData } from "~/types/articleProcessedData";
44
import { mockResponse } from "../../mocks/mock-response";
55
import { Article } from "../../types/articleData";
@@ -35,43 +35,36 @@ export default function JokeRoute() {
3535

3636
return (
3737
<div>
38-
<h1 className="text-center py-4 text-2xl mb-4 font-semibold">
38+
<h1 className="text-center py-4 underline decoration-cyan-300 text-2xl mb-4 font-semibold">
3939
Dev.to Wrapped 2021
4040
</h1>
41-
<div className="text-xl">
42-
{`You have written a total of ${stats.totalArticles} articles in 2021`}
43-
</div>
44-
<div className="text-xl ">
45-
{`You have written more articles in the month of ${articleProcessedData.monthHighArticles}`}
41+
<div className="border-solid rounded-lg my-8 p-8 shadow-lg shadow-lime-100/50 bg-lime-100 flex flex-row justify-between">
42+
<div className="text-xl underline decoration-sky-500 decoration-2">
43+
{`You have written a total of ${stats.totalArticles} articles in 2021`}
44+
</div>
45+
<div className="text-xl underline decoration-pink-500 decoration-2">
46+
{`You have written more articles in the month of ${articleProcessedData.monthHighArticles}`}
47+
</div>
4648
</div>
49+
4750
<div className="flex flex-row justify-between">
48-
<p>Total Views: {stats.totalViews}</p>
49-
<p>Total Reactions: {stats.totalReactions}</p>
50-
<p>Total Comments: {stats.totalComments}</p>
51-
<p>Total Reading Time: {stats.totalReadingTime}</p>
51+
<StatsContainer title={`Total Views: ${stats.totalViews}`} />
52+
<StatsContainer title={`Total Comments: ${stats.totalComments}`} />
53+
<StatsContainer title={`Total Reactions: ${stats.totalReactions}`} />
54+
<StatsContainer title={`Total Articles: ${stats.totalArticles}`} />
55+
<StatsContainer
56+
title={`Total Reading time: ${stats.totalReadingTime} min`}
57+
/>
5258
</div>
5359

5460
<div className="my-2 flex flex-col">
5561
<div className="my-4">
5662
<ChartProvider
5763
data={articleProcessedData.monthWiseGraphData}
58-
height={400}
59-
>
60-
<XAxis dataKey="month" />
61-
<LineSeries dataKey="articles" />
62-
<YAxis dataKey="articles" format={(count) => `${count}`} />
63-
<Tooltip>
64-
{({ month, articles }) => `Articles in ${month}: ${articles}`}
65-
</Tooltip>
66-
</ChartProvider>
67-
</div>
68-
<div className="my-4">
69-
<ChartProvider
70-
data={articleProcessedData.monthWiseGraphData}
71-
height={400}
64+
height={300}
7265
>
7366
<XAxis dataKey="month" />
74-
<LineSeries dataKey="articles" />
67+
<BarSeries dataKey="articles" />
7568
<YAxis dataKey="articles" format={(count) => `${count}`} />
7669
<Tooltip>
7770
{({ month, articles }) => `Articles in ${month}: ${articles}`}
@@ -82,3 +75,13 @@ export default function JokeRoute() {
8275
</div>
8376
);
8477
}
78+
interface StatsContainerProps {
79+
title: string;
80+
}
81+
const StatsContainer: React.FC<StatsContainerProps> = ({ title }) => {
82+
return (
83+
<div className="border-solid rounded-lg bg-lime-200 shadow-lime-200/50 p-8">
84+
{title}
85+
</div>
86+
);
87+
};

0 commit comments

Comments
 (0)