         (.text #(gstring/format "Queue time %.1fm" (aget % "queued_time_minutes"))))
 
     ;; legend
-    (add-legend svg plot-info)
+    (add-legend svg)
 
     ;; y-axis
     (-> svg

                                                            (/ (- item-height square-size)
                                                               2)))]
                                             (gstring/format "translate(%s,%s)" tr-x  tr-y)))}))
        right-legend-item (-> svg
                              (.select ".legend-container")
                              (.selectAll ".legend-right")
                              (.data (clj->js right-legend-array))
                              (.enter)
                              (.append "g")
                              (.attr #js {"class" "legend right"
                                          "transform"
                                          (fn [item i]
                                            (let [tr-x (- chart-width (* (inc i) item-width))
                                                  tr-y (- (- item-height
                                                             (/ (- item-height square-size)
                                                                2)))]
                                              (gstring/format "translate(%s,%s)" tr-x  tr-y)))}))]
    ;; left legend
    (-> left-legend-item
        (.append "rect")
        (.attr #js {"width" square-size
                    "height" square-size

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

(def plot-info
  {:width (- (:width svg-info) (:left svg-info) (:right svg-info))
   :height (- (:height svg-info) (:top svg-info) (:bottom svg-info))
   :left-legend-items [{:classname "success"
                        :text "Passed"}
                       {:classname "failed"
                        :text "Failed"}
                       {:classname "canceled"
                        :text "Canceled"}]
   :right-legend-items [{:classname "queue"
                         :text "Queue time"}]
   :legend-info {:square-size 10
                 :item-width 80
                 :item-height 14   ; assume font is 14px
                 :spacing 4}})

(def max-bar-count 60)

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