diff --git a/package.json b/package.json index 9c5f5dd..288bd27 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "core-js": "^3.29.0", "ethers": "^6.7.1", "flexsearch": "^0.7.43", + "luxon": "^3.4.4", "pinia": "2.1.6", "roboto-fontface": "*", "socket.io-client": "^4.7.2", diff --git a/src/charts/chart.js b/src/charts/chart.js index b546a48..f44e27a 100644 --- a/src/charts/chart.js +++ b/src/charts/chart.js @@ -2,6 +2,8 @@ import {useChartOrderStore} from "@/orderbuild.js"; import {invokeCallbacks, prototype} from "@/common.js"; import {DataFeed, initFeeDropdown, lookupSymbol} from "@/charts/datafeed.js"; import {intervalToSeconds, SingletonCoroutine} from "@/misc.js"; +import {store} from "core-js/internals/reflect-metadata.js"; +import {useStore} from "@/store/store.js"; export let widget = null export let chart = null @@ -9,6 +11,10 @@ export let crosshairPoint = null let symbolChangedCbs = [] // callbacks for TV's chart.onSymbolChanged() let lastSymbolChangedArgs = null + +const s = useStore() +const co = useChartOrderStore() + export function addSymbolChangedCallback(cb) { symbolChangedCbs.push(cb) } @@ -21,12 +27,12 @@ function changeSymbol(symbol) { const info = lookupSymbol(symbol.full_name) lastSymbolChangedArgs = info symbolChangedCbs.forEach((cb)=>cb(info)) - useChartOrderStore().selectedSymbol = info + co.selectedSymbol = info } function changeInterval(interval, _timeframe) { - useChartOrderStore().intervalSecs = intervalToSeconds(interval) + co.intervalSecs = intervalToSeconds(interval) } @@ -77,11 +83,14 @@ function initChart() { chart.crossHairMoved().subscribe(null, (point)=>setTimeout(()=>handleCrosshairMovement(point),0) ) chart.onSymbolChanged().subscribe(null, changeSymbol) chart.onIntervalChanged().subscribe(null, changeInterval) + const tzapi = chart.getTimezoneApi(); + tzapi.onTimezoneChanged().subscribe(null, (tz)=>s.timeZone=tz ) + s.timeZone = tzapi.getTimezone().id // chart.onHoveredSourceChanged().subscribe(null, ()=>console.log('hovered source changed', arguments)) // chart.selection().onChanged().subscribe(null, s => console.log('selection', chart.selection().allSources())); changeSymbol(chart.symbolExt()) changeInterval(widget.symbolInterval().interval) - useChartOrderStore().chartReady = true + co.chartReady = true console.log('chart ready') } @@ -128,7 +137,6 @@ let drawingCallbacks = null export function drawShape(shapeType, ...callbacks) { // puts the chart into a line-drawing mode for a new shape console.log('drawShape', callbacks, shapeType.name, shapeType.code) - const co = useChartOrderStore() if( drawingCallbacks ) invokeCallbacks(drawingCallbacks, 'onUndraw') drawingCallbacks = callbacks @@ -141,7 +149,6 @@ export function drawShape(shapeType, ...callbacks) { export function createShape(shapeType, points, options={}, ...callbacks) { - const co = useChartOrderStore() drawingCallbacks = null co.drawing = false options.shape = shapeType.code @@ -163,7 +170,7 @@ export function createShape(shapeType, points, options={}, ...callbacks) { if( callbacks.length ) shapeCallbacks[shapeId] = callbacks const shape = chart.getShapeById(shapeId) - console.log('tvShape created', shapeId) + // console.log('tvShape created', shapeId) shape.bringToFront() const props = shape.getProperties() invokeCallbacks(callbacks, 'onCreate', shapeId, shape, points, props) @@ -174,7 +181,6 @@ export function createShape(shapeType, points, options={}, ...callbacks) { export let allShapeIds = [] export function cancelDrawing() { - const co = useChartOrderStore() if (co.drawing) { co.drawing = false widget.selectLineTool(previousDrawingTool) @@ -190,7 +196,7 @@ function onSelectedLineToolChanged() { console.log('line tool changed', tool) if (drawingTool===null) drawingTool = tool - else if (tool!==drawingTool && useChartOrderStore().drawing) + else if (tool!==drawingTool && co.drawing) cancelDrawing(); } @@ -221,7 +227,6 @@ const crosshairHandler = new SingletonCoroutine(doHandleCrosshairMovement, 0) function doHandleCrosshairMovement(point) { // console.log('crosshair moved') crosshairPoint = point - const co = useChartOrderStore() if (co.drawing) invokeCallbacks(drawingCallbacks, 'onRedraw') else if (dragging) { @@ -304,8 +309,6 @@ function doHandleDrawingEvent(id, event) { } if (event === 'create') { allShapeIds.push(id) - - const co = useChartOrderStore(); const callbacks = drawingCallbacks // console.log('drawing callbacks', callbacks) if (callbacks !== null) { diff --git a/src/components/AbsoluteTimeEntry.vue b/src/components/AbsoluteTimeEntry.vue index 9eeed3d..27e92aa 100644 --- a/src/components/AbsoluteTimeEntry.vue +++ b/src/components/AbsoluteTimeEntry.vue @@ -1,25 +1,12 @@