Created
October 24, 2012 23:12
-
-
Save hiredman/3949532 to your computer and use it in GitHub Desktop.
jfreechart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blackbox.core | |
(:import (org.jfree.chart JFreeChart | |
ChartFactory | |
ChartPanel) | |
(org.jfree.data.time TimeSeriesCollection | |
TimeSeries | |
FixedMillisecond | |
TimeSeriesDataItem) | |
(javax.swing JFrame)) | |
(:use [vespa.crabro])) | |
(def mb (message-bus)) | |
(def go true) | |
(def ts (TimeSeries. "ain1" #_name)) | |
(def avg (atom [0 0])) | |
(defn f [v] | |
(let [g (- (* v -0.0024) -1.8477366255144032)] | |
g)) | |
(future | |
(while go | |
(let [[t v] (read-string (String. (receive-from mb "rover" identity)))] | |
(.add ts | |
(TimeSeriesDataItem. | |
(FixedMillisecond. t) | |
(f v)))))) | |
;; (def ts | |
;; (doto (TimeSeries. "foo" #_name) | |
;; (.add (TimeSeriesDataItem. | |
;; (FixedMillisecond. (System/currentTimeMillis)) 10)))) | |
;; (.add ts (TimeSeriesDataItem. | |
;; (FixedMillisecond. (+ 60000 (System/currentTimeMillis))) 500)) | |
(def tc | |
(TimeSeriesCollection. | |
ts)) | |
(.setMaximumItemAge ts 100000) | |
(def tsc | |
(ChartFactory/createTimeSeriesChart | |
"Accelerometer" | |
"TimeLabel" | |
"ValueLabel" | |
tc | |
true #_legend | |
true #_tooltips | |
true #_urls | |
)) | |
(def jp (JFrame. "Blackbox")) | |
(.add jp (ChartPanel. tsc)) | |
(.show jp) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment