1.2.3-SNAPSHOT permalink Arrow_down_16x16

set-theme

incanter.charts

  • (set-theme chart theme)
Changes the chart theme.

Arguments:
chart -- an Incanter/JFreeChart object
theme -- either a keyword indicating one of the built-in themes, or a JFreeChart ChartTheme object.

Built-in Themes:
:default
:dark

Examples:

(use '(incanter core charts))
(def chart (function-plot sin -4 4))
(view chart)
;; change the theme of chart to :dark
(set-theme chart :dark)
;; change it back to the default
(set-theme chart :default)


References:
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/StandardChartTheme.html
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/ChartTheme.html

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/charts.clj:214 top

(defn set-theme
"  Changes the chart theme.

   Arguments:
     chart -- an Incanter/JFreeChart object
     theme -- either a keyword indicating one of the built-in themes, or a JFreeChart ChartTheme object.

   Built-in Themes:
     :default
     :dark

   Examples:

     (use '(incanter core charts))
     (def chart (function-plot sin -4 4))
     (view chart)
     ;; change the theme of chart to :dark
     (set-theme chart :dark)
     ;; change it back to the default
     (set-theme chart :default)

   
    References:
       http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/StandardChartTheme.html
       http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/ChartTheme.html 

"
  ([chart theme]
     (let [built-in-theme? (some #{theme} #{:dark :legacy :gradient})
	   _theme (if built-in-theme? 
		    (cond
		     (= theme :dark)
		       (StandardChartTheme/createDarknessTheme)
		     (= theme :legacy)
		       (StandardChartTheme/createLegacyTheme)
		     :default
		       (StandardChartTheme/createJFreeTheme))
		    (cond
		     (= theme :bw)
		       set-theme-bw
		     (instance? ChartTheme theme)
		       #(.apply theme %)  
		     :default
		       set-theme-default))
	   ;; bar-painter
	   ;; (org.jfree.chart.renderer.xy.StandardXYBarPainter.)
	   ]
       (do
	 (if built-in-theme? 
	   (do
	     (.setShadowVisible _theme false)
	     (.apply _theme chart))
	   (do
	     ;; (doto (-> chart .getPlot .getRenderer)
;; 	       (.setBarPainter bar-painter)
;; 	       (.setSeriesOutlinePaint 0 java.awt.Color/lightGray)
;; 	       (.setShadowVisible false)
;; 	       (.setDrawBarOutline true))
	     (_theme chart)))
	 chart))))
Vars in incanter.charts/set-theme: defn let
Used in 0 other vars

Comments top

No comments for set-theme. Log in to add a comment.