@@ -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