Always update TradeEntries in candlechart - otherwise Trades may stick around

This commit is contained in:
Matthias 2021-05-15 20:30:21 +02:00
parent d1c66b633b
commit ffee8d8702

View File

@ -457,44 +457,41 @@ export default class CandleChart extends Vue {
this.chartOptions.grid[this.chartOptions.grid.length - 1].bottom = '50px'; this.chartOptions.grid[this.chartOptions.grid.length - 1].bottom = '50px';
delete this.chartOptions.grid[this.chartOptions.grid.length - 1].top; delete this.chartOptions.grid[this.chartOptions.grid.length - 1].top;
} }
if (this.filteredTrades.length > 0) { const { trades, tradesClose } = this.getTradeEntries();
// Show trades
const { trades, tradesClose } = this.getTradeEntries();
const name = 'Trades'; const name = 'Trades';
const nameClose = 'Trades Close'; const nameClose = 'Trades Close';
if (this.chartOptions.legend && this.chartOptions.legend.data) { if (this.chartOptions.legend && this.chartOptions.legend.data) {
this.chartOptions.legend.data.push(name); this.chartOptions.legend.data.push(name);
} }
const sp: echarts.EChartOption.SeriesScatter = { const sp: echarts.EChartOption.SeriesScatter = {
name, name,
type: 'scatter', type: 'scatter',
xAxisIndex: 0, xAxisIndex: 0,
yAxisIndex: 0, yAxisIndex: 0,
itemStyle: { itemStyle: {
color: tradeBuyColor, color: tradeBuyColor,
}, },
data: trades, data: trades,
}; };
if (this.chartOptions.series) { if (this.chartOptions.series) {
this.chartOptions.series.push(sp); this.chartOptions.series.push(sp);
} }
if (this.chartOptions.legend && this.chartOptions.legend.data) { if (this.chartOptions.legend && this.chartOptions.legend.data) {
this.chartOptions.legend.data.push(nameClose); this.chartOptions.legend.data.push(nameClose);
} }
const closeSeries: echarts.EChartOption.SeriesScatter = { const closeSeries: echarts.EChartOption.SeriesScatter = {
name: nameClose, name: nameClose,
type: 'scatter', type: 'scatter',
xAxisIndex: 0, xAxisIndex: 0,
yAxisIndex: 0, yAxisIndex: 0,
itemStyle: { itemStyle: {
color: tradeSellColor, color: tradeSellColor,
}, },
data: tradesClose, data: tradesClose,
}; };
if (this.chartOptions.series) { if (this.chartOptions.series) {
this.chartOptions.series.push(closeSeries); this.chartOptions.series.push(closeSeries);
}
} }
console.log('chartOptions', this.chartOptions); console.log('chartOptions', this.chartOptions);