                              PieSeries$PieSeriesRenderStyle
                              XYSeries$XYSeriesRenderStyle
                              XChartPanel)
-           (org.knowm.xchart.style Styler$LegendPosition
+           (org.knowm.xchart.style Styler
+                                   Styler$LegendPosition
                                    GGPlot2Theme
                                    MatlabTheme
                                    XChartTheme)

   padding (.setChartPadding (int padding))
   title (set-chart-title-style! title)))

;; TODO: Add in font as a shortcut to set all fonts not yet set.

(defn xy-chart
  "Returns an xy-chart"
  [{:keys [width height title series legend theme render-style chart-style
           annotations-font]
    :or {width 640 height 500}}]
  {:pre [series]}
  (let [chart (XYChart. width height)]
    (doseq [[s-name data] series]
      (if (sequential? data)
        (apply add-series chart s-name data)
        (let [{:keys [x y error-bars style]} data
              {:keys [marker-color marker-type
                      line-color line-style line-width
                      fill-color show-in-legend render-style]} style]
          (doto-cond
           (if error-bars
             (add-series chart s-name x y error-bars)
             (add-series chart s-name x y))
           marker-color (.setMarkerColor (colors marker-color marker-color))
           marker-type (.setMarker (markers marker-type marker-type))
           line-color (.setLineColor (colors line-color line-color))
           line-style (.setLineStyle line-style)
           line-width (.setLineWidth (float line-width))
           fill-color (.setFillColor (colors fill-color fill-color))
           (not (nil? show-in-legend)) (.setShowInLegend (boolean show-in-legend))
           render-style (.setXYSeriesRenderStyle (xy-render-styles render-style))))))
    (doto-cond
     (.getStyler chart)
     theme (.setTheme (themes theme theme))
     render-style (.setDefaultSeriesRenderStyle (xy-render-styles render-style))
     legend (set-legend! legend)
     chart-style (set-chart-style! chart-style)
     annotations-font (.setAnnotationsFont annotations-font))
    (doto-cond
     chart
     title (.setTitle title))))

(defn pie-chart
  "Returns a pie chart"
  [{:keys [width height title series circular legend theme render-style
           chart-style annotations-font]
    :or {width 640 height 500}}]
  {:pre [series]}
  (let [chart (PieChart. width height)]
    (doseq [[s-name num] series]
      (.addSeries chart s-name num))
    (doto-cond
     (.getStyler chart)
     theme (.setTheme (themes theme theme))
     render-style (.setDefaultSeriesRenderStyle (pie-render-styles render-style))
     (not (nil? circular)) (.setCircular circular)
     legend (set-legend! legend)
     chart-style (set-chart-style! chart-style)
     annotations-font (.setAnnotationsFont annotations-font))
    (doto-cond
     chart
     title (.setTitle title))))

(defn view
  "Utility function to render one or more charts in a swing frame."

   (not (nil? visible)) (.setLegendVisible visible)))

(defn- set-chart-title-style!
  [^Styler styler
   {:keys [box-background-color box-border-color box-visible
           font padding visible]}]
  (doto-cond
