From 3f5f374a360db45b126323e473f403204cf321e4 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Sun, 29 Jun 2025 02:00:40 -0400 Subject: [PATCH] Added functionality to clear the chart canvas so charts can be more easily created --- assets/scripts/reports.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/assets/scripts/reports.coffee b/assets/scripts/reports.coffee index 77d3da0..8c7af59 100644 --- a/assets/scripts/reports.coffee +++ b/assets/scripts/reports.coffee @@ -1,4 +1,6 @@ $ -> + chartInstance = null + $('#reports-download').on 'click', -> canvas = $('#benchmark-chart')[0] a = document.createElement 'a' @@ -7,6 +9,8 @@ $ -> a.click() $('#reports-button').on 'click', (e) -> + chartInstance.destroy() if chartInstance + benchmarkId = $('#report-benchmarks').val() testIds = $('#report-tests').val() @@ -67,7 +71,7 @@ $ -> y: beginAtZero: true - new Chart ctx, + chartInstance = new Chart ctx, type: 'bar' data: data options: options