(defn make-chart [groups]
(let [[x-min x-max] (get-bounds (map get-bounds groups))
unit-h 0.3
margin 0.1
amount (count groups)
chart-h (+ (* amount unit-h)
(* (dec amount) margin))]
[:svg {:width "100%"
:view-box (str "0 0 " (inc x-max) " " chart-h)
:style {:margin "2rem 0"}
}
(into [:g]
(map-indexed
(fn [y [[a1 a2] [b1 b2] :as group]]
(into [:g]
(map-indexed
(fn [i [x1 x2]]
[:rect {:x (dec x1)
:y (* y (+ unit-h margin))
:width (inc (- x2 x1))
:height unit-h
:fill (cond
(== i 3) "#ff0076"
(== i 2) "#344a77"
(== i 1) "#253455"
:else "#090c14")}])
(let [overlap (get-intersection group)
bg [1 x-max]]
(if overlap
(concat [bg] group [overlap])
(concat [bg] group))))))
groups))]))