               pairs)
        ~expr-sym)))
 
+(defn- set-legend!
+  [styler
+   {:keys [background-color border-color font padding
+           position series-line-length visible]}]
+  (doto-cond
+   styler
+   background-color (.setLegendBackgroundColor (colors background-color background-color))
+   border-color (.setLegendBorderColor (colors border-color border-color))
+   font (.setLegendFont font)
+   padding (.setLegendPadding (int padding))
+   position (.setLegendPosition (legend-positions position))
+   series-line-length (.setLegendSeriesLineLength (int series-line-length))
+   (not (nil? visible)) (.setLegendVisible visible)))
+
 (defn xy-chart
   "Returns an xy-chart"
-  [{:keys [width height title series]
+  [{:keys [width height title series legend]
     :or {width 640 height 500}}]
   {:pre [series]}
   (let [chart (XYChart. width height)]

   :scatter XYSeries$XYSeriesRenderStyle/Scatter
   :line XYSeries$XYSeriesRenderStyle/Line})

(defmacro ^:private doto-cond
  "Example:
  (doto-cond expr

                             PieChart
                             XYSeries$XYSeriesRenderStyle
                             XChartPanel)
           (org.knowm.xchart.style Styler$LegendPosition)
           (org.knowm.xchart.style.markers Circle
                                           Diamond
                                           None
