From f731417134d3d3137b8e00a4e41ecda8a44fbbcd Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 14 Nov 2024 19:49:26 +0100 Subject: [PATCH] fix: mixed_tag visualization not working --- src/components/ftbot/BacktestResultTablePer.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/ftbot/BacktestResultTablePer.vue b/src/components/ftbot/BacktestResultTablePer.vue index fd3db603..b26d9d5b 100644 --- a/src/components/ftbot/BacktestResultTablePer.vue +++ b/src/components/ftbot/BacktestResultTablePer.vue @@ -11,7 +11,19 @@ const props = defineProps({ keyHeaders: { type: Array as PropType, default: () => [] }, }); -const tableItems = computed(() => props.results as unknown as TableItem[]); +const tableItems = computed( + () => + props.results.map((v) => { + if (props.keyHeaders.length > 0) { + return { + ...v, + key: + typeof v['key'] === 'string' ? Array(props.keyHeaders.length).fill(v['key']) : v['key'], + }; + } + return v; + }) as unknown as TableItem[], +); const perTagReason = computed(() => { // TODO: should be TableField - but it's not working correctly @@ -20,7 +32,7 @@ const perTagReason = computed(() => { // Keys could be an array for (let i = 0; i < props.keyHeaders.length; i += 1) { firstFields.push({ - key: `key`, + key: `key[${i}]`, label: props.keyHeaders[i], formatter: (value, _, item) => Array.isArray(value) ? value[i] : value || item['exit_reason'] || 'OTHER', @@ -58,6 +70,7 @@ const perTagReason = computed(() => { { key: 'losses', label: 'Losses' }, ]; }); +console.log(props.title, 'xxx', perTagReason);