Skip to content

Commit 5996462

Browse files
authored
Merge pull request #222 from wildan3105/chore/fetch-max-repos-from-config
Chore/fetch max repos from config
2 parents 34c6878 + d511e1e commit 5996462

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

public/js/chart.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* eslint-disable no-useless-escape */
22
/* eslint-disable no-undef */
33
/* eslint-disable no-unused-vars */
4+
const { MAX_REPOS_PER_CHART } = require('../../src/config');
5+
46
const sum = (array) => {
57
if (array.length === 0) {
68
return 0;
@@ -56,7 +58,7 @@ const chart = ({ limit, singleColor }) => {
5658
}
5759
const labels = keys.slice(0, limit);
5860
const data = values.slice(0, limit);
59-
if (keys.length > 20) {
61+
if (keys.length > MAX_REPOS_PER_CHART) {
6062
const valueOthers = sum(values.slice(limit, keys.length));
6163
labels.push('Others');
6264
data.push(valueOthers);
@@ -133,7 +135,7 @@ const chart = ({ limit, singleColor }) => {
133135
const toggleColor = () => {
134136
window.chart.destroy();
135137
// eslint-disable-next-line no-undef
136-
singleColor = chart({ limit: 20, singleColor: !singleColor });
138+
singleColor = chart({ limit: MAX_REPOS_PER_CHART, singleColor: !singleColor });
137139
const btn = document.getElementById('btn-toggle');
138140

139141
btn.classList.toggle('active');

0 commit comments

Comments
 (0)