Skip to content

Commit bf576ab

Browse files
committed
Add 'last' prop, fix price primitive (just testing)
1 parent fa079d5 commit bf576ab

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/components/Chart.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ export default {
189189
grid: d.grid || {},
190190
tf: Utils.parse_tf(d.tf),
191191
i0: res[1],
192-
loading: d.loading
192+
loading: d.loading,
193+
last: d.data[d.data.length - 1]
193194
}
194195
195196
})
@@ -267,7 +268,8 @@ export default {
267268
data: this.sub,
268269
i0: this.sub_start,
269270
settings: this.chart.settings || this.settings_ohlcv,
270-
grid: this.chart.grid || {}
271+
grid: this.chart.grid || {},
272+
last: this.ohlcv[this.ohlcv.length - 1]
271273
})
272274
p.overlays = this.$props.overlays
273275
return p

src/components/Grid.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ export default {
141141
data: d.data,
142142
settings: d.settings,
143143
i0: d.i0,
144-
tf: d.tf
144+
tf: d.tf,
145+
last: d.last
145146
})
146147
count[d.type] = 0
147148
}
@@ -157,7 +158,8 @@ export default {
157158
tf: x.tf,
158159
num: i,
159160
grid_id: this.$props.grid_id,
160-
meta: this.$props.meta
161+
meta: this.$props.meta,
162+
last: x.last
161163
})
162164
})
163165
)

src/components/primitives/price.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default class Price {
55

66
constructor(comp) {
77
this.comp = comp
8-
this.data = comp.$props.data
98
}
109

1110
// Defines an inline shader (has access to both
@@ -20,9 +19,9 @@ export default class Price {
2019
this.comp.$emit('new-shader', {
2120
target: 'sidebar', draw: ctx => {
2221

23-
if (!last_bar()) return
24-
2522
let bar = last_bar()
23+
if (!bar) return
24+
2625
let w = ctx.canvas.width
2726
let h = config.PANHEIGHT
2827
let lbl = bar.price.toFixed(layout.prec)
@@ -47,7 +46,7 @@ export default class Price {
4746
if (!this.shader) this.init_shader()
4847

4948
let layout = this.comp.$props.layout
50-
let last = this.comp.$props.meta.last
49+
let last = this.comp.$props.last
5150

5251
let dir = last[4] >= last[1]
5352
let color = dir ? this.green() : this.red()
@@ -64,13 +63,13 @@ export default class Price {
6463

6564
last_bar() {
6665

67-
if (!this.data.length) return undefined
66+
if (!this.comp.data.length) return undefined
6867
let layout = this.comp.$props.layout
69-
let last = this.data[this.data.length - 1]
68+
let last = this.comp.data[this.comp.data.length - 1]
7069
let y = layout.$2screen(last[4])
71-
let cndl = layout.c_magnet(last[0])
70+
//let cndl = layout.c_magnet(last[0])
7271
return {
73-
y: Math.floor(cndl.c) - 0.5,
72+
y: y, //Math.floor(cndl.c) - 0.5,
7473
price: last[4],
7574
color: last[4] >= last[1] ? this.green() : this.red()
7675
}

src/mixins/overlay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
props: [
88
'id', 'num', 'interval', 'cursor', 'colors',
99
'layout', 'sub', 'data', 'settings', 'grid_id',
10-
'font', 'config', 'meta', 'tf', 'i0'
10+
'font', 'config', 'meta', 'tf', 'i0', 'last'
1111
],
1212
mounted() {
1313
// TODO(1): when hot reloading, dynamicaly changed mixins

0 commit comments

Comments
 (0)