-
-
Save mmower/1a452ec9ac8015c3939f75b94c340ff7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn axis-label-component [x y label] | |
(let [dom-data (atom {:width 0 :visibility "hidden"})] | |
(create-class {:display-name "svg-text" | |
:reagent-render (fn [x y label] | |
[:text {:ref (fn [cmp] | |
(if cmp | |
(if-let [rect (.getBoundingClientRect cmp)] | |
(reset! dom-data {:width (double (aget rect "width")) | |
:visibility "visible"})))) | |
:x (- x (/ (:width @dom-data) 2)) | |
:y y | |
:visibility (:visibility @dom-data) | |
:font-family "Arial" | |
:font-size 8} label])}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment