Skip to content

Commit

Permalink
notebook bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Apr 23, 2024
1 parent 51fd130 commit 4ed2f77
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
42 changes: 13 additions & 29 deletions lib/viz/resources/quanta/notebook/viz/highstock.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,10 @@
[1562851800000,50.83]
[1562938200000,50.61]])

(defn make-chart-config [{:keys [title series]}]
(let [{:keys [ohlc close volume]} series
grouping {:units [["week" [1]] ; // unit name - allowed multiples
(def spec
(let [grouping {:units [["week" [1]] ; // unit name - allowed multiples
["month" [1, 2, 3, 4, 6]]]}]
{;:chart {;:type "line"
; :animation false}
:title {:text title}
{:title {:text "demo stockchart"}
;:xAxis {:categories (:labels data)}
;:tooltip {:valueSuffix " %"}
:rangeSelector {;:selected 1 ; time selector on the top
Expand All @@ -79,9 +76,7 @@
;:label {;:pointStart 2010
; :connectorAllowed false}
}}

:credits {:enabled false}

:yAxis [{:labels {:align "right" :x -3}
:title {:text "OHLC"}
:height "60%"
Expand All @@ -95,45 +90,34 @@
:height "40%",
:offset 0,
:lineWidth 2}]

:series [{:type "candlestick" ; :type "ohlc"
:name "priceseries"
:data ohlc
:dataGrouping grouping
:id "27"}
{:type "line"
:name "close"
:linkedTo "priceseries"
:data close
;:yAxis 1
:dataGrouping grouping}

{:type "flags"
:data [{:x 1561469400000 ; // Point where the flag appears
:title "O" ;, // Title of flag displayed on the chart
:text "open trade" ; // Text displayed when the flag are highlighted.
}]
:data
:onSeries "27" ; // Id of which series it should be placed on. If not defined the flag series will be put on the X axis
:shape "flag" ;// Defines the shape of the flags.
:dataGrouping grouping}
{:type "column"
:name "Volume"
:data volume,
:yAxis 1,
:dataGrouping grouping}]}))

(def data
{:ohlc ohlc-series
:close close-series
:volume volume-series})

(def spec
(make-chart-config
{:title "stockchart"
:series data}))
[ohlc-series
close-series
volume-series
[{:x 1561469400000 ; // Point where the flag appears
:title "O" ;, // Title of flag displayed on the chart
:text "open trade" ; // Text displayed when the flag are highlighted.
}]
])

spec

(highstock {:data spec
:box :lg}
data)
(highstock spec data)
4 changes: 2 additions & 2 deletions lib/viz/resources/quanta/notebook/viz/vega.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns quanta.notebook.viz.vega
(:require
[ta.viz.renderfn.vega :refer [vegalite]]))
[ta.viz.renderfn.vega :refer [vega-lite]]))

(def spec
{;:width "1000"
Expand All @@ -27,4 +27,4 @@
{:nav 160.0 :index 7}
{:nav 150.0 :index 8}])

(vegalite spec data)
(vega-lite spec data)

0 comments on commit 4ed2f77

Please sign in to comment.