Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Oct 29, 2024
1 parent 1496c78 commit 4042177
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 31 deletions.
2 changes: 1 addition & 1 deletion demo/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
org.pinkgorilla/ui-site {:mvn/version "0.0.31"} ; site-menu, ipsum
org.pinkgorilla/ui-repl {:mvn/version "0.1.110"}
org.pinkgorilla/ui-fonts {:mvn/version "0.2.5"} ; font awesome
org.pinkgorilla/ui-input {:mvn/version "0.2.61"}
org.pinkgorilla/ui-input {:mvn/version "0.2.62"}
;; this project
org.pinkgorilla/reagent-table {:local/root "../" :deps/manifest :deps}
; tml dataset
Expand Down
1 change: 1 addition & 0 deletions demo/resources/ext/demo-rtable.edn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"cheetah" demo.page.cheetah/page
"pixi" demo.page.pixi/pixi-page
"layout" demo.page.layout/page
"layout-viewer" demo.page.layout-viewer/page

}
:sci-cljs-ns [demo.helper.ui
Expand Down
10 changes: 9 additions & 1 deletion demo/src/demo/helper/daliclj.cljs
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
(ns demo.helper.daliclj
(:require
[ui.flexlayout :refer [component-ui]]
[ui.flexlayout :refer [component-ui]]
[dali.viewer :refer [viewer2]]
[dali.cljviewer :refer [clj-viewer]]))

(defmethod component-ui "viewer" [{:keys [id state]}]
(fn [options]
(if options
[viewer2 options]
[:div "error: option does not exist"])))


(defmethod component-ui "clj" [{:keys [id state]}]
(fn [options]
(let [{:keys [fun args]} options]
Expand Down
2 changes: 1 addition & 1 deletion demo/src/demo/page/aggrid.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@
{:field "short" :width 70
:resizable true
:cellClassRules {"bg-blue-500" (fn [p]
(println "ccr: " p)
;(println "ccr: " p)
(nil? (.-value p)))}}]}}]}]])
37 changes: 11 additions & 26 deletions demo/src/demo/page/highcharts.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@
:height "800px"
:border "3px solid green"}
:class "bg-red-500"
:charts [{;:bar :candlestick ; :ohlc
:close {:type :line}
; band
:atr-band-mid {:type :point :color "orange"}
:atr-band-lower {:type :line :color "black"}
:atr-band-upper {:type :line :color "black"}}]}}]
:charts [{:bar {:type :ohlc
:mode :candle}
:close {:type :line}}]}}]
:bollinger-volume
[viewer2 {:viewer-fn 'rtable.viewer.highcharts/highstock
:transform-fn 'rtable.transform.highcharts/load-and-transform-highcharts
Expand All @@ -56,20 +53,10 @@
:height "950px" ; 600 + (100 + 100) + 100
:border "3px solid green"}
:class "bg-red-500"
:charts [{:bar {:type :ohlc} ; :ohlc
:close {:type :line}
; band
:atr-band-mid {:type :point :color "orange"}
:atr-band-lower {:type :line :color "black"}
:atr-band-upper {:type :line :color "black"}
;pivots
;:p0-low {:type :step :color "red"}
;:p1-low {:type :step :color "red"} ; :step does not work with gaps.
;:pweek-low {:type :step :color "red"} ; :step does not work with gaps.
;:p0-high {:type :step :color "red"}
;:p1-high {:type :step :color "red"} ; :step does not work with gaps.
;:pweek-high {:type :step :color "red"} ; :step does not work with gaps.
}
:charts [{:bar {:type :ohlc
:mode :candle
} ; :ohlc
:close {:type :line}}
{:volume :column}]}}]

