klipse

mchampine 2017-01-11T16:57:12.000292Z

Hi All. This blog entry shows the use of Klipse with HighCharts. http://ingesolvoll.github.io//2017/01/01/how-to-use-a-charting-library-in-reagent.html Very nice. Starting from there, I'm trying to figure out how to configure a HighChart with a y-axis label formatter function. I currently have it specified as: :yAxis {:title {:text "Billions"} :labels {:formatter (fn [x] (/ x 1000.0))}} . This generates a javascript function: {:formatter #object[Function "function (x) {return (x / (1000)); }”]} but the chart doesn’t have any y axis values. See http://jsfiddle.net/gh/get/jquery/3.1.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/area-stacked/ for how it’s done in straight javascript. Does anyone here know how this would be done?? I’m wondering if there’s some klipse/reagent/javascript interop magic that I’m missing.

Yehonathan Sharvit 2017-01-11T17:00:39.000295Z

On my chrome browser - this is what I see:

Yehonathan Sharvit 2017-01-11T17:00:46.000297Z

What is the issue exactly?

mchampine 2017-01-11T18:34:06.000298Z

Would you please share your chart config? My rendered chart doesn’t show any y axis values.

mchampine 2017-01-11T18:34:13.000299Z

(def default-config {:chart {:type :area} :title {:text "Historic and Estimated Worldwide Population Growth by Region"} :subtitle {:text "Source: http://Wikipedia.org"} :xAxis {:categories ["1750", "1800", "1850", "1900", "1950", "1999","2050"] :tickmarkPlacement :on :title {:enabled :false}} :yAxis {:title {:text "Billions"} :labels {:formatter (fn [x] (/ x 1000.0))}} :tooltip {:split :true, :valueSuffix "millions"} :plotOptions {:stacking :normal} :legend {:layout :vertical :align :right :verticalAlign :middle :borderwidth 0} :series [{:name "Asia" :data [502, 635, 809, 947, 1402, 3634, 5268]} {:name "Africa" :data [106, 107, 111, 133, 221, 767, 1766]} {:name "Europe" :data [163, 203, 276, 408, 547, 729, 628]} {:name "America" :data [18, 31, 54, 156, 339, 818, 1201]} {:name "Oceania" :data [2, 2, 2, 6, 13, 30, 46]}]}) (reset! config-atom default-config)

Yehonathan Sharvit 2017-01-11T18:34:42.000300Z

I’ve just opened the jsfiddle you sent http://jsfiddle.net/gh/get/jquery/3.1.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/area-stacked/

mchampine 2017-01-11T18:35:36.000304Z

Oh, I’m trying the above config in the klipse + highcharts blog page..

Yehonathan Sharvit 2017-01-11T18:35:46.000305Z

Oh I see

Yehonathan Sharvit 2017-01-11T18:35:57.000306Z

Let me try it

Yehonathan Sharvit 2017-01-11T18:36:54.000307Z

OK. Now I’m reproducing your issue

mchampine 2017-01-11T18:37:12.000308Z

great. thanks!

Yehonathan Sharvit 2017-01-11T18:48:42.000309Z

You need to use 'this'

Yehonathan Sharvit 2017-01-11T18:49:02.000310Z

There is a cljs macro for that

Yehonathan Sharvit 2017-01-11T18:49:19.000311Z

Its (js-this)

Yehonathan Sharvit 2017-01-11T18:49:30.000312Z

Can u give it a try?

mchampine 2017-01-11T18:54:04.000313Z

Where is it applied? I tried it as a wrapper around my formatter function - but that didn’t work.

Yehonathan Sharvit 2017-01-11T18:54:39.000314Z

No no

Yehonathan Sharvit 2017-01-11T18:55:03.000315Z

Just put (js-this) instead of x

mchampine 2017-01-11T18:58:01.000316Z

Ok, I have {:formatter (fn [] (/ js-this 1000.0))} - the output looks “right” but still not seeing y axis..

mchampine 2017-01-11T18:59:07.000317Z

output is {:formatter #object[Function "function (){return (cljs.core.js_this / (1000));}

Yehonathan Sharvit 2017-01-11T18:59:16.000318Z

Put parenthesis around js-this

mchampine 2017-01-11T19:01:26.000319Z

Input: {:formatter (fn [] (/ (js-this) 1000.0))} output: {:formatter #object[Function "function (){return (this / (1000));} Looking better! But still no joy. 😞

mchampine 2017-01-11T19:01:48.000320Z

Do you have it working? Can you share the exact formatter function?

Yehonathan Sharvit 2017-01-11T19:02:35.000321Z

Im on my phone

mchampine 2017-01-11T19:07:14.000322Z

ah, sorry. I think we’re getting closer.. I really appreciate the help so far.

Yehonathan Sharvit 2017-01-11T19:08:54.000323Z

😊

Yehonathan Sharvit 2017-01-11T19:09:10.000324Z

Will connect in an hour or so

Yehonathan Sharvit 2017-01-11T19:28:19.000325Z

Here you go

Yehonathan Sharvit 2017-01-11T19:28:24.000326Z

(fn [] (/ (js* "this.value") 1000.0))

Yehonathan Sharvit 2017-01-11T19:28:58.000327Z

This one works also:

Yehonathan Sharvit 2017-01-11T19:29:02.000328Z

(fn [] (/ (.-value (js-this)) 1000.0))

Yehonathan Sharvit 2017-01-11T19:53:42.000329Z

@mchampine does it work for u?

mchampine 2017-01-11T20:00:37.000330Z

Yes!! Both work. Thank you! Now I need to understand why. 🙂

mchampine 2017-01-11T20:01:26.000331Z

(not saying that you need to explain - Just that I want to figure it out!)

Yehonathan Sharvit 2017-01-11T20:02:02.000332Z

Ok

Yehonathan Sharvit 2017-01-11T20:02:31.000333Z

What are your plans with highcharts and klipse @mchampine ?

mchampine 2017-01-11T20:06:03.000334Z

Two fold: 1) The topic of the Boston Clojure Group meetup tomorrow is “Klipse” and I wanted some nice use cases. (I organize Boston Clojure Group). 2) I wanted a quick and easy-to-use method to create and share modifiable charts at work. This seems like a great fit.

Yehonathan Sharvit 2017-01-11T20:13:41.000335Z

I’m so happy to hear