From a1120f90f7c343b445897fd5daaa4debfcc16589 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Fri, 12 Jul 2024 03:07:03 -0500 Subject: [PATCH] progress --- Makefile | 2 +- html/ProgressHeader.html | 1 + scripts/build-table | 21 +++++++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 3f0c954..d6df3ee 100644 --- a/Makefile +++ b/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 \ diff --git a/html/ProgressHeader.html b/html/ProgressHeader.html index aed3338..8d6b85a 100644 --- a/html/ProgressHeader.html +++ b/html/ProgressHeader.html @@ -20,6 +20,7 @@ display: flex; flex-direction: column; min-height: 48px; + gap: 2px; align-items: center; justify-content: center; aspect-ratio: 1; diff --git a/scripts/build-table b/scripts/build-table index 686515b..fbe3e70 100755 --- a/scripts/build-table +++ b/scripts/build-table @@ -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 = $"($percent)%" $"
- ($k) / ($n) + ($k) / ($n) + (if ($isExercise) { $percentStr })
" | 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) }