8
我試圖在Google圖表中使用這個example。到re-frame
框架,reagent
。我想創建一個基於訂閱的實時圖表。我測試了一個簡單的計數器= + - 1。Google Chart CLJS Clojure
我得到的錯誤:Assert failed: Render must be a function, not nil (ifn? render-fun)
。
(defn draw-demo-chart
[d]
(let [[columns vectors options chart] (r/children d)
data (new js/google.visualization.DataTable)]
(doall ;gotta keep the doall on maps. lazy sequence...
(map (fn [[type name]]
(.addColumn data type name)) columns))
(.addRows data vectors)
(.draw chart data options)
(.load js/google "visualization" "1" (clj->js {:packages ["corechart" "orgchart" "calendar" "map" "geochart"]}))
(.setOnLoadCallback js/google draw-demo-chart)
))
(defn draw-demo-chart-container
[]
(let [count (re-frame/subscribe [:count])
columns (reaction [["date" "X"] ["number" "Y"]])
vectors (reaction (clj->js [[(new js/Date "07/11/14") 145] [(new js/Date "07/12/14") 15]
[(new js/Date "07/13/14") 23] [(new js/Date "07/14/14") 234]]))
options (reaction (clj->js {:title (str @count)}))
chart (reaction (new js/google.visualization.LineChart (.getElementById js/document "linechart"))) ]
(fn []
[draw-demo-graph @columns @vectors @options @chart])))
(def draw-demo-graph
(r/create-class {:reagent-render draw-demo-chart
:component-did-mount draw-demo-chart
:component-did-update draw-demo-chart}))
它看起來並不因爲如果你有相當正確的方法。本教程應指導您進行必要的調整:https://github.com/Day8/re-frame/blob/master/docs/Using-Stateful-JS-Components.md –
正如我發佈..與d3一起工作。 JS,我只是想創建Google Chart版本。我不知道是什麼問題,因爲在d3.js版本中我找回了數據。沒有問題。在谷歌圖表案例..不。我從很多論壇回來的鏈接..只是我不明白爲什麼不與谷歌圖表這種方法工作...哪裏是我的身邊的錯誤:s – RRR