Skip to content

Commit

Permalink
#80 Trend timespans coupled to individual trends (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
eidekrist authored Mar 27, 2019
1 parent ad15242 commit 3fad40c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
7 changes: 4 additions & 3 deletions src/cse_client/controller.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,13 @@
(socket-command ["reset-value" module signal causality type])))

(k/reg-event-fx ::trend-zoom
(fn [_ [begin end]]
(socket-command ["trend-zoom" (str begin) (str end)])))

(fn [{:keys [db]} [begin end]]
(socket-command ["trend-zoom" (:active-trend-index db) (str begin) (str end)])))

(k/reg-event-fx ::trend-zoom-reset
(fn [{:keys [db]} _]
(socket-command ["trend-zoom-reset" (-> db :trend-range str)])))
(socket-command ["trend-zoom-reset" (:active-trend-index db) (-> db :trend-range str)])))

(k/reg-event-fx ::trend-range
(fn [{:keys [db]} [new-range]]
Expand Down
9 changes: 4 additions & 5 deletions src/cse_client/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@
:hash-routing? true
:debug? (if debug {:blacklist #{::controller/socket-message-received}} false)
:root-component [view/root-comp]
:initial-db {:trend-range 10
:active-guide-tab "About"
:page 1
:vars-per-page 20
:prev-paths (reader/read-string (storage/get-item "cse-paths"))
:initial-db {:active-guide-tab "About"
:page 1
:vars-per-page 20
:prev-paths (reader/read-string (storage/get-item "cse-paths"))
:show-success-feedback-messages (reader/read-string (storage/get-item "show-success-feedback-message"))}})
5 changes: 4 additions & 1 deletion src/cse_client/trend.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@
:trend-layout (layout-selector plot-type)
:trend-id id}]]]))))

(rf/reg-sub ::trend-range :trend-range)
(rf/reg-sub ::active-trend #(get-in % [:state :trends (-> % :active-trend-index int)]))

(rf/reg-sub ::trend-range
:<- [::active-trend]
#(-> % :spec :range))

(defn- ascending-points? [tuples]
(= tuples
(sort-by :x tuples)))
Expand Down
32 changes: 17 additions & 15 deletions src/cse_client/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,26 @@
(case plot-type

"trend" (semantic/ui-dropdown-item
{:key (str "trend-item-" id)
:text (trend/plot-type-from-label label)
:label "Time series"
:onClick #(rf/dispatch [::controller/add-to-trend current-module name causality type value-reference index])})
{:key (str "trend-item-" id)
:text (trend/plot-type-from-label label)
:label "Time series"
:onClick #(rf/dispatch [::controller/add-to-trend current-module name causality type value-reference index])})

"scatter" (let [label-text (trend/plot-type-from-label label)
axis (if (even? count) 'X 'Y)]
(semantic/ui-dropdown-item
{:key (str "trend-item-" id)
:text label-text
:label (str "XY plot - " axis " axis")
:onClick #(rf/dispatch [::controller/add-to-trend current-module name causality type value-reference index])}))))
{:key (str "trend-item-" id)
:text label-text
:label (str "XY plot - " axis " axis")
:onClick #(rf/dispatch [::controller/add-to-trend current-module name causality type value-reference index])}))))

(defn action-dropdown [current-module name causality type value-reference trend-info]
(when-not (empty? trend-info)
(semantic/ui-dropdown {:button true :text "Add to plot"}
(semantic/ui-dropdown-menu {:direction 'left}
(map (partial trend-item current-module name causality type value-reference) trend-info)))))
(semantic/ui-dropdown
{:button true :text "Add to plot"}
(semantic/ui-dropdown-menu
{:direction 'left}
(map (partial trend-item current-module name causality type value-reference) trend-info)))))

(defn pages-menu []
(let [current-page @(rf/subscribe [:current-page])
Expand Down Expand Up @@ -150,13 +152,13 @@
(trend/plot-type-from-label label)]
(let [display-number (if (= plot-type "trend") count (int (/ count 2)))]
[:div.ui.teal.left.pointing.label display-number])
[:span {:style {:float 'right :cursor 'pointer :z-index 1000}
:data-tooltip "Remove plot"
[:span {:style {:float 'right :cursor 'pointer :z-index 1000}
:data-tooltip "Remove plot"
:data-position "top center"}
[:i.trash.gray.icon {:on-click #(rf/dispatch [::controller/removetrend index])}]]
(if (< 0 count)
[:span {:style {:float 'right :cursor 'pointer :z-index 1000}
:data-tooltip "Remove all variables from plot"
[:span {:style {:float 'right :cursor 'pointer :z-index 1000}
:data-tooltip "Remove all variables from plot"
:data-position "top center"}
[:i.eye.slash.gray.icon {:on-click #(rf/dispatch [::controller/untrend index])}]])])
trend-info)
Expand Down

0 comments on commit 3fad40c

Please sign in to comment.