Skip to content

Commit

Permalink
reval added
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Nov 14, 2024
1 parent a7cfd7e commit 4ab8328
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 2 deletions.
70 changes: 70 additions & 0 deletions demo/.reval/public/rdocument/demo/notebook/highchart/notebook.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
; saved on 2024-11-13 20:12:46
{:content [{:out "",
:id :90462a03-7ab2-416d-bd44-b5ccca925e5b,
:code "(ns demo.notebook.highchart\n (:require\n [tablecloth.api :as tc]\n [rtable.plot :as plot]\n [demo.random-bars :refer [random-bar-ds]]\n [demo.env :refer [env]]))",
:ns "demo.notebook.highchart",
:result ^{:dali true}
{:viewer-fn dali.viewer.hiccup/hiccup,
:data [:span
{:style {:color "grey"}}
"nil"]}}
{:out "",
:id :7b4ebe3c-cdae-4657-8073-155cb020ef01,
:code "(def ds\n (random-bar-ds 100))",
:ns "demo.notebook.highchart",
:result ^{:dali true}
{:viewer-fn dali.viewer.hiccup/hiccup,
:data [:span
{:style {:color "deeppink"}}
"#'demo.notebook.highchart/ds"]}}
{:out "2024-11-14T01:12:46.765855115Z INFO LOG nuc12 dali.store.file(23,7) - writing .data/public/dali/MIh5U.transit-json\n",
:id :085b427d-07d2-4e01-89cf-1bf2a0d35333,
:code "(plot/highstock-ds\n env {:style {:width \"600px\"\n :height \"300px\"}\n :charts [{:close {:type :line}\n :bar {:type :ohlc\n :mode :candle}}\n {:volume :column}]}\n ds)",
:ns "demo.notebook.highchart",
:result ^{:dali true}
{:viewer-fn rtable.viewer.highcharts/highstock,
:transform-fn rtable.transform.highcharts/load-and-transform-highcharts,
:data {:style {:width "600px",
:height "300px"},
:class "",
:charts [{:close {:type :line},
:bar {:type :ohlc,
:mode :candle}}
{:volume :column}],
:load {:id "MIh5U",
:url "/r/dali/MIh5U.transit-json",
:filename "MIh5U.transit-json",
:fmt "transit-json"}}}}
{:out "",
:id :319f226f-1dbd-42b8-a569-0c3a820b22d4,
:code "(def ds-step\n (tc/add-column\n ds\n :ind\n (map-indexed (fn [idx p]\n (cond\n (and (> idx 20) (< idx 40))\n nil\n :else\n (- p 2.5))) (:close ds))))",
:ns "demo.notebook.highchart",
:result ^{:dali true}
{:viewer-fn dali.viewer.hiccup/hiccup,
:data [:span
{:style {:color "deeppink"}}
"#'demo.notebook.highchart/ds-step"]}}
{:out "2024-11-14T01:12:46.771741436Z INFO LOG nuc12 dali.store.file(23,7) - writing .data/public/dali/gUK4_.transit-json\n",
:id :da38af2c-fe86-4967-a5c3-6aa054affdfa,
:code "(plot/highstock-ds\n env {:style {:width \"600px\"\n :height \"300px\"}\n :charts [{:bar {:type :ohlc\n :mode :candle}\n :ind {:type :step\n :color \"red\"}}\n {:volume :column}]}\n ds-step)",
:ns "demo.notebook.highchart",
:result ^{:dali true}
{:viewer-fn rtable.viewer.highcharts/highstock,
:transform-fn rtable.transform.highcharts/load-and-transform-highcharts,
:data {:style {:width "600px",
:height "300px"},
:class "",
:charts [{:bar {:type :ohlc,
:mode :candle},
:ind {:type :step,
:color "red"}}
{:volume :column}],
:load {:id "gUK4_",
:url "/r/dali/gUK4_.transit-json",
:filename "gUK4_.transit-json",
:fmt "transit-json"}}}}],
:meta {:id :d3f16459-5931-4ae4-9002-1ff8314fa2eb,
:eval-time "2024-11-14T01:12:46.773502487Z",
:ns "demo.notebook.highchart",
:java "19.0.2",
:clojure "1.11.1"}}
1 change: 1 addition & 0 deletions demo/.reval/public/rdocument/notebooks.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:study (), :demo ({:nbns "demo.notebook.highchart", :ext "clj", :path "/home/florian/repo/pink-gorilla/dali-table/demo/src/demo/notebook/highchart.clj"} {:nbns "demo.notebook.highlightjs", :ext "clj"} {:nbns "demo.notebook.ajax", :ext "cljs"} {:nbns "demo.notebook.clojure-edn", :ext "cljs"} {:nbns "demo.notebook.clojure-string", :ext "cljs"} {:nbns "demo.notebook.dialog", :ext "cljs"} {:nbns "demo.notebook.fonts", :ext "cljs"} {:nbns "demo.notebook.frisk", :ext "cljs"} {:nbns "demo.notebook.goog-string", :ext "cljs"} {:nbns "demo.notebook.javelin", :ext "cljs"} {:nbns "demo.notebook.jsinterop", :ext "cljs"} {:nbns "demo.notebook.notify", :ext "cljs"} {:nbns "demo.notebook.page-nav", :ext "cljs"} {:nbns "demo.notebook.pprint", :ext "cljs"} {:nbns "demo.notebook.promesa", :ext "cljs"} {:nbns "demo.notebook.tailwind", :ext "cljs"})}
1 change: 1 addition & 0 deletions demo/.reval/public/rdocument/welcome.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:meta {:ns "welcome"}, :content [{:code "(println \"Welcome to Notebook Viewer \")", :result {:viewer-fn dali.viewer.hiccup/hiccup, :data [:h1.text-blue-800 "Welcome to Notebook Viewer!"]}, :out "Welcome to Notebook Viewer"}]}
5 changes: 4 additions & 1 deletion demo/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"resources"
"target/webly"
".data"
".reval" ; r-eval notebooks
]

:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.pinkgorilla/clj-service {:mvn/version "0.3.20"}
org.pinkgorilla/webly {:mvn/version "0.7.703"} ; build tool
org.pinkgorilla/goldly {:mvn/version "0.7.684"}
org.pinkgorilla/reval {:mvn/version "0.9.171"}
;
org.pinkgorilla/ui-tailwind {:mvn/version "0.1.8"} ; tailwind css classes
org.pinkgorilla/ui-site {:mvn/version "0.0.31"} ; site-menu, ipsum
org.pinkgorilla/ui-repl {:mvn/version "0.1.112"}
Expand All @@ -31,7 +34,7 @@
{:exec-fn modular.system/start!
:exec-args {;:profile "jetty"
:profile "watch"
:config {}
:config "demo-config.edn"
:services "demo-services.edn"}}

;; BUILD / SERVE
Expand Down
10 changes: 10 additions & 0 deletions demo/resources/demo-config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{:reval {:rdocument {:fpath ".reval/public/rdocument"
:rpath "/r/rdocument"}
:collections {:study {:clj "quanta/notebook/study/"}
:demo {:clj "demo/notebook/" ; embedded notebooks in jars.
:cljs "demo/notebook/"}}}


}


6 changes: 6 additions & 0 deletions demo/resources/demo-services.edn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
(clip/ref :permission)
(clip/ref :exts))}


:reval {:start (reval.core/start-reval
(merge {:clj (clip/ref :clj-service)
:reval-role nil}
(:reval (deref (clip/ref :config)))))}


:webly {:start (webly.app.app/start-webly
(clip/ref :exts)
Expand Down
44 changes: 44 additions & 0 deletions demo/src/demo/notebook/highchart.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
(ns demo.notebook.highchart
(:require
[tablecloth.api :as tc]
[rtable.plot :as plot]
[demo.random-bars :refer [random-bar-ds]]
[demo.env :refer [env]]))


(def ds
(random-bar-ds 100))


(plot/highstock-ds
env {:style {:width "600px"
:height "300px"}
:charts [{:close {:type :line}
:bar {:type :ohlc
:mode :candle}}
{:volume :column}]}
ds)



(def ds-step
(tc/add-column
ds
:ind
(map-indexed (fn [idx p]
(cond
(and (> idx 20) (< idx 40))
nil
:else
(- p 2.5))) (:close ds))))

(plot/highstock-ds
env {:style {:width "600px"
:height "300px"}
:charts [{:bar {:type :ohlc
:mode :candle}
:ind {:type :step
:color "red"}}
{:volume :column}]}
ds-step)

3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"resources"]
:deps
{org.clojure/clojure {:mvn/version "1.11.1"}
io.helins/canvas {:mvn/version "2.0.0-beta0"}
potemkin/potemkin {:mvn/version "0.4.7"} ; api namespace consolidation.
io.helins/canvas {:mvn/version "2.0.0-beta0"} ; https://github.com/helins/canvas.cljs
; source code heavily modified, but based on this one:
;org.clojars.frozenlock/reagent-table {:mvn/version "0.1.6"}
io.github.clojure-quant/techml-dataset-cljs {:mvn/version "0.1.18"} ; tml transit.json export
Expand Down
2 changes: 2 additions & 0 deletions src/paint/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[helins.canvas :as hc]
[paint.series :refer [line-plot scale plot-canvas]]))

; https://github.com/helins/canvas.cljs

(defonce c (goog.dom.createElement "canvas"))

(goog.dom.setProperties c
Expand Down
21 changes: 21 additions & 0 deletions src/rtable/plot.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(ns rtable.plot
(:require
[potemkin :refer [import-vars]]
[rtable.plot.aggrid]
[rtable.plot.cheetah]
[rtable.plot.highcharts]
[rtable.plot.pixi]
[rtable.plot.rtable]
[rtable.plot.vega]))

(import-vars
rtable.plot.aggrid/aggrid-ds
rtable.plot.cheetah/cheetah-ds
rtable.plot.highcharts/highstock-ds
rtable.plot.pixi/pixi-ds
rtable.plot.rtable/rtable-ds
rtable.plot.rtable/rtable
rtable.plot.vega/vegalite
rtable.plot.vega/vegalite-ds
rtable.plot.vega/vega)

0 comments on commit 4ab8328

Please sign in to comment.