:bollinger-volume-2
Expand All @@ -83,12 +70,10 @@
:overflow-x "hidden"
}
:class "bg-red-500"
:charts [{:bar {:type :ohlc} ; :ohlc
:close {:type :line}
; band
:atr-band-mid {:type :point :color "orange"}
:atr-band-lower {:type :line :color "black"}
:atr-band-upper {:type :line :color "black"}}
:charts [{:bar {:type :ohlc
:mode :candle
} ; :ohlc
:close {:type :line}}
{:volume :column}
]}}]

Expand Down
193 changes: 193 additions & 0 deletions demo/src/demo/page/layout_viewer.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
(ns demo.page.layout-viewer
(:require
[ui.flexlayout :refer [create-model layout add-node]]
[demo.helper.daliclj] ; side-effects to register components
))

(def model
{:global {:tabEnableRename true
:tabEnableClose true
:tabEnableFloat true
:tabSetEnableActiveIcon true}
:layout {:type "row"
:weight 100
:children [{:type "tabset"
:weight 50
:children [{:type "tab"
:name "One"
:component "panel"
:enableClose false,
:icon "/r/images/bar_chart.svg"}]}
{:type "tabset"
:weight 100
:selected 1
:children
[{:type "tab"
:name "wikipedia"
:component "url"
:icon "/r/images/add.svg"
:helpText "this tab has helpText defined"
:id "wikipedia1"}
{:type "tab"
:name "text"
:id "text99"
:component "text"}

{:type "tab"
:name "cheetah"
:component "viewer"
:icon "/r/images/article.svg"
:id "cheetah"}
{:type "tab"
:name "aggrid"
:component "viewer"
:id "aggrid"}
{:type "tab"
:name "highcharts"
:component "viewer"
:id "highcharts"}
{:type "tab"
:name "pixi"
:component "viewer"
:id "pixi"}
]}]}
:borders [{:type "border"
;:selected 13,
:size 350
:location "left"
:children [{:type "tab"
:id "#1"
:name "Options"
:component "option"
:enableClose false}]}]})

