 (ns com.hypirion.clj-xchart
   (:import (org.knowm.xchart XYChart
                              PieChart
+                             CategoryChart
+                             CategorySeries$CategorySeriesRenderStyle
                              PieSeries$PieSeriesRenderStyle
                              XYSeries$XYSeriesRenderStyle
                              XChartPanel)

   {: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)))
     (doto (.getStyler chart)
       (set-default-style! styling)
       (set-axes-style! styling))

           (java.awt Color
                     GridLayout)))

(def colors
  {:blue Color/BLUE
   :black Color/BLACK
