Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve charts #12

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,9 @@ pyrightconfig.json
.DS_Store

data
clean_input/
coerce_input/
compressed_raw_input/
node_input/
raw_input/
node-metrics/charts/
30 changes: 28 additions & 2 deletions node-metrics/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"dependencies": {
"canvas": "^2.11.2",
"chart.js": "^4.4.4",
"chartjs-adapter-date-fns": "^3.0.0",
"fs": "^0.0.1-security",
"nodejs-polars": "^0.15.0",
"open": "^10.1.0"
Expand All @@ -10,7 +11,6 @@
"version": "1.0.0",
"description": "polars examples",
"main": "node_metrics.js",
"devDependencies": {},
"scripts": {
"start": "node src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
152 changes: 131 additions & 21 deletions node-metrics/src/visualizer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {createChart} from './createChart.js'
import 'chartjs-adapter-date-fns'; // Import the date adapter

export const createActiveContributorsChart = async (labels, data, filePath) => {
const configuration = {
Expand All @@ -8,14 +9,54 @@ export const createActiveContributorsChart = async (labels, data, filePath) => {
datasets: [{
label: 'Contributions Count',
data: data,
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(31, 87, 159, 0.2)', // blue-ish color
borderColor: 'rgba(31, 87, 159, 1)',
borderWidth: 1
}]
},
options: {
scales: {
y: { beginAtZero: true }
x: {
ticks: {
// Rotate labels if necessary
maxRotation: 45,
minRotation: 0,
font: {
size: 18 // Increase font size
}
},
title: {
display: false,
text: 'Contributors',
font: {
size: 18 // Increase font size for x-axis title
}
}
},
y: {
beginAtZero: true,
ticks: {
font: {
size: 18 // Increase font size for Y-axis
}
}
}
},
plugins: {
legend: {
labels: {
font: {
size: 18 // Increase font size for legend
}
}
},
title: {
display: true,
text: 'Most Active Contributors',
font: {
size: 24 // Increase title font size
}
}
}
}
};
Expand All @@ -29,10 +70,10 @@ export const createRollingMeanPRsChart = async (labels, data, filePath) => {
data: {
labels: labels, // X-axis: day (dates)
datasets: [{
label: '7-Day Rolling Mean of Pull Requests',
label: '3-Day Rolling Mean of Pull Requests',
data: data, // Y-axis: rolling mean of pull requests
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(27, 105, 53, 0.2)', // green-ish color
borderColor: 'rgba(27, 105, 53, 1)',
borderWidth: 1,
fill: true,
tension: 0.4 // Smoothing line
Expand All @@ -42,11 +83,44 @@ export const createRollingMeanPRsChart = async (labels, data, filePath) => {
scales: {
y: {
beginAtZero: true,
title: { display: true, text: 'Rolling Mean of Pull Requests' }
title: { display: false, text: 'Rolling Mean of Pull Requests' },
ticks: {
font: {
size: 18
}
},
},
x: {
title: { display: true, text: 'Day' }
title: { display: false, text: 'Date' },
type: 'time',
time: {
unit: 'day',
displayFormats: {
day: 'yyyy-MM-dd' // Display format for x-axis
}
},
ticks: {
font: {
size: 18
}
},
}
},
plugins: {
legend: {
labels: {
font: {
size: 18 // Increase font size for legend
}
}
},
title: {
display: true,
text: 'Rolling Mean of Pull Requests',
font: {
size: 24 // Increase title font size
}
}
}
}
};
Expand All @@ -61,30 +135,66 @@ export const createOpenIssuesOverTimeChart = async (labels, data, filePath) => {
datasets: [{
label: 'Open Issues Over Time',
data: data, // Y-axis: open issues count
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(129, 36, 36, 0.2)', // red-ish color
borderColor: 'rgba(129, 36, 36, 1)',
borderWidth: 1,
fill: true, // Optional: fill under the line
tension: 0.4 // Optional: curve the line slightly
}]
},
options: {
scales: {
y: {
beginAtZero: true, // Start Y-axis from 0
title: {
display: true,
text: 'Number of Open Issues'
x: {
type: 'time', // Use time scale for the x-axis
time: {
unit: 'day', // Group data by day
displayFormats: {
day: 'yyyy-MM-dd' // Display format for x-axis
}
},
ticks: {
font: {
size: 18 // Increase font size for x-axis labels
}
},
title: {
display: false,
text: 'Date',
font: {
size: 18 // Increase font size for x-axis title
}
}
},
y: {
beginAtZero: true,
ticks: {
font: {
size: 18 // Increase font size for y-axis labels
}
},
}
},
x: {
},
plugins: {
legend: {
labels: {
font: {
size: 18 // Increase font size for legend
}
}
},
title: {
display: true,
text: 'Time'
display: true,
text: 'Open Issues Over Time',
font: {
size: 24 // Increase title font size
}
},
tooltip: {
titleFont: { size: 14 }, // Increase font size for tooltip titles
bodyFont: { size: 12 } // Increase font size for tooltip body
}
}
}
}
}
};
await createChart(configuration, filePath);
}