more diagonal work (unfinished)
This commit is contained in:
@@ -31,10 +31,10 @@ export const ShapeType = {
|
||||
*/
|
||||
Segment: {name: 'Trend Line', code: 'trend_line'},
|
||||
Ray: {name: 'Ray', code: 'ray'},
|
||||
Line: {name: 'Extended Line', code: 'extended'},
|
||||
Line: {name: 'Extended Line', code: 'extended', drawingProp: 'linetoolextended'},
|
||||
HRay: {name: 'Horizontal Ray', code: 'horizontal_ray'},
|
||||
HLine: {name: 'Horizontal Line', code: 'horizontal_line', drawingProp: 'linetoolhorzline'},
|
||||
VLine: {name: 'Vertical Line', code: 'vertical_line'},
|
||||
VLine: {name: 'Vertical Line', code: 'vertical_line', drawingProp: 'linetoolvertline'},
|
||||
PriceRange: {name: 'Price Range', code: 'price_range'},
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ export class Shape {
|
||||
//
|
||||
|
||||
setModel(model) {
|
||||
// console.log('shape setModel', model)
|
||||
console.log('shape setModel', model)
|
||||
|
||||
if (model.color)
|
||||
this.model.color = model.color
|
||||
@@ -327,9 +327,9 @@ export class Shape {
|
||||
let lineChangeInfo = null
|
||||
|
||||
function dirtyPoints(pointsA, pointsB) {
|
||||
if (pointsB===null)
|
||||
return pointsA !== null
|
||||
if (pointsA===null)
|
||||
if (pointsB===null || pointsB===undefined)
|
||||
return pointsA !== null && pointsA !== undefined
|
||||
if (pointsA===null || pointsA===undefined)
|
||||
return pointsB.length > 0
|
||||
if (pointsA.length!==pointsB.length)
|
||||
return true
|
||||
@@ -543,10 +543,8 @@ export class DLine extends Line {
|
||||
this.model.pointA = null // {time:..., price:...}
|
||||
this.model.pointB = null
|
||||
|
||||
// since VLines must be on the start of an OHLC boundry, we track those value separately
|
||||
this.shapeTimes = null
|
||||
|
||||
this.setModel(model) // call setModel at the end
|
||||
console.log('initial shape model', {...model})
|
||||
}
|
||||
|
||||
|
||||
@@ -557,10 +555,14 @@ export class DLine extends Line {
|
||||
}
|
||||
|
||||
setModel(model) {
|
||||
console.log('DLine setModel', {...this.model}, {...model})
|
||||
super.setModel(model)
|
||||
if (model.pointA === null || model.pointB === null)
|
||||
this.delete()
|
||||
else if (dirtyPoints(this.model.pointA, model.pointA) || dirtyPoints(this.model.pointB, model.pointB)) {
|
||||
else if (
|
||||
dirtyPoints(this.model.pointA, model.pointA) ||
|
||||
dirtyPoints(this.model.pointB, model.pointB)
|
||||
) {
|
||||
this.model.pointA = model.pointA
|
||||
this.model.pointB = model.pointB
|
||||
this.setPoints([model.pointA, model.pointB])
|
||||
@@ -575,7 +577,7 @@ export class DLine extends Line {
|
||||
}
|
||||
if (dirty) {
|
||||
super.onPoints(points);
|
||||
this.updateModel({pointA: points[0], pointB: points[0]})
|
||||
this.updateModel({pointA: points[0], pointB: points[1]})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user