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