Skip to content

Commit 686d48d

Browse files
committed
composable_plotting wip
1 parent ca0a2ff commit 686d48d

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/data_visualization/aog/composable_plotting.clj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,10 @@ tips
718718

719719
(defn prepare-points
720720
"Clean data, compute domains, group by columns, extract color/size/shape values.
721-
Expects a resolved view (with :x-type, :group already filled in)."
721+
Expects a resolved view (with :x-type, :group already filled in).
722+
When mark is :rect, the y-domain includes 0 so bars have a baseline."
722723
[view]
723-
(let [{:keys [data x y color size shape text-col x-type y-type group]} view
724+
(let [{:keys [data x y color size shape text-col x-type y-type group mark]} view
724725
data-idx (tc/add-column data :__row-idx (range (tc/row-count data)))
725726
clean (cond-> (tc/drop-missing data-idx [x y])
726727
(= x-type :categorical) (tc/map-columns x [x] str))]
@@ -731,7 +732,12 @@ tips
731732
cat-x? (= x-type :categorical)
732733
cat-y? (= y-type :categorical)
733734
x-dom (if cat-x? (distinct xs-col) (numeric-extent xs-col))
734-
y-dom (if cat-y? (distinct ys-col) (numeric-extent ys-col))
735+
y-dom (if cat-y?
736+
(distinct ys-col)
737+
(let [[lo hi] (numeric-extent ys-col)]
738+
(if (= mark :rect)
739+
[(min 0 lo) (max 0 hi)]
740+
[lo hi])))
735741
point-group (fn [ds group-val]
736742
(cond-> {:xs (ds x) :ys (ds y)
737743
:row-indices (ds :__row-idx)}

0 commit comments

Comments
 (0)