Skip to content

Commit b4bea94

Browse files
committed
restore click on barchart to add word in search
1 parent dc603e8 commit b4bea94

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

Clojure-Websockets/MainApp/project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[org.clojure/tools.namespace "0.2.7"]
1111
[ch.qos.logback/logback-classic "1.1.1"]
1212
[com.taoensso/sente "1.2.0" :exclusions [org.clojure/clojure com.taoensso/encore]]
13-
[org.clojure/core.match "0.2.1"]
13+
[org.clojure/core.match "0.3.0-alpha3"]
1414
[http-kit "2.1.19"]
1515
[compojure "1.2.1"]
1616
[ring "1.3.1"]

Clojure-Websockets/MainApp/src/cljs/birdwatch/charts/wordcount_chart.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(:require [birdwatch.util :as util]
33
[birdwatch.stats.regression :as reg]
44
[birdwatch.charts.shapes :as s]
5+
[birdwatch.state :as state]
56
[reagent.core :as r :refer [atom]]))
67

78
(enable-console-print!)
@@ -19,7 +20,7 @@
1920
(defn bar [text cnt y h w idx]
2021
(let [pos-slope (get @pos-trends text)
2122
ratio-slope (get @ratio-trends text)]
22-
[:g
23+
[:g {:on-click #(state/append-search-text text)}
2324
[:text {:y (+ y 8) :x 138 :stroke "none" :fill "black" :dy ".35em" :textAnchor "end"} text]
2425
[s/arrow 146 y (cond (pos? pos-slope) :UP (neg? pos-slope ) :DOWN :else :RIGHT)]
2526
[s/arrow 160 y (cond (pos? ratio-slope) :RIGHT-UP (neg? ratio-slope ) :RIGHT-DOWN :else :RIGHT)]

Clojure-Websockets/MainApp/src/cljs/birdwatch/core.cljs

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@
1818
;;; Reagent components for the application are initialized here.
1919
(ui/init-views)
2020

21-
(defn ^:export append-search-text [s]
22-
(swap! state/app assoc :search-text (str (:search-text @state/app) " " s)))
23-
2421
;;; WordCloud element (implemented externally in JavaScript)
2522
(def cloud-elem (.getElementById js/document "wordCloud"))
2623
(def cloud-w (aget cloud-elem "offsetWidth"))
27-
(def word-cloud (.WordCloud js/BirdWatch cloud-w (* cloud-w 0.7) 250 append-search-text "#wordCloud"))
24+
(def word-cloud (.WordCloud js/BirdWatch cloud-w (* cloud-w 0.7) 250 state/append-search-text "#wordCloud"))
2825

2926
; update the cheap charts every second
3027
(go-loop [] (<! (timeout 1000))

Clojure-Websockets/MainApp/src/cljs/birdwatch/state.cljs

+3
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@
3939
(let [ttc (<! c/total-tweets-count-chan)]
4040
(swap! app assoc :total-tweet-count ttc)
4141
(recur)))
42+
43+
(defn append-search-text [s]
44+
(swap! app assoc :search-text (str (:search-text @app) " " s)))

0 commit comments

Comments
 (0)