From 4ed2f777fff86a1e0f43e4ce610cd502cdf4d7a5 Mon Sep 17 00:00:00 2001 From: awb99 Date: Tue, 23 Apr 2024 14:10:55 -0500 Subject: [PATCH] notebook bugfixes --- .../quanta/notebook/viz/highstock.cljs | 42 ++++++------------- .../resources/quanta/notebook/viz/vega.cljs | 4 +- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/lib/viz/resources/quanta/notebook/viz/highstock.cljs b/lib/viz/resources/quanta/notebook/viz/highstock.cljs index f2c26211..7846c98c 100644 --- a/lib/viz/resources/quanta/notebook/viz/highstock.cljs +++ b/lib/viz/resources/quanta/notebook/viz/highstock.cljs @@ -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 @@ -79,9 +76,7 @@ ;:label {;:pointStart 2010 ; :connectorAllowed false} }} - :credits {:enabled false} - :yAxis [{:labels {:align "right" :x -3} :title {:text "OHLC"} :height "60%" @@ -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) diff --git a/lib/viz/resources/quanta/notebook/viz/vega.cljs b/lib/viz/resources/quanta/notebook/viz/vega.cljs index 162136c0..4f98950d 100644 --- a/lib/viz/resources/quanta/notebook/viz/vega.cljs +++ b/lib/viz/resources/quanta/notebook/viz/vega.cljs @@ -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" @@ -27,4 +27,4 @@ {:nav 160.0 :index 7} {:nav 150.0 :index 8}]) -(vegalite spec data) +(vega-lite spec data)