Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@LauJensen
Created January 22, 2009 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LauJensen/50711 to your computer and use it in GitHub Desktop.
Save LauJensen/50711 to your computer and use it in GitHub Desktop.
;; Burn down chart, input something like "200 175 160 155 152"
;; This relies on Dejcartes which is out in "Super pre-alpha".
;; Much credit and praise to Chouser for ping-ponging with me on this.
(require '[com.markmfredrickson.dejcartes :as chart])
(import '(org.jfree.chart ChartFrame))
(defn make-window [title chart]
(doto (ChartFrame. title chart)
.pack
(.setVisible true)))
(defn mean-slope
[slope]
(int (/ (- (first slope) (last slope))
(dec (count slope)))))
(defn decreasing
[angle start n]
(take n (iterate #(max 0 (- % angle)) (- start angle))))
(defn same-size [& cols]
(let [size (reduce max (map count cols))]
(apply interleave
(map #(concat % (decreasing (mean-slope %) (last %) (- size (count %)))) cols))))
(defn main
[] ; 124 86 75
(let [dates (into [] (range 1 21)) ;; Change to length of sprint
units (map #(Integer. %) (apply vector
(.split (javax.swing.JOptionPane/showInputDialog "Progress:") " ")))
slope (same-size units dates)]
(make-window "Burn-down chart"
(chart/line "Project 1" "Days" "Units"
(apply array-map (same-size dates units))))))
(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment