Skip to content

Commit

Permalink
dali-store
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Nov 7, 2024
1 parent 28a9c8b commit 72bfb98
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 57 deletions.
9 changes: 9 additions & 0 deletions demo/src/demo/env.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns demo.env
(:require
[dali.store.file :refer [create-dali-file-store]]))

(def env
{:dali-store (create-dali-file-store
{:fpath ".data/public/dali"
:rpath "/r/dali"})})

14 changes: 7 additions & 7 deletions demo/src/demo/service/aggrid.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(ns demo.service.aggrid
(:require
[tablecloth.api :as tc]
[rtable.plot.aggrid :refer [aggrid-ds]]))
[rtable.plot.aggrid :refer [aggrid-ds]]
[demo.env :refer [env]]))

;; WORKING

Expand All @@ -12,18 +13,17 @@
{:field "date" :header "date" :width 220 :resizable true}
{:field "price" :header "price" :width 90 :resizable true
:cellStyle {:color "red" :background-color "green"}
:type "rightAligned"
}]}]
(aggrid-ds opts ds)))
:type "rightAligned"}]}]
(aggrid-ds env opts ds)))



(comment
(comment
(-> (stock-csv)
;(tc/info)
)


;
)

Expand Down
11 changes: 6 additions & 5 deletions demo/src/demo/service/cheetah.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[tick.core :as t]
[tech.v3.dataset :as ds]
[tablecloth.api :as tc]
[rtable.plot.cheetah :refer [cheetah-ds]]))
[rtable.plot.cheetah :refer [cheetah-ds]]
[demo.env :refer [env]]))

;; WORKING

Expand All @@ -14,16 +15,16 @@
{:field "date" :caption "date" :width 220}
{:field "price" :caption "price" :width 90
:style 'demo.helper.format2/red-color}]}]
(cheetah-ds opts ds)))
(cheetah-ds env opts ds)))



(comment
(comment
(-> (stock-csv)
;(tc/info)
)


;
)

Expand Down
8 changes: 5 additions & 3 deletions demo/src/demo/service/pixi.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(ns demo.service.pixi
(:require
[dali.transform.transit :refer [load-transit]]
[rtable.plot.pixi :refer [pixi-ds]]))
[rtable.plot.pixi :refer [pixi-ds]]
[cquant.tmlds :refer [transit-json-file->ds]]
[demo.env :refer [env]]
))

(def opts {:style {:width "100%"
:height "800px"
Expand All @@ -26,6 +28,6 @@
{:type :point :col :high :color "green-9"}]]})

(defn pixi-static []
(pixi-ds opts (load-transit "resources/public/bars-1m-full.transit-json")))
(pixi-ds env opts (transit-json-file->ds "resources/public/bars-1m-full.transit-json")))


2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; source code heavily modified, but based on this one:
;org.clojars.frozenlock/reagent-table {:mvn/version "0.1.6"}
io.helins/canvas {:mvn/version "2.0.0-beta0"}
org.pinkgorilla/dali {:mvn/version "0.1.24"}}
org.pinkgorilla/dali {:mvn/version "0.1.26"}}
:aliases
{; github ci
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"}
Expand Down
12 changes: 12 additions & 0 deletions src/dali/store/file/transit.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns dali.store.file.transit
(:refer-clojure :exclude [read])
(:require
[dali.store.file :refer [write-file open-file]]
[cquant.tmlds :refer [ds->transit-json-file transit-json-file->ds]]))

(defmethod write-file "transit-json" [_ filename ds]
(ds->transit-json-file ds filename))

(defmethod open-file "transit-json" [_ filename]
(transit-json-file->ds filename))

23 changes: 0 additions & 23 deletions src/dali/transform/transit.clj

This file was deleted.

16 changes: 8 additions & 8 deletions src/rtable/plot/aggrid.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[tick.core :as t]
[tablecloth.api :as tc]
[dali.spec :refer [create-dali-spec]]
[dali.transform.transit :refer [save-transit]]))
[dali.store.file.transit] ; side effects
[dali.store :refer [write]]))

;; DATE FORMAT

Expand Down Expand Up @@ -50,7 +51,8 @@
spec must follow r-table spec format.
The ui shows a table with specified columns,
Specified formats, created from the ds"
[{:keys [style class columns]
[{:keys [dali-store]}
{:keys [style class columns]
:or {style {:width "100%" :height "100%"}
class ""}
:as opts}
Expand All @@ -62,9 +64,7 @@
:data {:style style
:class class
:columns columns
:load (-> ds
;(format-date opts)
(select-columns opts)
#_(tc/rename-columns {:open "open"
:high "high"})
(save-transit))}}))
:load (->> (select-columns ds opts)
#_(tc/rename-columns {:open "open"
:high "high"})
(write dali-store "transit-json"))}}))
8 changes: 5 additions & 3 deletions src/rtable/plot/cheetah.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
(ns rtable.plot.cheetah
(:require
[dali.spec :refer [create-dali-spec]]
[dali.transform.transit :refer [save-transit]]))
[dali.store.file.transit] ; side effects
[dali.store :refer [write]]))

(defn cheetah-ds [{:keys [style class columns]
(defn cheetah-ds [{:keys [dali-store]}
{:keys [style class columns]
:or {style {:width "100%" :height "100%"}
class ""}} ds]
(create-dali-spec
Expand All @@ -12,4 +14,4 @@
:data {:style style
:class class
:columns columns
:load (save-transit ds)}}))
:load (write dali-store "transit-json" ds)}}))
11 changes: 7 additions & 4 deletions src/rtable/plot/highcharts.clj
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
(ns rtable.plot.highcharts
(:require
[dali.spec :refer [create-dali-spec]]
[dali.transform.transit :refer [save-transit]]))
[dali.store.file.transit] ; side effects
[dali.store :refer [write]]))

(defn highstock-ds [{:keys [style class charts]
(defn highstock-ds [{:keys [dali-store]}
{:keys [style class charts]
:or {style {:width "100%" :height "100%"}
class ""}} ds]
class ""}}
ds]
(create-dali-spec
{:viewer-fn 'rtable.viewer.highcharts/highstock
:transform-fn 'rtable.transform.highcharts/load-and-transform-highcharts
:data {:style style
:class class
:charts charts
:load (save-transit ds)}}))
:load (write dali-store "transit-json" ds)}}))
8 changes: 5 additions & 3 deletions src/rtable/plot/pixi.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
(ns rtable.plot.pixi
(:require
[dali.spec :refer [create-dali-spec]]
[dali.transform.transit :refer [save-transit]]))
[dali.store.file.transit] ; side effects
[dali.store :refer [write]]))

(defn pixi-ds [{:keys [style class charts]
(defn pixi-ds [{:keys [dali-store]}
{:keys [style class charts]
:or {style {:width "100%" :height "100%"}
class ""}} ds]
(create-dali-spec
Expand All @@ -12,4 +14,4 @@
:data {:style style
:class class
:columns charts
:load (save-transit ds)}}))
:load (write dali-store "transit-json" ds)}}))

0 comments on commit 72bfb98

Please sign in to comment.