39 KiB
39 KiB
In [43]:
(require '[clojupyter.misc.display :as display]
'[hiccup.core :as hiccup]
'[cheshire.core :as cheshire]
'[clojure.repl :refer :all]) ;; to have all the repl goodiesIn [44]:
(display/make-html (hiccup/html [:script {:src "https://code.highcharts.com/highcharts.js"}]))Out [44]:
In [45]:
(defn plot-highchart [highchart-json]
(let [id (str (java.util.UUID/randomUUID))
code (format "Highcharts.chart('%s', %s );" id, (cheshire/encode highchart-json))
html [:div [:div {:id id}]
[:script code]]]
(-> html hiccup/html display/make-html)))Out [45]:
#'user/plot-highchart
In [63]:
(def raw-data (map #(+ (* 22 (+ % (Math/random)) 78)) (range)))
(def data-1 (take 1000 raw-data))
(def data-2 (take 1000 (drop 1000 raw-data)))
(plot-highchart {:chart {:type "line"}
:title {:text "Plot of random data"}
:series [{:data data-1} {:data data-2}]})Out [63]:
In [ ]: