Skip to content

Commit

Permalink
Show latest x-value for scatter plots (#201)
Browse files Browse the repository at this point in the history
Co-authored-by: Levi Jamt <[email protected]>
  • Loading branch information
ljamt and Levi Jamt authored Apr 5, 2022
1 parent 849381d commit e69d1af
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/client/trend.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@

(defn variable-row []
(let [untrending? (r/atom false)]
(fn [trend-idx module signal causality val]
(fn [module signal causality val]
[:tr
[:td module]
[:td signal]
Expand All @@ -221,7 +221,14 @@
:data-position "top center"}
[:i.eye.slash.gray.icon {:on-click #(rf/dispatch [::controller/untrend-single trend-idx (str module "." signal)])}]])]])))

(defn variables-table [trend-idx trend-values]
(defn last-value [xvals yvals plot-type]
(let [last-x (last xvals)
last-y (last yvals)]
(if (= plot-type "scatter")
(or last-x last-y)
last-y)))

(defn variables-table [trend-values plot-type]
[:table.ui.single.line.striped.table
[:thead
[:tr
Expand All @@ -232,8 +239,8 @@
#_[:th {:style {:text-align 'right}} "Remove"]]]
[:tbody
(doall
(for [{:keys [module signal causality yvals]} trend-values] ^{:key (str module signal (rand-int 9999))}
[variable-row trend-idx module signal causality (last yvals)]))]])
(for [{:keys [module signal causality xvals yvals]} trend-values] ^{:key (str module signal (rand-int 9999))}
[variable-row module signal causality (last-value xvals yvals plot-type)]))]])

(defn trend-outer []
(let [trend-range (rf/subscribe [::trend-range])
Expand Down Expand Up @@ -268,8 +275,7 @@
:trend-id id}]]

(when (not @plot-expanded?)

[variables-table active-trend-index trend-values])]))))
[variables-table trend-values plot-type])]))))

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

Expand Down

0 comments on commit e69d1af

Please sign in to comment.