 (defn build-graphable [{:keys [outcome]}]
   (#{"success" "failed" "canceled"} outcome))
 
-(defn add-legend [svg {chart-width :width}]
-  (let [left-legend-array [{:classname "success"
-                            :text "Passed"}
-                           {:classname "failed"
-                            :text "Failed"}
-                           {:classname "canceled"
-                            :text "Canceled"}]
-        {:keys [square-size item-width item-height spacing]} {:square-size 10
-                                                              :item-width 80
-                                                              :item-height 14   ; assume font is 14px
-                                                              :spacing 4}
-        right-legend-array [{:classname "queue"
-                             :text "Queue time"}]
-        left-legend-item (-> svg
+(defn add-legend [svg]
+  (let [{:keys [square-size item-width item-height spacing]} (:legend-info plot-info)
+        left-legend-enter (-> svg
                              (.select ".legend-container")
                              (.selectAll ".legend")
-                             (.data (clj->js left-legend-array))
+                             (.data (clj->js (:left-legend-items plot-info)))
                              (.enter)
                              (.append "g")
                              (.attr #js {"class" "legend left"

   :height 180
   :top 30, :right 10, :bottom 10, :left 70})

(defn add-queued-time [build]
  (let [queued-time (max (build/queued-time build) 0)]
    (assoc build :queued_time_millis queued-time)))

        (.text #(gstring/format "Queue time %.1fm" (aget % "queued_time_minutes"))))

    ;; legend
    (add-legend svg)

    ;; y-axis
    (-> svg
