mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 13:05:15 +00:00
Allow config of Graph plots
This commit is contained in:
parent
3e483bdc77
commit
77dd1f492b
|
@ -22,13 +22,20 @@
|
||||||
</b-input-group>
|
</b-input-group>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
</div>
|
</div>
|
||||||
|
<PlotIndicatorSelect
|
||||||
|
v-if="graphType === ChartType.line"
|
||||||
|
v-model="fillTo"
|
||||||
|
:columns="columns"
|
||||||
|
class="mt-1"
|
||||||
|
label="Select indicator to add"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ChartType, IndicatorConfig } from '@/types';
|
import { ChartType, IndicatorConfig } from '@/types';
|
||||||
import randomColor from '@/shared/randomColor';
|
import randomColor from '@/shared/randomColor';
|
||||||
|
import PlotIndicatorSelect from '@/components/charts/PlotIndicatorSelect.vue';
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -42,22 +49,28 @@ const graphType = ref<ChartType>(ChartType.line);
|
||||||
const availableGraphTypes = ref(Object.keys(ChartType));
|
const availableGraphTypes = ref(Object.keys(ChartType));
|
||||||
const selAvailableIndicator = ref('');
|
const selAvailableIndicator = ref('');
|
||||||
const cancelled = ref(false);
|
const cancelled = ref(false);
|
||||||
|
const fillTo = ref('');
|
||||||
|
|
||||||
function newColor() {
|
function newColor() {
|
||||||
selColor.value = randomColor();
|
selColor.value = randomColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
const combinedIndicator = computed(() => {
|
const combinedIndicator = computed<IndicatorConfig>(() => {
|
||||||
if (cancelled.value || !selAvailableIndicator.value) {
|
if (cancelled.value || !selAvailableIndicator.value) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
const val: IndicatorConfig = {
|
||||||
|
color: selColor.value,
|
||||||
|
type: graphType.value,
|
||||||
|
};
|
||||||
|
if (fillTo.value && graphType.value === ChartType.line) {
|
||||||
|
val.fill_to = fillTo.value;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
[selAvailableIndicator.value]: {
|
[selAvailableIndicator.value]: val,
|
||||||
color: selColor.value,
|
|
||||||
type: graphType.value,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function emitIndicator() {
|
function emitIndicator() {
|
||||||
emit('update:modelValue', combinedIndicator.value);
|
emit('update:modelValue', combinedIndicator.value);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +84,7 @@ watch(
|
||||||
const xx = props.modelValue[selAvailableIndicator.value];
|
const xx = props.modelValue[selAvailableIndicator.value];
|
||||||
selColor.value = xx.color || randomColor();
|
selColor.value = xx.color || randomColor();
|
||||||
graphType.value = xx.type || ChartType.line;
|
graphType.value = xx.type || ChartType.line;
|
||||||
|
fillTo.value = xx.fill_to || '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -78,7 +92,7 @@ watch(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
watch([selColor, graphType], () => {
|
watch([selColor, graphType, fillTo], () => {
|
||||||
emitIndicator();
|
emitIndicator();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user