Skip to content

Commit

Permalink
Changed chart type
Browse files Browse the repository at this point in the history
  • Loading branch information
dyzqy committed Jul 3, 2024
1 parent 94c16b9 commit f38e386
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions other/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fetchContributions = async (username) => {
throw new Error('Network response was not ok');
}
const data = await response.json();

// Process the events to count contributions per day
const contributions = {};
data.forEach(event => {
Expand All @@ -21,6 +21,9 @@ const fetchContributions = async (username) => {
contributionCount: contributions[date]
}));

// Sort contributions by date (oldest to newest)
contributionArray.sort((a, b) => new Date(a.date) - new Date(b.date));

return contributionArray;
};

Expand All @@ -33,14 +36,19 @@ const prepareChartData = (contributions) => {
const createChart = (dates, contributions) => {
const ctx = document.getElementById('contributionsChart').getContext('2d');
new Chart(ctx, {
type: 'bar',
type: 'line',
data: {
labels: dates,
datasets: [{
label: 'Contributions',
data: contributions,
backgroundColor: 'rgb(113, 227, 180)',
borderWidth: 0
backgroundColor: 'rgb(113, 227, 180, 0.5)',

fill: true,
borderWidth: 3,
borderColor: 'rgb(113, 227, 180)',
lineTenstion: 0.1

}]
},
options: {
Expand Down

0 comments on commit f38e386

Please sign in to comment.