chart-based route finding
This commit is contained in:
@@ -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')
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user