2023-05-15 05:52:06 +00:00
|
|
|
// ui
|
|
|
|
import { LineGraph } from "components/ui";
|
|
|
|
// types
|
|
|
|
import { IDefaultAnalyticsResponse } from "types";
|
|
|
|
// constants
|
|
|
|
import { MONTHS_LIST } from "constants/calendar";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
defaultAnalytics: IDefaultAnalyticsResponse;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AnalyticsYearWiseIssues: React.FC<Props> = ({ defaultAnalytics }) => {
|
|
|
|
const currentMonth = new Date().getMonth();
|
|
|
|
const startMonth = Math.floor(currentMonth / 3) * 3 + 1;
|
|
|
|
const quarterMonthsList = [startMonth, startMonth + 1, startMonth + 2];
|
|
|
|
|
|
|
|
return (
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="py-3 border border-custom-border-200 rounded-[10px]">
|
2023-05-15 05:52:06 +00:00
|
|
|
<h1 className="px-3 text-base font-medium">Issues closed in a year</h1>
|
2023-05-17 07:55:58 +00:00
|
|
|
{defaultAnalytics.issue_completed_month_wise.length > 0 ? (
|
|
|
|
<LineGraph
|
|
|
|
data={[
|
|
|
|
{
|
|
|
|
id: "issues_closed",
|
2023-07-10 06:55:32 +00:00
|
|
|
color: "rgb(var(--color-primary-100))",
|
2023-05-17 07:55:58 +00:00
|
|
|
data: MONTHS_LIST.map((month) => ({
|
|
|
|
x: month.label.substring(0, 3),
|
|
|
|
y:
|
|
|
|
defaultAnalytics.issue_completed_month_wise.find(
|
|
|
|
(data) => data.month === month.value
|
|
|
|
)?.count || 0,
|
|
|
|
})),
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
customYAxisTickValues={defaultAnalytics.issue_completed_month_wise.map((data) => {
|
|
|
|
if (quarterMonthsList.includes(data.month)) return data.count;
|
2023-05-15 05:52:06 +00:00
|
|
|
|
2023-05-17 07:55:58 +00:00
|
|
|
return 0;
|
|
|
|
})}
|
|
|
|
height="300px"
|
|
|
|
colors={(datum) => datum.color}
|
|
|
|
curve="monotoneX"
|
|
|
|
margin={{ top: 20 }}
|
2023-06-26 08:56:38 +00:00
|
|
|
enableSlices="x"
|
|
|
|
sliceTooltip={(datum) => (
|
2023-07-17 10:58:23 +00:00
|
|
|
<div className="rounded-md border border-custom-border-200 bg-custom-background-80 p-2 text-xs">
|
2023-06-26 08:56:38 +00:00
|
|
|
{datum.slice.points[0].data.yFormatted}
|
2023-07-10 07:17:00 +00:00
|
|
|
<span className="text-custom-text-200"> issues closed in </span>
|
2023-06-26 08:56:38 +00:00
|
|
|
{datum.slice.points[0].data.xFormatted}
|
|
|
|
</div>
|
|
|
|
)}
|
2023-05-17 07:55:58 +00:00
|
|
|
theme={{
|
2023-07-10 06:55:32 +00:00
|
|
|
background: "rgb(var(--color-background-100))",
|
2023-05-17 07:55:58 +00:00
|
|
|
}}
|
|
|
|
enableArea
|
|
|
|
/>
|
|
|
|
) : (
|
2023-07-10 07:17:00 +00:00
|
|
|
<div className="text-custom-text-200 text-center text-sm py-8">No matching data found.</div>
|
2023-05-17 07:55:58 +00:00
|
|
|
)}
|
2023-05-15 05:52:06 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|