diff --git a/src/charts/shape.js b/src/charts/shape.js
index c82c49d..ee9a10d 100644
--- a/src/charts/shape.js
+++ b/src/charts/shape.js
@@ -1,7 +1,7 @@
// noinspection JSPotentiallyInvalidUsageOfThis
import {invokeCallback, mixin} from "@/common.js";
-import {chart, createShape, deleteShapeId, dragging, draggingShapeIds, drawShape} from "@/charts/chart.js";
+import {chart, createShape, deleteShapeId, dragging, draggingShapeIds, drawShape, widget} from "@/charts/chart.js";
//
@@ -30,7 +30,7 @@ export const ShapeType = {
Ray: {name: 'Ray', code: 'ray'},
Line: {name: 'Extended Line', code: 'extended'},
HRay: {name: 'Horizontal Ray', code: 'horizontal_ray'},
- HLine: {name: 'Horizontal Line', code: 'horizontal_line'},
+ HLine: {name: 'Horizontal Line', code: 'horizontal_line', drawingProp: 'linetoolhorzline'},
VLine: {name: 'Vertical Line', code: 'vertical_line'},
PriceRange: {name: 'Price Range', code: 'price_range'},
}
@@ -44,7 +44,7 @@ class Shape {
this.model = model // subclass-specific
this.points = null
this.points = this.pointsFromModel()
- console.log('construct points', this.points)
+ // console.log('construct points', this.points)
this.props = props === null ? this.propsFromModel() : mixin(props, this.propsFromModel())
if (onModel !== null)
this.onModel = onModel
@@ -59,12 +59,26 @@ class Shape {
draw() {
// have the user draw this shape
- console.log(`draw ${this.type.name}`)
+ console.log(`draw ${this.type.name}`, this.model)
if (this.id)
throw Error(`Shape already exists ${this.id}`)
+ const or = this.drawingOverrides();
+ // console.log('drawing overrides', or)
+ widget.applyOverrides(or)
drawShape(this.type, new ShapeTVCallbacks(this))
}
+ // return an object with property defaults, e.g. { "linetoolhorzline.linecolor": "#7f11e0" }
+ // https://www.tradingview.com/charting-library-docs/latest/api/modules/Charting_Library#drawingoverrides
+ drawingOverrides() {
+ if (this.model.color===null) return null
+ const o = {}
+ const p = this.type.drawingProp
+ o[p+".linecolor"] = this.model.color
+ o[p+".textcolor"] = this.model.color
+ return o
+ }
+
create() {
if (this.id !== null) return
// programatically create the shape using the current this.points
@@ -257,6 +271,7 @@ class ShapeTVCallbacks {
constructor(shape) {
this.shape = shape
+ this.creating = false
}
onCreate(shapeId, _tvShape, points, props) {
@@ -264,6 +279,7 @@ class ShapeTVCallbacks {
throw Error(`Created a shape ${shapeId} where one already existed ${this.shape.id}`)
this.shape.id = shapeId
if( this.shape.lock ) return
+ this.creating = true
invokeCallback(this.shape, 'onCreate', points, props)
}
@@ -274,6 +290,11 @@ class ShapeTVCallbacks {
}
onProps(shapeId, _tvShape, props) {
+ // console.log('onProps', props)
+ if (this.creating) {
+ this.creating = false
+ return
+ }
this.shape.props = props
this.shape.onProps(props)
this.shape.onDirtyModel(this.shape.propsToModel)
@@ -353,7 +374,6 @@ export class HLine extends Shape {
propsToModel() {this.model.color=this.props.linecolor}
-
onDrag(points) {
const s = this.tvShape();
console.log('shape', s)
diff --git a/src/components/chart/ChartOrder.vue b/src/components/chart/ChartOrder.vue
index 92e6730..fc06789 100644
--- a/src/components/chart/ChartOrder.vue
+++ b/src/components/chart/ChartOrder.vue
@@ -9,7 +9,7 @@
:label="order.amountIsTokenA ? 'Amount':('Value in '+co.selectedSymbol.quote.s)"
>
-
@@ -50,6 +50,7 @@ import {lightenColor, lightenColor2} from "@/misc.js";
import {useTheme} from "vuetify";
import RowBar from "@/components/chart/RowBar.vue";
import ColorBand from "@/components/chart/ColorBand.vue";
+import Color from "color";
const props = defineProps(['order'])
const co = useChartOrderStore()
@@ -66,7 +67,7 @@ function builders(order) {
}
const theme = useTheme().current
-const color = computed(()=>props.order.buy?theme.value.colors.success:theme.value.colors.error)
+const color = computed(()=>new Color(props.order.buy?theme.value.colors.success:theme.value.colors.error).darken(0.2).string())
const lightColor = computed(() => lightenColor(color.value))
const faintColor = computed(() => lightenColor2(color.value))
const colorStyle = computed(() => { return {'color': color.value} })
diff --git a/src/components/chart/ChartOrderPane.vue b/src/components/chart/ChartOrderPane.vue
index ebead7b..8c63e5f 100644
--- a/src/components/chart/ChartOrderPane.vue
+++ b/src/components/chart/ChartOrderPane.vue
@@ -1,18 +1,10 @@
-
-
-
dexorder
-
-
New Order
-
-
Place Order
-
Cancel
-
-
-
-
-
+
+ New Order
+ Place Order
+ Cancel
+
@@ -22,7 +14,6 @@
-
@@ -41,6 +32,7 @@ import {useOrderStore, useStore} from "@/store/store.js";
import {routeFinder} from "@/blockchain/route.js";
import ChartOrder from "@/components/chart/ChartOrder.vue";
import {useTheme} from "vuetify";
+import Toolbar from "@/components/chart/Toolbar.vue";
const s = useStore()
const co = useChartOrderStore()
diff --git a/src/components/chart/ColorBand.vue b/src/components/chart/ColorBand.vue
index eea28ef..f8f5a7e 100644
--- a/src/components/chart/ColorBand.vue
+++ b/src/components/chart/ColorBand.vue
@@ -7,7 +7,6 @@ import {computed} from "vue";
const props = defineProps(['color'])
const computedStyle = computed(() => {
- console.log('computing bar color')
return {
'background-color': props.color,
'border-color': props.color,
diff --git a/src/components/chart/LimitBuilder.vue b/src/components/chart/LimitBuilder.vue
index 43d3b94..f15c5e1 100644
--- a/src/components/chart/LimitBuilder.vue
+++ b/src/components/chart/LimitBuilder.vue
@@ -65,7 +65,7 @@ import {chart} from "@/charts/chart.js";
import {useChartOrderStore} from "@/orderbuild.js";
import Color from "color";
import {HLine} from "@/charts/shape.js";
-import {builderDefaults, lightenColor2} from "@/misc.js";
+import {builderDefaults, lightenColor2, lineColor} from "@/misc.js";
import {useTheme} from "vuetify";
import {useOrderStore} from "@/store/store.js";
import RowBar from "@/components/chart/RowBar.vue";
@@ -77,6 +77,12 @@ const theme = useTheme().current
const props = defineProps(['order', 'builder'])
const emit = defineEmits(['update:builder'])
+function computeDefaultColor() {
+ const index = props.order.builders.indexOf(props.builder)
+ return lineColor(props.order.buy, index)
+}
+
+const defaultColor = computeDefaultColor()
// Fields must be defined in order to be reactive
builderDefaults(props, emit, {
@@ -87,7 +93,7 @@ builderDefaults(props, emit, {
priceB: null,
rungs: 1,
skew: 0,
- color: null,
+ color: defaultColor,
})
const skew100 = computed( {
@@ -106,7 +112,7 @@ const lineAPrice = computed({
})
const lineA = new HLine(
- {price:null,color:null},
+ {price:null,color:defaultColor},
function (line) {props.builder.priceA = line.price; props.builder.color = line.color; adjustShapes()},
deleteBuilder
)
@@ -120,7 +126,7 @@ const lineBPrice = computed({
})
const lineB = new HLine(
- {price:null,color:null},
+ {price:null,color:props.builder.color.value},
(line)=>{props.builder.priceB = line.price; props.builder.color = line.color; adjustShapes()},
deleteBuilder
)
diff --git a/src/components/chart/MarketBuilder.vue b/src/components/chart/MarketBuilder.vue
index c5f4ed6..4ca9072 100644
--- a/src/components/chart/MarketBuilder.vue
+++ b/src/components/chart/MarketBuilder.vue
@@ -1,5 +1,5 @@
-
+
Market Order
@@ -12,7 +12,7 @@
%
-
+