Skip to content

Commit

Permalink
notebook render-fn meta data added
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Apr 23, 2024
1 parent b3dbc2d commit 98402d5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/viz/src/ta/viz/ds/hiccup.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"returns a render specification {:render-fn :spec :data} .
for hiccup"
[hiccup]
^{:render-fn 'ta.viz.renderfn/render-spec} ; needed for notebooks
{:render-fn 'ta.viz.renderfn.hiccup/hiccup
:data []
:spec hiccup})
1 change: 1 addition & 0 deletions lib/viz/src/ta/viz/ds/highchart.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
(let [chart-spec (or (:chart spec) {})
pane-spec (:charts spec)]
(assert (chart-pane-spec? pane-spec) "please comply with chart-pane-spec")
^{:render-fn 'ta.viz.renderfn/render-spec} ; needed for notebooks
{:render-fn 'ta.viz.renderfn.highcharts/highstock
:data (-> bar-algo-ds
(tc/select-columns (chart-cols pane-spec))
Expand Down
1 change: 1 addition & 0 deletions lib/viz/src/ta/viz/ds/metrics.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:location :trade-summary}))))

(defn metrics-render-spec-impl [{:keys [roundtrip-ds nav-ds metrics]}]
^{:render-fn 'ta.viz.renderfn/render-spec} ; needed for notebooks
{:render-fn 'ta.viz.renderfn.metrics/metrics
:data {:roundtrips (ds->map roundtrip-ds)
:nav (ds->map nav-ds)
Expand Down
1 change: 1 addition & 0 deletions lib/viz/src/ta/viz/ds/rtable.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Specified formats, created from the bar-algo-ds"
[spec bar-algo-ds]
(assert (rtable-spec? spec) "rtable-spec needs to have :columns key")
^{:render-fn 'ta.viz.renderfn/render-spec} ; needed for notebooks
{:render-fn 'ta.viz.renderfn.rtable/rtable
:data (-> bar-algo-ds
(tc/select-columns (rtable-cols spec))
Expand Down
16 changes: 16 additions & 0 deletions lib/viz/src/ta/viz/ds/vega.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@

(defn vega-render-spec [{:keys [cols spec] :as vega-spec} bar-algo-ds]
(when bar-algo-ds
^{:render-fn 'ta.viz.renderfn/render-spec} ; needed for notebooks
{:render-fn 'ta.viz.renderfn.vega/vega-lite
:data {:values (convert-data bar-algo-ds cols)}
:spec spec}))

(defn- select-one [ds x col]
(-> ds
(tc/select-columns [x col])
(tc/add-column :name col)
(tc/rename-columns {col :y
x :x})))

(defn ds-stacked
"produces a dataset with [:x :y :name] columns
useful for vega-plots that colorize depending on
the series name"
[ds x cols]
(let [ds-seq (map #(select-one ds x %) cols)]
(apply tc/concat ds-seq)))

1 change: 1 addition & 0 deletions lib/viz/src/ta/viz/error.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
plotted with a specified style/position,
created from the bar-algo-ds"
[nom-anomaly]
^{:render-fn 'ta.viz.renderfn/render-spec} ; needed for notebooks
{:render-fn 'ta.viz.renderfn.error/nom-error
:data nom-anomaly
:spec :whatever})

0 comments on commit 98402d5

Please sign in to comment.