-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 50f3673
Showing
10 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"shadow-cljs": "^2.3.22" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
color: green; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html> | ||
<head><title>Browser Starter</title></head> | ||
<link rel="stylesheet" href="/css/main.css"> | ||
<body> | ||
<h1>shadow-cljs - Browser</h1> | ||
<div id="app"></div> | ||
|
||
<script src="/js/main.js"></script> | ||
<script>starter.browser.init();</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{:source-paths | ||
["src"] | ||
|
||
:dependencies | ||
[[reagent "1.0.0"] | ||
[re-echarts "5.0.2"]] | ||
|
||
:builds | ||
{:app {:target :browser | ||
:output-dir "public/js" | ||
:asset-path "/js" | ||
|
||
:modules | ||
{:main | ||
{:entries [starter.browser]}} | ||
|
||
:devtools | ||
{:http-root "public" | ||
:http-port 8020}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(ns starter.browser | ||
(:require | ||
[reagent.dom :as rdom] | ||
[re-echarts.core :refer [ECharts]])) | ||
|
||
(defn myechart [] | ||
[:> ECharts | ||
{:style {:width "800px" :height "600px"} | ||
:theme "dark" | ||
:option | ||
{:title {:text "Echarts is here"} | ||
:dataset {:dimention [:Week :Value] | ||
:source [{:Week "Mon" :Value 820} {:Week "Tue" :Value 932} {:Week "Wed" :Value 901} | ||
{:Week "Thu" :Value 934} {:Week "Fri" :Value 1220} {:Week "Sat" :Value 820} | ||
{:Week "Sun" :Value 990}]} | ||
:xAxis {:type "category"} | ||
:yAxis {:type "value"} | ||
:series [{:type "line" | ||
:smooth true}]}}]) | ||
|
||
;; start is called by init and after code reloading finishes | ||
(defn ^:dev/after-load start [] | ||
(js/console.log "start") | ||
(rdom/render [#'myechart] (.getElementById js/document "app"))) | ||
|
||
(defn ^:export init [] | ||
;; init is called ONCE when the page loads | ||
;; this is called in the index.html and must be exported | ||
;; so it is available even in :advanced release builds | ||
(js/console.log "init") | ||
(start)) | ||
|
||
;; this is called before any code is reloaded | ||
(defn ^:dev/before-load stop [] | ||
(js/console.log "stop")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
# move jar to local repo for testing purpose | ||
export version=5.0.2 | ||
lein jar | ||
lein pom | ||
lein localrepo install target/re-echarts-$version.jar re-echarts $version | ||
mkdir -p ~/.m2/repository/re-echarts/re-echarts/$version/ | ||
mv pom.xml ~/.m2/repository/re-echarts/re-echarts/$version/re-echarts-$version.pom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(defproject re-echarts/re-echarts "5.0.2" | ||
:description "React ECharts wrapper in ClojureScript" | ||
:url "https://github.com/kimim/re-echarts" | ||
|
||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
|
||
:dependencies | ||
;; always use "provided" for Clojure(Script) | ||
[[org.clojure/clojurescript "1.10.520" :scope "provided"] | ||
[reagent "1.0.0"]] | ||
|
||
:source-paths | ||
["src"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{:npm-deps {"echarts" "5.0.2"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(ns re-echarts.core | ||
(:require | ||
[react :as react] | ||
[reagent.core :as r] | ||
[echarts :as echarts])) | ||
|
||
(defn ECharts [options] | ||
(r/as-element | ||
(let [mychart (react/useRef nil)] | ||
(react/useEffect (fn [] | ||
(set! (.-chart js/document) | ||
(echarts/init (.-current mychart) (.-theme options))) | ||
(.setOption (.-chart js/document) (.-option options))) | ||
(clj->js [options js/ResizeObserver])) | ||
[:div {:ref mychart | ||
:style (.-style options)}]))) |