Hi all, I currently using Om.Next to render my Highchart. It works but it looks ugly so I would like to know if anyone has a better way for it.
;;; Highchart (defui MyLocalChart Object (render [this] (dom/div #js {:style {:height "100%" :width "100%" :position "relative"}})) (componentDidMount [this] (let [{:keys [tableconfig]} (om/props this) my-chart-config (utils/gen-chart-config-handson tableconfig)] (swap! mydb/staticstates assoc :localchart (js/Highcharts.Chart. (dom/node this) (clj->js @my-chart-config))))) (componentDidUpdate [this prev-props new-props] (let [{:keys [tableconfig]} (om/props this) my-chart-config (utils/gen-chart-config-handson tableconfig) chart (:localchart @mydb/staticstates)] ;(.log js/console "My local chart componentDidUpdate") (.destroy chart) (swap! mydb/staticstates assoc :localchart (js/Highcharts.Chart. (dom/node this) (clj->js @my-chart-config))))))
I have to store the highchart in an appstate
solved it: ;;; Highchart (defui MyLocalChart Object (render [this] (let [{:keys [tableconfig]} (om/props this) my-chart-config (utils/gen-chart-config-handson tableconfig)] (dom/div #js {:style {:height "100%" :width "100%" :position "relative"} :ref (fn [mydiv] (if (some? mydiv) (js/Highcharts.Chart. mydiv (clj->js @my-chart-config))))}))))
#js {:a {:b :c}}
will make a js object
where the value of :a
is a clojure object(not a js object)
Not sure if thats a problem in your case.