Skip to content

Commit fc1d6e6

Browse files
committed
offset overlapping line labels in history plots #39
1 parent 23a5c7a commit fc1d6e6

File tree

3 files changed

+69
-7
lines changed

3 files changed

+69
-7
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: dashboard
22
Title: What the Package Does (One Line, Title Case)
3-
Version: 0.2.2.058
3+
Version: 0.2.2.059
44
Authors@R:
55
person(given = "First",
66
family = "Last",

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"name": "dashboard: What the Package Does (One Line, Title Case)",
77
"codeRepository": "https://github.com/ropensci-review-tools/dashboard",
88
"license": "https://spdx.org/licenses/MIT",
9-
"version": "0.2.2.058",
9+
"version": "0.2.2.059",
1010
"programmingLanguage": {
1111
"@type": "ComputerLanguage",
1212
"name": "R",

quarto/history.qmd

+67-5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ submissions_stats$type <- "stats"
7070
submissions_stats$lty <- 1L
7171
7272
submissions <- rbind (submissions_all, submissions_gen, submissions_stats)
73+
submissions$yshift <- 0
74+
submissions$yshift [which (submissions$type == "all")] <- 20
7375
```
7476

7577
```{r ojs-in-submissions, echo = FALSE}
@@ -103,6 +105,13 @@ viewof submissionYear = Inputs.range(
103105
submissionsFiltered = {
104106
return submissions.filter(d => d.submissionYear >= submissionYear);
105107
}
108+
// These next two are needed to offset label placement for "all":
109+
submissionsFilteredAll = {
110+
return submissions.filter(d => d.type === "all");
111+
}
112+
submissionsFilteredOther = {
113+
return submissions.filter(d => d.type !== "all");
114+
}
106115
```
107116

108117
```{ojs}
@@ -125,15 +134,27 @@ Plot.plot({
125134
fontSize: 18
126135
}
127136
),
128-
Plot.text(
129-
submissionsFiltered,
137+
Plot.text( // Label for "all" with dy: -20
138+
submissionsFilteredAll,
130139
Plot.selectLast({
131140
x: "date",
132141
y: "submissions",
133142
z: "type",
134143
text: "type",
135144
textAnchor: "start",
136-
dx: 3,
145+
dy: -20,
146+
fontSize: 18
147+
})
148+
),
149+
Plot.text( // Labels for others
150+
submissionsFilteredOther,
151+
Plot.selectLast({
152+
x: "date",
153+
y: "submissions",
154+
z: "type",
155+
text: "type",
156+
textAnchor: "start",
157+
dy: 0,
137158
fontSize: 18
138159
})
139160
),
@@ -439,6 +460,14 @@ revDurFiltered = {
439460
}
440461
441462
maxRev = 1.05 * Math.max(...revDurFiltered.map(d => d.type === "all" && d.dur));
463+
464+
// These next two are needed to offset label placement for "all":
465+
revDurFilteredAll = {
466+
return revDurFiltered.filter(d => d.type === "all");
467+
}
468+
revDurFilteredOther = {
469+
return revDurFiltered.filter(d => d.type !== "all");
470+
}
442471
```
443472

444473
```{ojs}
@@ -464,7 +493,20 @@ Plot.plot({
464493
}
465494
),
466495
Plot.text(
467-
revDurFiltered,
496+
revDurFilteredAll,
497+
Plot.selectLast({
498+
x: "date",
499+
y: "dur",
500+
z: "type",
501+
text: "type",
502+
textAnchor: "start",
503+
dx: 4,
504+
dy: -20,
505+
fontSize: 18
506+
})
507+
),
508+
Plot.text(
509+
revDurFilteredOther,
468510
Plot.selectLast({
469511
x: "date",
470512
y: "dur",
@@ -615,6 +657,13 @@ revHoursFiltered = {
615657
}
616658
617659
maxHours = 1.05 * Math.max(...revHoursFiltered.map(d => d.type === "all" && d.hours));
660+
// These next two are needed to offset label placement for "all":
661+
revHoursFilteredAll = {
662+
return revHoursFiltered.filter(d => d.type === "all");
663+
}
664+
revHoursFilteredOther = {
665+
return revHoursFiltered.filter(d => d.type !== "all");
666+
}
618667
```
619668

620669
```{ojs}
@@ -640,7 +689,20 @@ Plot.plot({
640689
}
641690
),
642691
Plot.text(
643-
revHoursFiltered,
692+
revHoursFilteredAll,
693+
Plot.selectLast({
694+
x: "date",
695+
y: "hours",
696+
z: "type",
697+
text: "type",
698+
textAnchor: "start",
699+
dx: 4,
700+
dy: -20,
701+
fontSize: 18
702+
})
703+
),
704+
Plot.text(
705+
revHoursFilteredOther,
644706
Plot.selectLast({
645707
x: "date",
646708
y: "hours",

0 commit comments

Comments
 (0)