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

add 'cumulative' radio button to gitlog plot #52

Merged
merged 4 commits into from
Dec 5, 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: repometrics
Title: Metrics for Your Code Repository
Version: 0.1.2.030
Version: 0.1.2.034
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/repometrics",
"issueTracker": "https://github.com/ropensci-review-tools/repometrics/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.2.030",
"version": "0.1.2.034",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
90 changes: 66 additions & 24 deletions inst/extdata/quarto/contributors.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,21 @@ log_reg <- dplyr::group_by (log, gh_handle) |>
)) |>
dplyr::group_by (gh_handle) |>
dplyr::mutate (
nfiles_changed = cumsum (nfiles_changed),
lines_added = cumsum (lines_added),
lines_removed = cumsum (lines_removed),
ncommits = cumsum (ncommits),
nfiles_changed_cum = cumsum (nfiles_changed),
lines_added_cum = cumsum (lines_added),
lines_removed_cum = cumsum (lines_removed),
ncommits_cum = cumsum (ncommits),
date = as.Date (date)
) |>
dplyr::ungroup ()

log_reg <- tidyr::pivot_longer (
log_reg,
c ("nfiles_changed", "lines_added", "lines_removed", "ncommits")
c (
"nfiles_changed", "lines_added", "lines_removed", "ncommits",
"nfiles_changed_cum", "lines_added_cum", "lines_removed_cum",
"ncommits_cum"
)
)
```

Expand Down Expand Up @@ -112,11 +116,50 @@ viewof varNameGitLog = Inputs.radio(
value: "ncommits"
}
)
```

```{ojs cumulative-checkbox-gitlog}
viewof cumulativeGitLog = Inputs.radio(["true", "false"],
{
value: "true",
label: "Cumulative Values:"
}
)
```

```{ojs log-scale-checkbox-gitlog}
viewof logScaleGitLog = Inputs.radio(["true", "false"],
{
value: "true",
label: "Log Scale:"
}
)
logTypeGitLog = logScaleGitLog === "true" ? "log" : "linear";
```

```{ojs transform-gitlog-data}
varNameGitLogActual = cumulativeGitLog === "true" ? varNameGitLog + "_cum" : varNameGitLog;
logFiltered = log.filter(function(row) {
return varNameGitLog.includes(row.name)
return row.name === varNameGitLogActual;
})

function replaceZeroWithOneLog(data) {
return data.map(row => {
const newRow = { ...row };
if (logTypeGitLog === "log") {
Object.values(newRow).forEach(value => {
if (typeof value === "number" && value === 0) {
newRow.value = 1;
}
});
}
return newRow;
});
}
logFiltered01 = replaceZeroWithOneLog(logFiltered);
```


```{ojs count-contributors}
function getMaxValues(log, varNameGitLog) {
const ctbs = log.map((item) => item.gh_handle);
Expand Down Expand Up @@ -159,20 +202,10 @@ function reduceLogToCtbs(log, maxValues, numContribsGitLog) {
return logReduced;
}
logReduced = reduceLogToCtbs(logFiltered, maxValues, numContribsGitLog);
```

```{ojs log-scale-checkbox-gitlog}
viewof logScaleGitLog = Inputs.radio(["true", "false"],
{
value: "true",
label: "Log Scale:"
}
)
logTypeGitLog = logScaleGitLog === "true" ? "log" : "linear";
logReduced01 = reduceLogToCtbs(logFiltered01, maxValues, numContribsGitLog);
```



```{ojs log-plot}
Plot.plot({
style: `
Expand All @@ -185,7 +218,7 @@ Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(
logReduced,
logReduced01,
{
x: "date",
y: "value",
Expand All @@ -195,7 +228,7 @@ Plot.plot({
},
),
Plot.text(
logReduced,
logReduced01,
Plot.selectLast({
x: "date",
y: "value",
Expand Down Expand Up @@ -310,7 +343,7 @@ viewof varNameIssues = Inputs.radio(
)
```

```{ojs log-scale-checkbox-issues}
```{ojs cumulative-checkbox-issues}
viewof cumulativeIssues = Inputs.radio(["true", "false"],
{
value: "true",
Expand All @@ -320,7 +353,7 @@ viewof cumulativeIssues = Inputs.radio(["true", "false"],
```


```{ojs cumulative-checkbox-issues}
```{ojs log-scale-checkbox-issues}
viewof logScaleIssues = Inputs.radio(["true", "false"],
{
value: "false",
Expand All @@ -329,7 +362,7 @@ viewof logScaleIssues = Inputs.radio(["true", "false"],
)
logTypeIssues = logScaleIssues === "true" ? "log" : "linear";

function replaceZeroWithOne(data) {
function replaceZeroWithOneIssues(data) {
return data.map(row => {
const newRow = { ...row };
if (logTypeIssues === "log") {
Expand All @@ -349,7 +382,7 @@ varNameIssuesActual = cumulativeIssues === "true" ? varNameIssues + "_cum" : var
issueDataFiltered = issueData.filter(function(row) {
return row.name === varNameIssuesActual;
})
issueDataFiltered01 = replaceZeroWithOne(issueDataFiltered);
issueDataFiltered01 = replaceZeroWithOneIssues(issueDataFiltered);
```


Expand All @@ -358,7 +391,7 @@ Plot.plot({
style: `
overflow: visible;
`,
marginLeft: 90,
marginLeft: 80,
marginBottom: 50,
x: { grid: true },
y: { grid: true, type: logTypeIssues },
Expand Down Expand Up @@ -396,6 +429,15 @@ Plot.plot({
labelArrow: false
}
),
Plot.axisY(
{
fontSize: 24,
label: "Value",
labelAnchor: "center",
labelOffset: 75,
ticks: []
}
),
]
})
```
2 changes: 1 addition & 1 deletion inst/extdata/quarto/fn-stats.qmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Git history"
title: "Package stats"
execute:
echo: false
format:
Expand Down