Fork me on GitHub
#re-frame
<
2017-03-14
>
edwthomas00:03:27

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

edwthomas00:03:36

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.

kenny00:03:21

@limist I suggest you use the hard work someone else has already done with react-chartjs-2. https://github.com/gor181/react-chartjs-2 https://github.com/cljsjs/packages/tree/master/react-chartjs-2 Or if you're using chartjs 1 then https://github.com/reactjs/react-chartjs and you'd need to make your own externs.

kenny00:03:17

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
  (:require
    [cljsjs.chartjs]
    [cljsjs.react-chartjs-2]
    [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")))

kenny00:03:45

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

souenzzo01:03:36

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

limist01:03:36

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

limist01:03:26

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

limist01:03:19

Perfect, thanks.

souenzzo01:03:39

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.

souenzzo01:03:50

main reload works fine

mac14:03:23

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

souenzzo14:03:39

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 🙂

viveke15:03:39

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 ?

mangr3n17:03:08

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?

mangr3n17:03:17

Aha, that’s the part I missed, thanks

mangr3n17:03:49

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

hkjels17:03:44

Yup, that’s needed ATM

hkjels17:03:14

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

mangr3n17:03:45

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

abarylko18:03:47

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

mangr3n18:03:38

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

mangr3n18:03:44

how do I turn that into a piece of code?

mangr3n18:03:49

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

mangr3n18:03:18

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

mangr3n18:03:00

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

mangr3n18:03:52

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

https://github.com/JulianBirch/cljs-ajax/blob/master/docs/formats.md At the end of this document it describes how to get a raw xhrio back.

stephentriphahn18:03:38

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

stephentriphahn18:03:59

I know not including that can cause problems

mangr3n18:03:00

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

mangr3n18:03:14

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

stephentriphahn18:03:16

ah, apologies. I did misunderstand

mangr3n18:03:09

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.

mangr3n18:03:37

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

mangr3n18:03:25

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.

mangr3n18:03:30

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

mangr3n18:03:48

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

sandbags21:03:31

@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

sandbags21:03:00

0.3.2 i think

sandbags22:03:15

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.

sandbags22:03:19

oh the lein plugin bit seems new to me in 0.4.4

sandbags22:03:48

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