enhance: hide text when small scale for the graph view

pull/1604/head
Tienson Qin 2021-04-02 12:27:00 +08:00
parent 231314f5dd
commit 4e1ef488e9
1 changed files with 6 additions and 4 deletions

View File

@ -56,7 +56,8 @@
(defn- dot-text-mode
[node ctx global-scale dark?]
(let [label (gobj/get node "id")
(let [hide-text? (< global-scale 0.45)
label (gobj/get node "id")
val (gobj/get node "val")
val (if (zero? val) 1 val)
font-size (min
@ -72,9 +73,10 @@
(set! (.-filltextAlign ctx) "center")
(set! (.-textBaseLine ctx) "middle")
(set! (.-fillStyle ctx) color)
(when-not hide-text?
(.fillText ctx label
(- x (/ text-width 2))
(- y (/ 9 global-scale)))
(- y (/ 9 global-scale))))
(.beginPath ctx)
(.arc ctx x y (if (zero? val)