progress
This commit is contained in:
parent
76613a032b
commit
a1120f90f7
3 changed files with 15 additions and 9 deletions
2
Makefile
2
Makefile
|
@ -18,7 +18,7 @@ build-to-html:
|
|||
.PHONY: html/src/generated/Progress.md
|
||||
|
||||
html/src/generated/Progress.md:
|
||||
nu scripts/build-table > /dev/null
|
||||
nu scripts/build-table
|
||||
|
||||
html/book/Progress.html: html/src/generated/Progress.md
|
||||
pandoc \
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 48px;
|
||||
gap: 2px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
aspect-ratio: 1;
|
||||
|
|
|
@ -10,9 +10,9 @@ let chapters = {
|
|||
}
|
||||
|
||||
let gradients = [
|
||||
[0, [90, 0, 0]],
|
||||
[0, [60, 0, 0]],
|
||||
[0.65, [180, 180, 0]],
|
||||
[1, [0, 90, 0]],
|
||||
[1, [0, 120, 0]],
|
||||
]
|
||||
|
||||
let formatColor = {|color| $"rgb\(($color.0), ($color.1), ($color.2)\)" }
|
||||
|
@ -31,17 +31,20 @@ let interpColor = {|p|
|
|||
do $formatColor $color
|
||||
}
|
||||
|
||||
let viz = { |k, n|
|
||||
let ratio = ($k / $n) | math round --precision 1
|
||||
# let color = if n == 0 { "gray" } else if $ratio < 0.25 { "red" } else if $ratio < 0.5 { "orange"} else if $ratio < 0.75 { "yellow"} else { "green" }
|
||||
let color = if $n == 0 { "gray" } else { do $interpColor ($k / $n) }
|
||||
let viz = { |k, n, cell|
|
||||
let ratio = $k / $n
|
||||
let percent = $ratio * 100 | math round --precision 1
|
||||
let color = if $n == 0 { "gray" } else { do $interpColor $ratio }
|
||||
let textColor = if $k == $n { "gold" } else { "white" }
|
||||
let isExercise = $cell.0.section == "Exercise"
|
||||
let percentStr = $"<small style=\"font-size: 0.7rem\">($percent)%</small>"
|
||||
|
||||
$"<div class=\"cell\" style=\"
|
||||
background-color: ($color);
|
||||
color: ($textColor);
|
||||
\">
|
||||
($k) / ($n)
|
||||
<span>($k) / ($n)</span>
|
||||
(if ($isExercise) { $percentStr })
|
||||
</div>" | str replace -a "\n" ""
|
||||
# $n | math round --precision 1
|
||||
}
|
||||
|
@ -80,7 +83,9 @@ let vizChapter = { |n|
|
|||
let table2 = $table
|
||||
| group-by section
|
||||
| transpose
|
||||
| each { $in | update column1 { do $viz ($in | where completed == "x" | length) ($in | length) } }
|
||||
| each { $in | update column1 {
|
||||
do $viz ($in | where completed == "x" | length) ($in | length) $in
|
||||
} }
|
||||
| sort-by -n column0
|
||||
|
||||
let newColumn1 = { column0: "Ch", column1: (do $vizCh $n $table) }
|
||||
|
|
Loading…
Reference in a new issue