Hi, I’m new to cljs, and om.
I’m trying to transform this cljs script
(ns omtu.core
(:require [goog.dom :as gdom]
;; [cljsjs.echarts :as baidu]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[js.echarts]
[taoensso.timbre :as timbre
:refer-macros [log trace debug info warn error fatal report
logf tracef debugf infof warnf errorf fatalf reportf
spy get-env]]))
(enable-console-print!)
(defn render []
(set! (.-innerHTML (js/document.getElementById "scatterp"))
"<h1>Hello Chestnut!</h1>"))
(defn render-plot []
(let [element (js/document.getElementById "scatterp")
the-chart (.init js/echarts element)
option {:title {:text "Simple"}
:tooltip {}
:legend {:data ["Sales"]}
:xAxis {:data ["aik" "amidi" "chiffon shirt" "pants" "heels" "socks"]}
:yAxis {}
:series [{:name "Sales"
:type "bar"
:data [5, 20, 36, 10, 20, 30]}]}]
(.setOption the-chart (clj->js option))))
(spy :warn "render-plot")
(render-plot)
to work with om next :
(defui SPlot0
Object
(render [this]
(let [element (.createElement js/document "DIV")
element-2 (dom/div #js {:height 400 :width 500} "holder")
the-chart (js/echarts.init element)
option {:title {:text "Simple Minded"}
:tooltip {}
:legend {:data ["Sales"] }
:xAxis {:data ["aik" "amidi" "chiffon shirt" "pants" "heels" "socks"]}
:yAxis {}
:series [{:name "Sales"
:type "bar"
:data [5, 20, 36, 10, 20, 30]}]}
]
(set! (.-option the-chart) (clj->js option))
;; (.setOption the-chart (clj->js option))
element)))
(def splot0 (om/factory SPlot0))
(js/ReactDOM.render (splot0) (gdom/getElement "scatterp"))
When I use element-2
I get :
TypeError: this.dom.getContext is not a function
And When I use element
I get :
Error: omtu.core/SPlot0.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.