From 2df9f30041bf0b23232bce51ab4d213b13233c4a Mon Sep 17 00:00:00 2001 From: Beautiful Mim <156966699+beautifulmim@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:54:23 -0500 Subject: [PATCH] Updated number format and sorting for timeline (#976) * Updated number format and sorting for timeline * Added vertical lines for data points --- .../blocks/AnalizeCombatLogButton.astro | 3 -- .../blocks/CombatLogAnalysisComponent.astro | 12 ++++---- .../components/blocks/CombatLogChart.astro | 30 ++++++++++++++++++- .../app/src/helpers/fetching/combatlog.ts | 2 +- frontend/app/src/i18n/ui.ts | 2 ++ 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/frontend/app/src/components/blocks/AnalizeCombatLogButton.astro b/frontend/app/src/components/blocks/AnalizeCombatLogButton.astro index e6e60ce1..a411a84f 100644 --- a/frontend/app/src/components/blocks/AnalizeCombatLogButton.astro +++ b/frontend/app/src/components/blocks/AnalizeCombatLogButton.astro @@ -66,10 +66,8 @@ import TutorialIcon from '@components/icons/TutorialIcon.astro'; combatlogfile: '', async update_status(combatlogfileinput) { let array_buffer = this.str2ab(this.combatlog) - console.log(this.combatlogfile) if (combatlogfileinput) { - console.log(combatlogfileinput) const file = combatlogfileinput.files[0] array_buffer = await file.arrayBuffer() } @@ -77,7 +75,6 @@ import TutorialIcon from '@components/icons/TutorialIcon.astro'; const compressed_data = pako.gzip(new Uint8Array(array_buffer)) const b64encoded_string = btoa(String.fromCharCode.apply(null, compressed_data)) this.gziped_combatlog = b64encoded_string - console.log(b64encoded_string) }, str2ab(str) { const encoder = new TextEncoder() diff --git a/frontend/app/src/components/blocks/CombatLogAnalysisComponent.astro b/frontend/app/src/components/blocks/CombatLogAnalysisComponent.astro index 96859dd5..a69cfd88 100644 --- a/frontend/app/src/components/blocks/CombatLogAnalysisComponent.astro +++ b/frontend/app/src/components/blocks/CombatLogAnalysisComponent.astro @@ -70,7 +70,7 @@ import RepairBadge from '@components/blocks/RepairBadge.astro'; {combat_log_analysis?.max_to && - {combat_log_analysis?.max_to.damage} - {combat_log_analysis?.max_to.weapon} - {combat_log_analysis?.max_to.outcome} + {combat_log_analysis?.max_to.damage.toLocaleString()} - {combat_log_analysis?.max_to.weapon} - {combat_log_analysis?.max_to.outcome} To {combat_log_analysis?.max_to.entity} @@ -78,16 +78,16 @@ import RepairBadge from '@components/blocks/RepairBadge.astro'; {combat_log_analysis?.max_from && - {combat_log_analysis?.max_from.damage} - {combat_log_analysis?.max_from.weapon} - {combat_log_analysis?.max_from.outcome} + {combat_log_analysis?.max_from.damage.toLocaleString()} - {combat_log_analysis?.max_from.weapon} - {combat_log_analysis?.max_from.outcome} From {combat_log_analysis?.max_from.entity} } {combat_log_analysis.armor_repaired > 0 && - {combat_log_analysis.armor_repaired} + {combat_log_analysis.armor_repaired.toLocaleString()} } {combat_log_analysis.shield_repaired > 0 && - {combat_log_analysis.shield_repaired} + {combat_log_analysis.shield_repaired.toLocaleString()} } } @@ -115,7 +115,7 @@ import RepairBadge from '@components/blocks/RepairBadge.astro'; {(combat_log_analysis?.enemies?.length ?? 0) > 0 && -

{t('enemies')}

+

{t('damage_to_and_from')}

0 && -

{t('repairs')}

+

{t('repair_targets')}

{ + const ctx = chart.ctx + const xScale = chart.scales.x + const yScale = chart.scales.y + + ctx.save() + + chart.data.datasets.forEach(dataset => { + dataset.data.forEach((value, index) => { + const x = xScale.getPixelForValue(index) + const y = yScale.getPixelForValue(value) + + // Draw a vertical line + ctx.beginPath() + ctx.moveTo(x, y) + ctx.lineTo(x, yScale.getPixelForValue(0)) + ctx.strokeStyle = 'rgba(241, 217, 160, 0.25)' + ctx.lineWidth = 1 + ctx.stroke() + }) + }) + + ctx.restore() + } + }] }) const set_axis_button = document.querySelector('.set-x-axis') diff --git a/frontend/app/src/helpers/fetching/combatlog.ts b/frontend/app/src/helpers/fetching/combatlog.ts index 7526c65a..8b95eb47 100644 --- a/frontend/app/src/helpers/fetching/combatlog.ts +++ b/frontend/app/src/helpers/fetching/combatlog.ts @@ -25,6 +25,7 @@ export async function fetch_combatlog_by_id(access_token:string, log_id:number) } async function process_analysis(analysis:CombatLog) { + analysis.times = analysis.times.sort((a, b) => a.name.localeCompare(b.name)) const start_time = analysis.times[0]?.name ?? analysis.start const end_time = analysis.times[analysis.times.length - 1]?.name ?? analysis.end @@ -69,7 +70,6 @@ async function process_analysis(analysis:CombatLog) { const fleet_id = analysis?.fleet_id > 0 ? analysis?.fleet_id : null const repairs = await Promise.all(analysis.repairs.map(async repair => { const effective_reps = (repair.repairs_to * 100) / (repair.max_to * repair.cycles_to) - console.log(repair) return { name: repair.name, diff --git a/frontend/app/src/i18n/ui.ts b/frontend/app/src/i18n/ui.ts index eae7ff3c..1d9ef7ef 100644 --- a/frontend/app/src/i18n/ui.ts +++ b/frontend/app/src/i18n/ui.ts @@ -1233,5 +1233,7 @@ export const ui = { 'unauthenticated_error': 'Authentication is required', 'invalid_log_id': 'Log is not valid', 'uknown_structure_type': 'Uknown structure type', + 'repair_targets': 'Repair targets', + 'damage_to_and_from': 'Damage to and from', }, } as const; \ No newline at end of file