Skip to content

Commit 4bb5d13

Browse files
committed
Fix tvjsx#187, gt2i() to setCursor()
1 parent 935bb9f commit 4bb5d13

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

docs/api/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ export default {
8989

9090
Sets custom time range.
9191

92-
* **Arguments**: t1 (Number) Left-bound of the range
93-
* **Arguments**: t2 (Number) Right-bound of the range
92+
* **Arguments**: t1 (Number) Left-bound of the range | Index (in IB mode)
93+
* **Arguments**: t2 (Number) Right-bound of the range | Index (in IB mode)
9494

9595
*Example:*
9696

@@ -120,7 +120,7 @@ Gets current timerange.
120120

121121
Goto to a specific timestamp
122122

123-
* **Arguments**: t (Number) Target timestamp
123+
* **Arguments**: t (Number) Target timestamp | Index (in IB mode)
124124

125125
### getCursor()
126126

src/TradingVue.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ export default {
276276
setRange(t1, t2) {
277277
if (this.chart_props.ib) {
278278
const ti_map = this.$refs.chart.ti_map
279-
t1 = ti_map.smth2i(t1)
280-
t2 = ti_map.smth2i(t2)
279+
const ohlcv = this.$refs.chart.ohlcv
280+
t1 = ti_map.gt2i(t1, ohlcv)
281+
t2 = ti_map.gt2i(t2, ohlcv)
281282
}
282283
this.$refs.chart.setRange(t1, t2)
283284
},

src/stuff/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default {
122122

123123
// Fast filter. Really fast, like 10X
124124
fast_filter(arr, t1, t2) {
125-
if (!arr.length) return arr
125+
if (!arr.length) return [arr, undefined]
126126
try {
127127
let ia = new IndexedArray(arr, "0")
128128
let res = ia.getRange(t1, t2)
@@ -139,7 +139,7 @@ export default {
139139

140140
// Fast filter (index-based)
141141
fast_filter_i(arr, t1, t2) {
142-
if (!arr.length) return arr
142+
if (!arr.length) return [arr, undefined]
143143
let i1 = Math.floor(t1)
144144
if (i1 < 0) i1 = 0
145145
let i2 = Math.floor(t2 + 1)

0 commit comments

Comments
 (0)