Support not having an exit column

This commit is contained in:
Matthias 2022-06-05 23:09:26 +02:00
parent 9d7748b504
commit de50ed88d9

View File

@ -280,7 +280,15 @@ export default defineComponent({
y: colBuyData, y: colBuyData,
}, },
}, },
{ ],
};
if (colSellData >= 0) {
if (!Array.isArray(chartOptions.value?.legend) && chartOptions.value?.legend?.data) {
chartOptions.value.legend.data.push('Long exit');
}
if (Array.isArray(options.series)) {
options.series.push({
name: 'Long exit', name: 'Long exit',
type: 'scatter', type: 'scatter',
symbol: 'diamond', symbol: 'diamond',
@ -294,47 +302,55 @@ export default defineComponent({
x: colDate, x: colDate,
y: colSellData, y: colSellData,
}, },
}, });
], }
}; }
if (hasShorts) { if (hasShorts) {
// Add short support // Add short support
if (!Array.isArray(chartOptions.value?.legend) && chartOptions.value?.legend?.data) { if (!Array.isArray(chartOptions.value?.legend) && chartOptions.value?.legend?.data) {
chartOptions.value.legend.data.push('Short'); if (colShortEntryData >= 0) {
chartOptions.value.legend.data.push('Short exit'); chartOptions.value.legend.data.push('Short');
}
if (colShortExitData >= 0) {
chartOptions.value.legend.data.push('Short exit');
}
} }
if (Array.isArray(options.series)) { if (Array.isArray(options.series)) {
options.series.push({ if (colShortEntryData >= 0) {
name: 'Short', options.series.push({
type: 'scatter', name: 'Short',
symbol: 'pin', type: 'scatter',
symbolSize: 10, symbol: 'pin',
xAxisIndex: 0, symbolSize: 10,
yAxisIndex: 0, xAxisIndex: 0,
itemStyle: { yAxisIndex: 0,
color: shortEntrySignalColor, itemStyle: {
}, color: shortEntrySignalColor,
encode: { },
x: colDate, encode: {
y: colShortEntryData, x: colDate,
}, y: colShortEntryData,
}); },
options.series.push({ });
name: 'Short exit', }
type: 'scatter', if (colShortExitData >= 0) {
symbol: 'pin', options.series.push({
symbolSize: 8, name: 'Short exit',
xAxisIndex: 0, type: 'scatter',
yAxisIndex: 0, symbol: 'pin',
itemStyle: { symbolSize: 8,
color: shortexitSignalColor, xAxisIndex: 0,
}, yAxisIndex: 0,
encode: { itemStyle: {
x: colDate, color: shortexitSignalColor,
y: colShortExitData, },
}, encode: {
}); x: colDate,
y: colShortExitData,
},
});
}
} }
} }
@ -526,7 +542,7 @@ export default defineComponent({
animation: false, animation: false,
legend: { legend: {
// Initial legend, further entries are pushed to the below list // Initial legend, further entries are pushed to the below list
data: ['Candles', 'Volume', 'Long', 'Long exit'], data: ['Candles', 'Volume', 'Long'],
right: '1%', right: '1%',
}, },
tooltip: { tooltip: {