From 4f9b76bcea5c72771dd016bd92884e0f7988fb1d Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Thu, 1 Feb 2024 20:25:04 +0900 Subject: [PATCH] bug fixes --- Monitor/Pages/Index.cshtml | 32 +++++++---- Monitor/Pages/MarketAnalyzer.cshtml | 4 ++ Monitor/Pages/SalesAnalyzer.cshtml | 4 ++ Monitor/Pages/_get/DashboardBottom.cshtml | 69 +++++++++++++++-------- PTMagic/Program.cs | 2 +- 5 files changed, 74 insertions(+), 37 deletions(-) diff --git a/Monitor/Pages/Index.cshtml b/Monitor/Pages/Index.cshtml index 901f19f..08f3ac9 100644 --- a/Monitor/Pages/Index.cshtml +++ b/Monitor/Pages/Index.cshtml @@ -30,6 +30,8 @@ var intervalDashboardTop; var intervalDashboardBottom; + + var loadDashboardTop = function () { $("#baglist-refresh-icon").html(''); $("#buylist-refresh-icon").html(''); @@ -68,6 +70,23 @@ if (intervalDashboardBottom != null) { clearInterval(intervalDashboardBottom); } + console.log(counterIndex["DashboardBottom"]); + + // Destroy all d3 svg graph to avoid memory leak every 10 refreshes of Dashboard Bottom + if (counterIndex["DashboardBottom"] >= 10) { + $(".nvtooltip").remove(); + $("svg > *").remove(); + $("svg").remove(); + $("svg").off(); // Remove all event listeners from SVG elements + nv.charts = {}; + nv.graphs = []; + nv.logs = {}; + nv.tooltip = {}; + window.cleanupData(); + // Reset the counter + counterIndex["DashboardBottom"] = 0; + console.log("d3 svg graph destroyed"); + } // Load dashboard $("#dashboardBottom").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/DashboardBottom', '', function (responseText, textStatus, XMLHttpRequest) { @@ -84,18 +103,7 @@ // Increment the counter counterIndex["DashboardBottom"] = (counterIndex["DashboardBottom"] || 0) + 1; - // Destroy all d3 svg graph to avoid memory leak every 30 refreshes of Dashboard Bottom - if (counterIndex["DashboardBottom"] >= 30) { - $(".nvtooltip").remove(); - $("svg > *").remove(); - $("svg").remove(); - nv.charts = {}; - nv.graphs = []; - nv.logs = {}; - nv.tooltip = {}; - // Reset the counter - counterIndex["DashboardBottom"] = 0; - } + } // Reinstate the interval. diff --git a/Monitor/Pages/MarketAnalyzer.cshtml b/Monitor/Pages/MarketAnalyzer.cshtml index 562c717..380d127 100644 --- a/Monitor/Pages/MarketAnalyzer.cshtml +++ b/Monitor/Pages/MarketAnalyzer.cshtml @@ -404,6 +404,9 @@ else // Get the chart's container var container = d3.select('.trend-chart .nv-wrap.nv-lineChart .nv-linesWrap'); + // Remove any existing y=0 line + container.selectAll('.zero-line').remove(); + // Get the x-values of the first and last data points var xRange = lineChart.xAxis.scale().range(); var xMin = xRange[0]; @@ -412,6 +415,7 @@ else // Add a line at y=0 container.insert('line', ':first-child') + .attr('class', 'zero-line') // Add a class to the line for easy .attr('x1', xMin) // x position of the first end of the line .attr('y1', lineChart.yAxis.scale()(0)) // y position of the first end of the line .attr('x2', xMax) // x position of the second end of the line diff --git a/Monitor/Pages/SalesAnalyzer.cshtml b/Monitor/Pages/SalesAnalyzer.cshtml index 84a0393..29554b6 100644 --- a/Monitor/Pages/SalesAnalyzer.cshtml +++ b/Monitor/Pages/SalesAnalyzer.cshtml @@ -503,6 +503,9 @@ // Get the chart's container var container = d3.select('.profit-chart .nv-wrap.nv-lineChart .nv-linesWrap'); + // Remove any existing y=0 line + container.selectAll('.zero-line').remove(); + // Check if profitData[0].values is not empty if (profitData[0].values.length > 0) { // Get the x-values of the first and last data points @@ -511,6 +514,7 @@ // Add a line at y=0 container.insert('line', ':first-child') + .attr('class', 'zero-line') // Add a class to the line for easy selection .attr('x1', xMin) // x position of the first end of the line .attr('y1', profitChart.yAxis.scale()(0)) // y position of the first end of the line .attr('x2', xMax) // x position of the second end of the line diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 1e6f386..0a7f8ca 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -299,13 +299,20 @@ + + + + - - + + diff --git a/PTMagic/Program.cs b/PTMagic/Program.cs index ca7ee6a..288dfaf 100644 --- a/PTMagic/Program.cs +++ b/PTMagic/Program.cs @@ -6,7 +6,7 @@ using Core.Helper; using Microsoft.Extensions.DependencyInjection; -[assembly: AssemblyVersion("2.7.1")] +[assembly: AssemblyVersion("2.7.2")] [assembly: AssemblyProduct("PT Magic")] namespace PTMagic