fix: scope and demand line graph y axis values (#1563)

This commit is contained in:
Aaryan Khandelwal 2023-07-19 13:13:23 +05:30 committed by GitHub
parent 5e1f0a2604
commit c71a2137e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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