diff --git a/src/client/trend.cljs b/src/client/trend.cljs index 1eec1c1..daede73 100644 --- a/src/client/trend.cljs +++ b/src/client/trend.cljs @@ -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] @@ -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 @@ -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]) @@ -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)]))