clj-xchart icon indicating copy to clipboard operation
clj-xchart copied to clipboard

how to define a new theme?

Open rqcy opened this issue 8 years ago • 2 comments

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

rqcy avatar Oct 28 '16 14:10 rqcy

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.

hypirion avatar Oct 30 '16 18:10 hypirion

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})

lischenko avatar Apr 06 '18 01:04 lischenko