Skip to content

Instantly share code, notes, and snippets.

@hillkim
Forked from edwthomas/chart_reframe.cljs
Created January 10, 2019 06:16
Show Gist options
  • Save hillkim/e17bfaacd08619588e81d631b0c6b5b3 to your computer and use it in GitHub Desktop.
Save hillkim/e17bfaacd08619588e81d631b0c6b5b3 to your computer and use it in GitHub Desktop.
Using CLJS and Re-frame to call third-part JS library (Chartist.js)
(:require [re-frame.core :as re-frame]
[reagent.core :as reagent]
[cljsjs.chartist])
(defn show-chart
[]
(let [chart-data {:labels ["Mar-2012" "Jun-2012" "Nov-2012" "Oct-2013" "Nov-2014"]
:series [[1 1 6 15 25]]}
options {:width "700px"
:height "380px"}]
(js/Chartist.Line. ".ct-chart" (clj->js chart-data) (clj->js options))))
(defn chart-component
[]
(let [some "state goes here"]
(reagent/create-class
{:component-did-mount #(show-chart)
:display-name "chart-component"
:reagent-render (fn []
[:div {:class "ct-chart ct-perfect-fourth"}])})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment