Skip to content

Check axis spec :major / :minor instead of :visible when drawing grid. #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/thi/ng/geom/viz/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
;; | `:range` | vec of range bounds | Y | nil | Lower & upper bound of projected coordinates |
;; | `:pos` | number | Y | nil | Draw position of the axis (ypos for X-axis, xpos for Y-axis) |
;; | `:major` | seq of domain values | N | nil | Seq of domain positions at which to draw labeled tick marks |
;; | `:minor` | seq of domain values | N | nil | Seq of domain positions at which |
;; | `:minor` | seq of domain values | N | nil | Seq of domain positions at which to draw minor tick marks |
;; | `:major-size` | number | N | 10 | Length of major tick marks |
;; | `:minor-size` | number | N | 5 | Length of minor tick marks |
;; | `:label` | function | N | =(default-svg-label (value-format 2))= | Function to format & emit tick labels |
Expand Down Expand Up @@ -122,7 +122,9 @@
;; *** Axis grid definition (:grid)
;;
;; *Note:* If no `:grid` spec is given in the main spec, no background
;; *grid will be displayed...
;; *grid will be displayed. If the axis is not `:visible`, the grid
;; *will still be displayed as long as either `:major` or `:minor`
;; *ticks are defined in the axis spec.
;;
;; | *Key* | *Value* | *Required* | *Default* | *Description* |
;; |------------+---------+------------+-----------------+----------------------------------------------------------|
Expand Down Expand Up @@ -782,9 +784,9 @@
scale-y (:scale y-axis)]
(svg/group
(merge {:stroke "#ccc" :stroke-dasharray "1 1"} attribs)
(if (:visible x-axis)
(if (or (:major x-axis) (:minor x-axis))
(map #(let [x (scale-x %)] (svg/line (vec2 x y1) (vec2 x y2))) (select-ticks x-axis minor-x)))
(if (:visible y-axis)
(if (or (:major y-axis) (:minor y-axis))
(map #(let [y (scale-y %)] (svg/line (vec2 x1 y) (vec2 x2 y))) (select-ticks y-axis minor-y))))))

(defn svg-plot2d-cartesian
Expand Down Expand Up @@ -848,11 +850,11 @@
great? (> (m/abs-diff x1 x2) m/PI)]
(svg/group
(merge {:stroke "#ccc" :stroke-dasharray "1 1"} attribs)
(if (:visible x-axis)
(if (or (:major x-axis) (:minor x-axis))
(map
#(let [x (scale-x %)] (svg/line (project [x y1]) (project [x y2])))
(select-ticks x-axis minor-x)))
(if (:visible y-axis)
(if (or (:major y-axis) (:minor y-axis))
(map
#(let [y (scale-y %)]
(if circle
Expand Down