Fork me on GitHub

@limist yeah my Gist is really simplistic. At that time I was just playing around with understanding how to render the chart and didn’t have a need for a component-did-update. However I used the document referenced by @mikethompson for another component and it worked well.


Maybe once you are done with your changes, you can share some code and I can update that Gist to handle updates. If I remember, someone else had the same problem as you did too.


@limist I suggest you use the hard work someone else has already done with react-chartjs-2. Or if you're using chartjs 1 then and you'd need to make your own externs.


I am using react-chartjs-2 in my current project and it works well. Here is how I define the different chart types:

(ns myns.chartjs
    [goog.object :as obj]
    [reagent.core :as reagent]))

(def line-chart (reagent/adapt-react-class (obj/get js/reactChartjs2 "Line")))
(def bar-chart (reagent/adapt-react-class (obj/get js/reactChartjs2 "Bar")))
(def horizontal-bar-chart (reagent/adapt-react-class (obj/get js/reactChartjs2 "HorizontalBar")))
(def radar-chart (reagent/adapt-react-class (obj/get js/reactChartjs2 "Radar")))
(def polar-chart (reagent/adapt-react-class (obj/get js/reactChartjs2 "Polar")))
(def pie-chart (reagent/adapt-react-class (obj/get js/reactChartjs2 "Pie")))
(def doughnut-chart (reagent/adapt-react-class (obj/get js/reactChartjs2 "Doughnut")))
(def bubble-chart (reagent/adapt-react-class (obj/get js/reactChartjs2 "Bubble")))


And here's an example usage:

[chartjs/line-chart {:data    {:labels   ["Red" "Blue" "Yellow" "Green" "Purple" "Orange"]
                               :datasets [{:label           "# of votes"
                                           :data            [12 19 3 5 2 3]
                                           :backgroundColor "rgba(255, 99, 132, 0.2)"}]}
                     :options {:legend {:display false}}}]


goog.require could not find: devtools.context on browser console running lein new re-frame app


@kenny Thanks for the links, this looks like a real time/sanity-saver, will try it out!


@kenny So in your example usage, f the :datasets are using subscriptions/atoms, then the chart will update automagically, as the subscriptions change?


Perfect, thanks.


Hi. I'm trying to use re-frame with figwheel but I need to change/reload every NS when I refresh my browser. Yes, I'm :requireing there NS in main.


main reload works fine


@souenzzo What does your project.clj look like? And how do you invoke figwheel?


I discovered that it's a problem with goog.history something like... (my bad implementation of history/url) I removed everything related to history/url and everything went back up For now, i will not use url's 🙂


I am using cljs with react native. I would not like to navigate to another screen on-press. Can you please share the peace of example code to do ?


Hey guys not to be obtuse, but how do I get the default loggers to log clojure data structures as clojure data structures instead of as the JS objects?


Aha, that’s the part I missed, thanks


I didn’t have the custom formatters turned on in Chrome, I already had everything else set up


Yup, that’s needed ATM


Would have used another browser if it wasn’t for that one bit


So, I’m trying to use a raw request through re-frame-http-fx… And the xhrio instance I get back has nothing in it… And the status code is -1, no header data, nothing. Like it has no relationship to the call other than the URI


@mangr3n can you share the bit of your code when you do the :http-xhrio ?


one second inlining some stuff I’d extracted, so you can see it in a complete way


how do I turn that into a piece of code?


The GET above worked but of course it’s an embedded side effect.


I would receive the xhrio and was able to manipulate it. I forget how I figured it out. Basically identity gave me the xhrio object and I could then get Data from the Headers and manually transform the content to a clojurescript map with xhrio.getResponseJson and then js->clj


The provider of the service basically used a Header to provide paging information… in both directions...


I didn’t write the service, but I can go re-write it, but damn I’d hate to have to do that for this to work properly. The paging information should be in the JSON, but it’s not. I’d like to not have to rewrite every service in this older application.

mangr3n18:03:53 At the end of this document it describes how to get a raw xhrio back.


Sorry if I have mis understood, but at the bottom there it looks like you might have to change the :response-format in your effects


I know not including that can cause problems


That’s how you use cljs-ajax to get the raw xhrio object back


I have it in there, and the way I did it get’s you the xhrio.


ah, apologies. I did misunderstand


The xhrio object I get back in the event handler is non-functional.. It doesn’t have any of the data from the call in it and no status. It does have the right uri and that’s it.


I’m gonna go dive through the re-frame-http-fx code and see what’s happening in there if I can tell.


I think I see, If I have access to xhrio it’s not data in the event. It might pass through some kind of clojure function that basically neuters it.


We’d have to modify re-frame-http-fx to allow you to register to pick up additional data from Headers.


Or, just transform the entire xhrio into a map. Which would make a lot of sense


@andre has something changed about re-frisk with v0.4? I seem to be getting "goog.require could not find: datafrisk.core" errors since updating from (IIRC) 0.3.something


0.3.2 i think


hrmm... 0.3.2 seems to be throwing up some kind of grumble to do with dispatching also: re-frame: expected a vector, but got: null originating in re_frisk$core$enable_re_frisk_BANG_:24 followed by a re-frame: no subscription handler registered for: "". Returning a nil subscription. from the same location.


oh the lein plugin bit seems new to me in 0.4.4


okay seems some caching thing was interfering with 0.4.4 after empty cache+hard reload it seems to work ... sorry for the line noise