ordershape fixes
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import {invokeCallback, mixin} from "@/common.js";
|
||||
import {chart, createShape, deleteShapeId, dragging, draggingShapeIds, drawShape, widget} from "@/charts/chart.js";
|
||||
import {allocationText} from "@/orderbuild.js";
|
||||
import Color from "color";
|
||||
import {dirtyItems, dirtyPoints, pointsToTvOhlcStart} from "@/charts/chart-misc.js";
|
||||
|
||||
@@ -39,6 +38,25 @@ export const ShapeType = {
|
||||
}
|
||||
|
||||
|
||||
export function allocationText(weight, amount, symbol, separator = ' ') {
|
||||
const hasAmount = amount !== null && amount !== undefined && amount > 0
|
||||
if (hasAmount)
|
||||
amount = Number(amount)
|
||||
const hasWeight = weight !== null && weight !== undefined
|
||||
if (hasWeight)
|
||||
weight = Number(weight)
|
||||
let text = ''
|
||||
if (hasWeight)
|
||||
text += `${(weight * 100).toFixed(1)}%`
|
||||
const hasSymbol = symbol !== null && symbol !== undefined
|
||||
if (hasAmount && hasSymbol) {
|
||||
if (hasWeight)
|
||||
text += separator
|
||||
text += `${amount.toPrecision(3).toLocaleString('fullwide')} ${symbol}`
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
export class Shape {
|
||||
|
||||
constructor(type, onModel=null, onDelete=null, props=null, readonly=false, overrides={}) {
|
||||
@@ -555,6 +573,7 @@ export class DLine extends Line {
|
||||
if (model.pointA === null && model.pointB === null)
|
||||
this.delete()
|
||||
else {
|
||||
this.setProps({extendLeft:model.extendLeft, extendRight: model.extendRight})
|
||||
if ('pointA' in model && 'pointB' in model) {
|
||||
const newPoints = [model.pointA, model.pointB];
|
||||
const oldPoints = [this.model.pointA, this.model.pointB];
|
||||
@@ -564,7 +583,6 @@ export class DLine extends Line {
|
||||
this.setPoints(newPoints)
|
||||
}
|
||||
}
|
||||
this.setProps({extendLeft:model.extendLeft, extendRight: model.extendRight})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user