File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -269,7 +269,7 @@ export default {
269269 // TODO: limit goto & setRange (out of data error)
270270 if (this .chart_props .ib ) {
271271 const ti_map = this .$refs .chart .ti_map
272- t = ti_map .smth2i (t )
272+ t = ti_map .gt2i (t, this . $refs . chart . ohlcv )
273273 }
274274 this .$refs .chart .goto (t)
275275 },
Original file line number Diff line number Diff line change @@ -225,4 +225,20 @@ export default class TI {
225225 }
226226 }
227227
228+ // Global Time => Index (uses all data, approx. method)
229+ // Used by tv.goto()
230+ gt2i ( smth , ohlcv ) {
231+ if ( smth > MAX_ARR ) {
232+ let E = 0.1 // Fixes the arrayslicer bug
233+ let [ i1 , i2 ] = Utils . fast_nearest ( ohlcv , smth + E )
234+ if ( typeof i1 === 'number' ) {
235+ return i1
236+ } else {
237+ return this . t2i ( smth ) // fallback
238+ }
239+ } else {
240+ return smth // it was an index
241+ }
242+ }
243+
228244}
You can’t perform that action at this time.
0 commit comments