chart-based route finding

This commit is contained in:
Tim
2024-02-27 22:20:23 -04:00
parent fc126955b6
commit 9a5d7a1ce5
12 changed files with 126 additions and 46 deletions

View File

@@ -1,10 +1,28 @@
import {useChartOrderStore} from "@/orderbuild.js";
import {invokeCallbacks, prototype} from "@/common.js";
import datafeed from "@/charts/datafeed.js";
import datafeed, {lookupSymbol} from "@/charts/datafeed.js";
export let widget = null
export let chart = null
export let crosshairPoint = null
let symbolChangedCbs = [] // callbacks for TV's chart.onSymbolChanged()
let lastSymbolChangedArgs = null
export function addSymbolChangedCallback(cb) {
symbolChangedCbs.push(cb)
}
export function removeSymbolChangedCallback(cb) {
symbolChangedCbs = symbolChangedCbs.filter((i)=>i!==cb)
}
function changeSymbol(symbol) {
console.log('tv changeSymbol', symbol)
const info = lookupSymbol(symbol.full_name)
lastSymbolChangedArgs = info
symbolChangedCbs.forEach((cb)=>cb(info))
}
const subscribeEvents = [
'toggle_sidebar', 'indicators_dialog', 'toggle_header', 'edit_object_dialog', 'chart_load_requested',
@@ -51,7 +69,10 @@ function initChart() {
console.log('init chart')
chart = widget.activeChart()
chart.crossHairMoved().subscribe(null, (point)=>setTimeout(()=>handleCrosshairMovement(point),0) )
chart.onSymbolChanged().subscribe(null, changeSymbol);
changeSymbol(chart.symbolExt())
useChartOrderStore().chartReady = true
console.log('chart ready')
}