(def m (create-model
{:model model
:options {"wikipedia1" "https://en.wikipedia.org/wiki/Main_Page"
"cheetah" {:viewer-fn 'rtable.viewer.cheetah/cheetah-ds
:transform-fn 'rtable.transform.cheetah/load-and-transform-cheetah
:data {:load {:url "/r/bars-1m-full.transit-json"}
:style {:width "100%" :height "100%"}
:columns [; bar
{:field "asset" :caption "a" :width 90}
{:field "date" :caption "d" :width 220
;:style 'demo.page.cheetah/bad-fn
}
{:field "open" :caption "o" :width 90
:style 'demo.helper.format2/red-color}
{:field "high" :caption "h" :width 90
:format 'demo.helper.format2/format-hidden}
{:field "low" :caption "l" :width 90
;; this namespace does not work.
:format 'demo.helper.format2/format-number
:format-args ["Low: %.5f"]}
{:field "close" :caption "c" :width 90
:style 'demo.helper.format2/blue-color
;:format format
:format-args "Cost: %.2f"}
{:field "volume" :caption "v" :width 90}
;
{:field "atr-band-lower" :caption "BL" :width 50}
{:field "atr-band-upper" :caption "BU" :width 50}
{:field "doji" :caption "doji" :width 50}

{:field "below-band" :caption "B?" :width 50
:style {:bgColor "#5f5"}}
{:field "cross-down" :caption "XD" :width 50}
{:field "cross-down-c" :caption "XD_" :width 50}
{:field "long-signal" :caption "LS" :width 50}

{:field "above-band" :caption "A?" :width 50 :format 'demo.helper.format2/format-bool}
{:field "cross-up" :caption "XU" :width 50 :format 'demo.helper.format2/format-bool}
{:field "cross-up-c" :caption "XU_" :width 50
:style 'demo.helper.format2/bool-color
:format 'demo.helper.format2/format-bool2
:format-args [false]}
{:field "short-signal" :caption "SS" :width 50
:format 'demo.helper.format2/format-bool2
:format-args [true]}
{:field "entry" :caption "entry" :width 50}]}}
"aggrid" {:viewer-fn 'rtable.viewer.aggrid/aggrid
:transform-fn 'rtable.transform.aggrid/load-and-transform-aggrid
:data {:load {:url "/r/signal-no-date.transit-json"}
:style {:width "100%" :height "100%"}
:columns [{:field "close" :header "C" :resizable true}
{:field "spike"
:cellStyle {:color "red" :background-color "green"}
:resizable true}
{:field "doji"
:type "rightAligned"
:resizable true
;:valueGetter: p => p.data.athlete
; A Value Getter is a function that gets called for each row to return the Cell Value for a Column.
}
{:field "spike-doji" :width 70
:resizable true}
{:field "doji-v" :width 70
:cellClass "shaded-class"
:resizable true}
{:field "spike-doji-v" :width 70 :resizable true}
{:field "long" :width 70
:resizable true
:cellStyle {:fontWeight "bold"}}
{:field "short" :width 70
:resizable true
:cellClassRules {"bg-blue-500" (fn [p]
;(println "ccr: " p)
(nil? (.-value p)))}}]}}
"highcharts" {:viewer-fn 'rtable.viewer.highcharts/highstock
:transform-fn 'rtable.transform.highcharts/load-and-transform-highcharts
:data {:load {:url "/r/bars-1m-full.transit-json"}
:style {:width "100%"
:height "100%"
:border "3px solid green"}
:class "bg-red-500"
:charts [{;:bar :candlestick ; :ohlc
:close {:type :line}
; band
:atr-band-mid {:type :point :color "orange"}
:atr-band-lower {:type :line :color "black"}
:atr-band-upper {:type :line :color "black"}}]}}
"pixi" {:viewer-fn 'rtable.viewer.pixi/pixi
:transform-fn 'rtable.transform.pixi/load-and-transform-pixi
:data {:load {:url "/r/bars-1m-full.transit-json"}
:style {:width "100%"
:height "100%"
:border "3px solid green"}
:class "bg-red-500"
:charts [[;:bar :candlestick ; :ohlc
;:close {:type :line}
{:type :line :col :daily-atr-lower :color "blue-3"}
{:type :line :col :daily-atr-upper :color "blue-7"}
{:type :range :col [:daily-atr-lower :daily-atr-upper] :color "red-3"}
{:type :line :col :p0-low :color "red-3"}
{:type :line :col :p1-low :color "red-4"}
{:type :line :col :pweek-low :color "red-5"}
{:type :line :col :p0-high :color "red-6"}
{:type :line :col :p1-high :color "red-7"}
{:type :line :col :pweek-high :color "red-8"}]
[{:type :line :col :daily-atr-mid :color "green-5"}
;:volume :column
]
[;:low :column
{:type :line :col :low :color "green-2"}
{:type :point :col :high :color "green-9"}]]}}
"text99" "hello\r\nI come from the options!"}}))



(defn page [{:keys [route-params query-params handler] :as route}]
[:div.h-screen.w-screen
{:style {:display "flex"
:flex-direction "column"
:flex-grow 1}}
[:div {:dir "ltr"
:style {:margin "2px"
:display "flex"
:align-items "center"}}]

[:div {:style {:display "flex"
:flex-grow "1"
:position "relative"
:border "1px solid #ddd"}}
[layout m]]])
3 changes: 1 addition & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +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.18"}
}
org.pinkgorilla/dali {:mvn/version "0.1.20"}}
:aliases
{; github ci
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"}
Expand Down
1 change: 1 addition & 0 deletions src/rtable/transform/highcharts/data.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
(let [series-data (cols->series ds cols)
series-data-js (clj->js series-data)
series (aget (.-series highchart-spec-js) series-index)]
;(println "series idx: " series-index " data: " series-data)
(if series
(set! (.-data series) series-data-js)
(println "error: cannot set-series idx: " series-index " col: " cols " - index does not exist."))
Expand Down

0 comments on commit 4042177

Please sign in to comment.