diff --git a/src/pages/ContentScripts/features/repo-activity-racing-bar/RacingBar.tsx b/src/pages/ContentScripts/features/repo-activity-racing-bar/RacingBar.tsx index b15eb3c8..6ee63a7e 100644 --- a/src/pages/ContentScripts/features/repo-activity-racing-bar/RacingBar.tsx +++ b/src/pages/ContentScripts/features/repo-activity-racing-bar/RacingBar.tsx @@ -3,7 +3,6 @@ import * as echarts from 'echarts'; import type { EChartsOption, EChartsType } from 'echarts'; interface RacingBarProps { - height: number; repoName: string; data: any; } @@ -35,8 +34,8 @@ const option: EChartsOption = { return `${value} {avatar${value.replaceAll('-', '')}|}`; }, }, - animationDuration: 300, - animationDurationUpdate: 300, + animationDuration: 0, + animationDurationUpdate: 200, }, series: [ { @@ -131,9 +130,41 @@ const play = (instance: EChartsType, data: any) => { playNext(); }; -const RacingBar = ({ height, data }: RacingBarProps): JSX.Element => { +/** + * Count the number of unique contributors in the data + */ +const countLongTermContributors = (data: any) => { + const contributors = new Map(); + Object.keys(data).forEach((month) => { + data[month].forEach((item: any[]) => { + if (contributors.has(item[0])) { + contributors.set(item[0], contributors.get(item[0])! + 1); + } else { + contributors.set(item[0], 0); + } + }); + }); + let count = 0; + contributors.forEach((value) => { + // only count contributors who have contributed more than 3 months + if (value >= 3) { + count++; + } + }); + return count; +}; + +const RacingBar = ({ data }: RacingBarProps): JSX.Element => { const divEL = useRef(null); + let height = 300; + const longTermContributorsCount = countLongTermContributors(data); + if (longTermContributorsCount >= 20) { + // @ts-ignore + option.yAxis.max = 20; + height = 600; + } + useEffect(() => { if (!divEL.current) return; diff --git a/src/pages/ContentScripts/features/repo-activity-racing-bar/view.tsx b/src/pages/ContentScripts/features/repo-activity-racing-bar/view.tsx index f4db746f..ce05b43f 100644 --- a/src/pages/ContentScripts/features/repo-activity-racing-bar/view.tsx +++ b/src/pages/ContentScripts/features/repo-activity-racing-bar/view.tsx @@ -51,7 +51,6 @@ const View = ({ currentRepo, repoActivityDetails }: Props): JSX.Element => {