Fork me on GitHub
#om-next
<
2017-03-30
>
thinhptran08:03:41

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.

thinhptran08:03:56

;;; 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))))))

thinhptran08:03:23

I have to store the highchart in an appstate

thinhptran10:03:32

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))))}))))

souenzzo12:03:18

#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.