limit ladder weights; still some color wonkiness
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<div class="top">
|
<div class="top">
|
||||||
<slot name="top"/>
|
<slot name="top"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="resizer bg-grey-lighten-2" :data-direction="horizontal?'horizontal':'vertical'" ref="resizerElement"></div>
|
<div class="resizer bg-green-lighten-4" :data-direction="horizontal?'horizontal':'vertical'" ref="resizerElement"></div>
|
||||||
<div class="scrollpane">
|
<div class="scrollpane">
|
||||||
<slot name="bottom"/>
|
<slot name="bottom"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,33 +1,60 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- todo extract builder-panel --> <!-- :builder="builder" color-tag="limit" -->
|
<!-- todo extract builder-panel --> <!-- :builder="builder" color-tag="limit" -->
|
||||||
<v-card flat rounded="0">
|
<v-sheet dense :color="faintColor" class="d-flex align-content-stretch" style="overflow-y: hidden">
|
||||||
<v-toolbar dense :color="faintColor" elevation="3">
|
<div :style="colorStyle" style="width:1em"> </div>
|
||||||
<span :style="colorStyle" style="width:1em;height:100%"> </span>
|
<div style="min-width: 3em; font-size: larger" class="align-self-start ml-2 pt-3">{{ rungs === 1 ? 'Limit' : 'Ladder' }}</div>
|
||||||
<v-toolbar-title>{{ rungs === 1 ? 'Limit' : 'Ladder' }}</v-toolbar-title>
|
<div>
|
||||||
<v-text-field type="number" v-model="lineAPrice"
|
<v-text-field type="number" v-model="rungs"
|
||||||
density="compact" hide-details single-line class="justify-self-start" variant="outlined"
|
density="compact" hide-details class="mx-1 my-2" variant="outlined"
|
||||||
:color="color" :base-color="color" min="0"
|
label="Rungs"
|
||||||
/>
|
:color="color" :base-color="color" min="1"
|
||||||
<v-text-field type="number" v-model="rungs"
|
style="width: 4.5em;"
|
||||||
density="compact" hide-details single-line class="justify-self-start" variant="outlined"
|
/>
|
||||||
:color="color" :base-color="color" min="1"
|
</div>
|
||||||
/>
|
<div>
|
||||||
<v-menu>
|
<div v-if="rungs>1">
|
||||||
<template v-slot:activator="{ props }">
|
<v-text-field type="number" v-model="lineBPrice" min="0"
|
||||||
<v-btn variant="plain" v-bind="props" icon="mdi-dots-vertical"/>
|
density="compact" hide-details class="mx-1 my-2" variant="outlined"
|
||||||
</template>
|
label="Price"
|
||||||
<v-list>
|
:color="color" :base-color="color"
|
||||||
<v-list-subheader :title="'Limit '+ (lineAPrice?lineAPrice.toPrecision(5):'')"/>
|
style="flex: 6em"
|
||||||
<v-list-item title="Delete" key="withdraw" value="withdraw" prepend-icon="mdi-delete" color="red"
|
/>
|
||||||
@click="deleteBuilder"/>
|
</div>
|
||||||
</v-list>
|
<v-text-field type="number" v-model="lineAPrice" min="0"
|
||||||
</v-menu>
|
density="compact" hide-details class="mx-1 my-2" variant="outlined"
|
||||||
</v-toolbar>
|
label="Price"
|
||||||
|
:color="color" :base-color="color"
|
||||||
|
style="flex: 6em"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div v-if="rungs>1" class="mx-2 d-flex align-center">
|
||||||
|
<v-slider v-if="rungs>1" direction="vertical" min="-100" max="100" v-model="skew100" class="slider ml-2 mr-4" hide-details/>
|
||||||
|
<v-text-field type="number" v-model="skew100" min="-100" max="100"
|
||||||
|
density="compact" hide-details variant="outlined" label="Skew" step="10"
|
||||||
|
:color="color" :base-color="color">
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-btn icon="mdi-scale-balance" variant="text" @click="builder.skew=0"/>
|
||||||
|
</template>
|
||||||
|
</v-text-field>
|
||||||
|
</div>
|
||||||
|
<div class="align-self-center">
|
||||||
|
<v-menu>
|
||||||
|
<template v-slot:activator="{ props }">
|
||||||
|
<v-btn variant="plain" v-bind="props" icon="mdi-dots-vertical"/>
|
||||||
|
</template>
|
||||||
|
<v-list>
|
||||||
|
<v-list-subheader :title="'Limit '+ (lineAPrice?lineAPrice.toPrecision(5):'')"/>
|
||||||
|
<v-list-item title="Delete" key="withdraw" value="withdraw" prepend-icon="mdi-delete" color="red"
|
||||||
|
@click="deleteBuilder"/>
|
||||||
|
</v-list>
|
||||||
|
</v-menu>
|
||||||
|
</div>
|
||||||
|
</v-sheet>
|
||||||
|
|
||||||
<!-- <v-col>-->
|
<!-- <v-col>-->
|
||||||
<!-- <v-btn v-if="!co.drawing" prepend-icon="mdi-ray-vertex" @click="draw" variant="tonal">Draw</v-btn>-->
|
<!-- <v-btn v-if="!co.drawing" prepend-icon="mdi-ray-vertex" @click="draw" variant="tonal">Draw</v-btn>-->
|
||||||
<!-- <v-btn v-if="co.drawing" prepend-icon="mdi-ray-vertex" @click="cancelDrawing" variant="tonal">Cancel Drawing</v-btn>-->
|
<!-- <v-btn v-if="co.drawing" prepend-icon="mdi-ray-vertex" @click="cancelDrawing" variant="tonal">Cancel Drawing</v-btn>-->
|
||||||
<!-- </v-col>-->
|
<!-- </v-col>-->
|
||||||
</v-card>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -35,7 +62,7 @@ import {computed} from "vue";
|
|||||||
import {chart} from "@/charts/chart.js";
|
import {chart} from "@/charts/chart.js";
|
||||||
import {useChartOrderStore} from "@/orderbuild.js";
|
import {useChartOrderStore} from "@/orderbuild.js";
|
||||||
import Color from "color";
|
import Color from "color";
|
||||||
import {HLine, ShapeType} from "@/charts/shape.js";
|
import {HLine} from "@/charts/shape.js";
|
||||||
import {builderDefaults} from "@/misc.js";
|
import {builderDefaults} from "@/misc.js";
|
||||||
|
|
||||||
const co = useChartOrderStore()
|
const co = useChartOrderStore()
|
||||||
@@ -49,9 +76,15 @@ builderDefaults(props.builder, {
|
|||||||
priceA: null,
|
priceA: null,
|
||||||
priceB: null,
|
priceB: null,
|
||||||
rungs: 1,
|
rungs: 1,
|
||||||
|
skew: 0,
|
||||||
color: null,
|
color: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const skew100 = computed( {
|
||||||
|
get() {return props.builder.skew*100},
|
||||||
|
set(v) {props.builder.skew = v/100; adjustShapes()}
|
||||||
|
} )
|
||||||
|
|
||||||
// we keep two special control lines as the edge of the ranges and then deletable lines in-between
|
// we keep two special control lines as the edge of the ranges and then deletable lines in-between
|
||||||
|
|
||||||
const lineAPrice = computed({
|
const lineAPrice = computed({
|
||||||
@@ -112,9 +145,13 @@ function removeInteriorLine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const color = computed(() => {
|
const color = computed({
|
||||||
// todo saturate the color when the corresponding shape is selected https://github.com/Qix-/color
|
get() {
|
||||||
return props.builder.color
|
const maxLightness = 60
|
||||||
|
const c = new Color(props.builder.color).hsl()
|
||||||
|
return c.saturation <= maxLightness ? props.builder.color : c.lightness(maxLightness).string()
|
||||||
|
},
|
||||||
|
set(v) {props.builder.color = v}
|
||||||
})
|
})
|
||||||
const faintColor = computed(() => new Color(color.value).hsl().lightness(97).string())
|
const faintColor = computed(() => new Color(color.value).hsl().lightness(97).string())
|
||||||
const colorStyle = computed(() => {
|
const colorStyle = computed(() => {
|
||||||
@@ -190,6 +227,38 @@ const prices = computed(()=>{
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const weights = computed(() => {
|
||||||
|
const r = props.builder.rungs
|
||||||
|
const s = -props.builder.skew
|
||||||
|
if (r === 1) return [1]
|
||||||
|
const result = []
|
||||||
|
if (s === 0) {
|
||||||
|
for (let i = 0; i < r; i++)
|
||||||
|
result.push(1 / r)
|
||||||
|
} else if (s === 1) {
|
||||||
|
result.push(1)
|
||||||
|
for (let i = 1; i < r; i++)
|
||||||
|
result.push(0)
|
||||||
|
} else if (s === -1) {
|
||||||
|
for (let i = 1; i < r; i++)
|
||||||
|
result.push(0)
|
||||||
|
result.push(1)
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < r; i++)
|
||||||
|
result.push((1 - s * (2 * i / (r - 1) - 1)) / r)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const colors = computed( ()=> {
|
||||||
|
const c = new Color(props.builder.color).rgb()
|
||||||
|
const ws = weights.value;
|
||||||
|
const max = Math.max(...ws)
|
||||||
|
return ws.map((w)=>c.alpha(w/max).string())
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
let priceRangeId = null
|
let priceRangeId = null
|
||||||
|
|
||||||
|
|
||||||
@@ -210,7 +279,7 @@ function adjustShapes() {
|
|||||||
// SINGLE LINE
|
// SINGLE LINE
|
||||||
//
|
//
|
||||||
console.log('single line')
|
console.log('single line')
|
||||||
lineA.setModel({price:limits[0], color: props.builder.color})
|
lineA.setModel({price:limits[0], color: colors.value[0]})
|
||||||
lineB.delete()
|
lineB.delete()
|
||||||
for( const line of interiorLines )
|
for( const line of interiorLines )
|
||||||
line.delete()
|
line.delete()
|
||||||
@@ -242,8 +311,9 @@ function adjustShapes() {
|
|||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
lineA.setModel({price:limits[0], color: props.builder.color})
|
const colorStrings = colors.value
|
||||||
lineB.setModel({price:limits[limits.length-1], color: props.builder.color})
|
lineA.setModel({price:limits[0], color: colorStrings[0]})
|
||||||
|
lineB.setModel({price:limits[limits.length-1], color: colorStrings[colorStrings.length-1]})
|
||||||
|
|
||||||
const numInterior = Math.max(0,limits.length-2);
|
const numInterior = Math.max(0,limits.length-2);
|
||||||
// trim excess interior lines
|
// trim excess interior lines
|
||||||
@@ -256,7 +326,7 @@ function adjustShapes() {
|
|||||||
if (i === interiorLines.length)
|
if (i === interiorLines.length)
|
||||||
createInteriorLine(limit)
|
createInteriorLine(limit)
|
||||||
else
|
else
|
||||||
interiorLines[i].setModel({price:limit, color: props.builder.color})
|
interiorLines[i].setModel({price:limit, color: colorStrings[1+i]})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,5 +358,10 @@ if (!props.builder.priceA)
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
:deep(.v-slider.v-input--vertical > .v-input__control) {
|
||||||
|
min-height: 5em !important;
|
||||||
|
}
|
||||||
|
.v-slider-track__fill {
|
||||||
|
background-color: inherit !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="d-flex" >
|
<div class="d-flex mb-1">
|
||||||
<span class="arrow align-self-start"><v-icon icon="mdi-arrow-up-bold" color="green"/></span>
|
<span class="arrow align-self-start"><v-icon icon="mdi-arrow-up-bold" color="green"/></span>
|
||||||
<span class="logo">dexorder</span>
|
<span class="logo">dexorder</span>
|
||||||
<v-chip text="ALPHA" size='x-small' color="red" class="align-self-start" variant="text"/>
|
<v-chip text="ALPHA" size='x-small' color="red" class="align-self-start" variant="text"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user