arb1 redeploy
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
import {invokeCallback, mixin} from "@/common.js";
|
||||
import {chart, createShape, deleteShapeId, dragging, draggingShapeIds, drawShape, widget} from "@/charts/chart.js";
|
||||
import Color from "color";
|
||||
import {dirtyItems, dirtyPoints, pointsToTvOhlcStart} from "@/charts/chart-misc.js";
|
||||
import {dirtyItems, dirtyPoints, nearestOhlcStart, pointsToTvOhlcStart} from "@/charts/chart-misc.js";
|
||||
import {readonly} from "vue";
|
||||
import {computeInterceptSlope} from "@/misc.js";
|
||||
|
||||
|
||||
//
|
||||
@@ -222,7 +224,7 @@ export class Shape {
|
||||
// createShape(this.type, this.points, {overrides:this.props}, new ShapeTVCallbacks(this))
|
||||
options = mixin(options, this.drawingOverrides())
|
||||
options['overrides'] = props
|
||||
this.tvPoints = pointsToTvOhlcStart(points)
|
||||
this.tvPoints = this.pointsToTvOhlcStart(points)
|
||||
this.tvCallbacks = new ShapeTVCallbacks(this);
|
||||
const id = createShape(this.type, this.tvPoints, options, this.tvCallbacks)
|
||||
// todo set id?
|
||||
@@ -267,7 +269,7 @@ export class Shape {
|
||||
if (this.id === null)
|
||||
this.create()
|
||||
else {
|
||||
points = pointsToTvOhlcStart(points)
|
||||
points = this.pointsToTvOhlcStart(points)
|
||||
if (dirtyPoints(this.tvPoints, points)) {
|
||||
/*
|
||||
setPoints(e) {
|
||||
@@ -298,6 +300,13 @@ export class Shape {
|
||||
}
|
||||
}
|
||||
|
||||
// diagonals need to override this to adjust their price as well.
|
||||
pointsToTvOhlcStart(points, periodSeconds=null) {
|
||||
return points === null ? null : points.map((p) => {
|
||||
return {time: nearestOhlcStart(p.time, periodSeconds), price: p.price}
|
||||
})
|
||||
}
|
||||
|
||||
onPoints(points) {} // the control points of an existing shape were changed
|
||||
|
||||
setProps(props) {
|
||||
@@ -602,4 +611,20 @@ export class DLine extends Line {
|
||||
super.onProps(props);
|
||||
this.updateModel({extendLeft: props.extendLeft, extendRight: props.extendRight})
|
||||
}
|
||||
|
||||
|
||||
pointsToTvOhlcStart(points, periodSeconds = null) {
|
||||
if (points === null) return null
|
||||
const [v,w] = points
|
||||
const [b,m] = computeInterceptSlope(v.time, v.price, w.time, w.price)
|
||||
points.map((p) => {
|
||||
let {time, price} = p
|
||||
const aligned = nearestOhlcStart(time, periodSeconds);
|
||||
if (time !== aligned) {
|
||||
time = aligned
|
||||
price = b + m * aligned
|
||||
}
|
||||
return {time, price}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user