hypirion / clj-xchart

XChart wrapper for Clojure
https://hypirion.github.io/clj-xchart/
Eclipse Public License 1.0
112 stars 6 forks source link

how to define a new theme? #13

Open rqcy opened 8 years ago

rqcy commented 8 years ago

Is it possible to define a new theme in Clojure and use it later with :theme keyword?

hypirion commented 8 years ago

Yes, but as of now it requires a lot of Java interop and a solid understanding of the XChart API itself. It's on my list of things to resolve for 1.0, but it's not something I will focus on immediately.

lischenko commented 6 years ago

For simple cases you can tweak one of the existing themes by overriding its methods. For example:

(def my-theme
  (proxy [org.knowm.xchart.style.GGPlot2Theme] []
    (getPlotBackgroundColor [] (Color.  1.0 1.0 1.0))
    (getSeriesColors []        (into-array [(Color. 1.0 0.0 0.0)]))))

And then you use that object as a value for the :theme key.

(c/category-chart
 {"Steps" {:x (range 10)
           :y (range 10)}}
 {:title "Ladder"
  :theme  my-theme})