add scribble view for plot lol

This commit is contained in:
xenia 2020-12-04 23:59:00 -05:00
parent 5365272e27
commit 06ab477340
3 changed files with 99 additions and 96 deletions

View File

@ -1,9 +1,10 @@
#!/usr/bin/env racket
#lang racket
(require "aoc-lib.rkt" plot)
(plot-new-window? #t)
(require "aoc-lib.rkt" plot/no-gui)
(provide make-plot)
(define (make-plot plot-func)
(define data
(aoc-fetch-leaderboard (getenv "AOC_YEAR") (getenv "AOC_LEADERBOARD") (getenv "AOC_SESSION")))
@ -41,23 +42,6 @@
(hash-update! timeline time (lambda (v) (cons (tl-entry mid day level) v)) '())])))
(define timestamps (sort (hash-keys timeline) <))
;; vector of day to vector of part to ordered list of solvers
; (define chals (for/vector ([day (in-range 1 26)]) (make-vector 2 '())))
;
; (for ([time (in-list timestamps)])
; (for ([solve (in-list (hash-ref timeline time))])
; (match-define (tl-entry mid day level) solve)
; (define old (vector-ref (vector-ref chals (sub1 day)) (sub1 level)))
; (vector-set! (vector-ref chals (sub1 day)) (sub1 level) (append old (list mid)))))
;
; (define (total-points mem)
; ;; day 1 is worth no points u___u
; (for*/sum ([day (in-range 2 26)] [level (in-range 1 3)])
; (define solves-for-day (vector-ref (vector-ref chals (sub1 day)) (sub1 level)))
; (match (index-of solves-for-day mem)
; [#f 0]
; [x (- max-pts x)])))
; (total-points 1067937)
(define point-values (make-hash))
(for* ([day (in-range 1 26)] [level (in-range 1 3)])
@ -101,7 +85,8 @@
(sort (hash-keys point-tls)
(lambda (a b)
(>= (get-last-pts (hash-ref point-tls a)) (get-last-pts (hash-ref point-tls b))))))
(plot (for/list ([mid (in-list ordered-mids)])
(plot-func
(for/list ([mid (in-list ordered-mids)])
(lines (hash-ref point-tls mid)
#:label (format "~a (~a pts)" (hash-ref member-names mid)
(get-last-pts (hash-ref point-tls mid)))
@ -109,4 +94,9 @@
#:style mid
#:width 2))
#:x-label "date/time"
#:y-label "points")
#:y-label "points"))
(module+ main
(require plot)
(plot-new-window? #t)
(make-plot plot))

3
scripts/plot.css Normal file
View File

@ -0,0 +1,3 @@
html, body { background: black; color: white; font-family: monospace; }
h1, h2, h3, p { font-family: monospace; }

10
scripts/plot.scrbl Normal file
View File

@ -0,0 +1,10 @@
#lang scribble/base
@(require plot/no-gui racket "plot")
@title[#:style '(toc-hidden no-sidebar no-index no-toc+aux)]{BLÁHAJ score chart}
meow
@(parameterize ([plot-width 2048] [plot-height 1024])
(make-plot plot-pict))