Skip to content

Commit 93022b1

Browse files
Rename chart to IssueReactsByMonth
1 parent 06c57b9 commit 93022b1

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

examples/nextjs-import-airbyte-github-export-seafowl/components/RepositoryAnalytics/Charts.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SqlProvider, makeSeafowlHTTPContext } from "@madatdata/react";
66
import { useMemo } from "react";
77

88
import { StargazersChart } from "./charts/StargazersChart";
9-
import { MonthlyIssueStatsTable } from "./charts/MonthlyIssueStats";
9+
import { IssueReactsByMonth } from "./charts/IssueReactsByMonth";
1010

1111
export interface ChartsProps {
1212
importedRepository: ImportedRepository;
@@ -30,9 +30,9 @@ export const Charts = ({ importedRepository }: ChartsProps) => {
3030
<SqlProvider dataContext={seafowlDataContext}>
3131
<h3>Stargazers</h3>
3232
<StargazersChart {...importedRepository} />
33-
<MonthlyIssueStatsTable {...importedRepository} />
33+
<h3>Issue Reacts by Month</h3>
34+
<IssueReactsByMonth {...importedRepository} />
3435
</SqlProvider>
35-
MonthlyIssueStatsTable
3636
</div>
3737
);
3838
};

examples/nextjs-import-airbyte-github-export-seafowl/components/RepositoryAnalytics/charts/MonthlyIssueStats.tsx renamed to examples/nextjs-import-airbyte-github-export-seafowl/components/RepositoryAnalytics/charts/IssueReactsByMonth.tsx

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ type Reaction =
1717
| "rocket"
1818
| "eyes";
1919

20-
type MappedMonthlyIssueStatsRow = MonthlyIssueStatsRow & {
20+
type MappedIssueReactsByMonthRow = IssueReactsByMonthRow & {
2121
created_at_month: Date;
2222
};
2323

2424
/**
2525
* A stacked bar chart of the number of reactions each month, grouped by reaction type
2626
*/
27-
export const MonthlyIssueStats = ({
27+
export const IssueReactsByMonth = ({
2828
splitgraphNamespace,
2929
splitgraphRepository,
3030
}: ImportedRepository) => {
3131
const renderPlot = useSqlPlot({
3232
sqlParams: { splitgraphNamespace, splitgraphRepository },
3333
buildQuery: monthlyIssueStatsTableQuery,
34-
mapRows: (r: MonthlyIssueStatsRow) => ({
34+
mapRows: (r: IssueReactsByMonthRow) => ({
3535
...r,
3636
created_at_month: new Date(r.created_at_month),
3737
}),
38-
reduceRows: (rows: MappedMonthlyIssueStatsRow[]) => {
38+
reduceRows: (rows: MappedIssueReactsByMonthRow[]) => {
3939
const reactions = new Map<
4040
Reaction,
4141
{ created_at_month: Date; count: number }[]
@@ -89,14 +89,41 @@ export const MonthlyIssueStats = ({
8989
isRenderable: (p) => !!p.splitgraphRepository,
9090

9191
makePlotOptions: (issueStats) => ({
92-
y: { grid: true },
93-
color: { legend: true },
92+
y: { grid: true, label: "Number of Reactions" },
93+
x: {
94+
label: "Month",
95+
},
96+
color: {
97+
legend: true,
98+
label: "Reaction",
99+
tickFormat: (reaction) => {
100+
switch (reaction) {
101+
case "plus_one":
102+
return "👍 plus_one";
103+
case "minus_one":
104+
return "👎 minus_one";
105+
case "laugh":
106+
return "😄 laugh";
107+
case "confused":
108+
return "😕 confused";
109+
case "heart":
110+
return "❤️ heart";
111+
case "hooray":
112+
return "🎉 hooray";
113+
case "rocket":
114+
return "🚀 rocket";
115+
case "eyes":
116+
return "👀 eyes";
117+
}
118+
},
119+
},
94120
marks: [
95121
Plot.rectY(issueStats, {
96122
x: "created_at_month",
97123
y: "count",
98124
interval: "month",
99125
fill: "reaction",
126+
tip: true,
100127
}),
101128
Plot.ruleY([0]),
102129
],
@@ -107,7 +134,7 @@ export const MonthlyIssueStats = ({
107134
};
108135

109136
/** Shape of row returned by {@link monthlyIssueStatsTableQuery} */
110-
export type MonthlyIssueStatsRow = {
137+
export type IssueReactsByMonthRow = {
111138
created_at_month: string;
112139
num_issues: number;
113140
total_reacts: number;

0 commit comments

Comments
 (0)