From 2f8701b4b2985cb371881a9a214718271289f86c Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 18 May 2019 11:15:27 +0300 Subject: [PATCH] Rework plot point processing for dmg over time graph the same way --- eos/graph/fitDmgVsTime.py | 48 ++++++++++++++++++++++--------- eos/graph/fitDpsVsTime.py | 3 +- gui/builtinGraphs/fitDmgVsTime.py | 4 +-- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/eos/graph/fitDmgVsTime.py b/eos/graph/fitDmgVsTime.py index 8b29de539..67487c95a 100644 --- a/eos/graph/fitDmgVsTime.py +++ b/eos/graph/fitDmgVsTime.py @@ -20,6 +20,7 @@ from eos.graph import Graph from eos.utils.spoolSupport import SpoolType, SpoolOptions +from gui.utils.numberFormatter import roundToPrec class FitDmgVsTimeGraph(Graph): @@ -27,27 +28,48 @@ class FitDmgVsTimeGraph(Graph): def getPlotPoints(self, fit, extraData, xRange, xAmount): # We deliberately ignore xAmount here to build graph which will reflect # all steps of building up the damage - maxTime = xRange[1] + minX, maxX = xRange if fit.ID not in self.cache: - self.__generateCache(fit, maxTime) - currentY = 0 - # Add zeros even if there's some damage dealt at time = 0, to explicitly show that - # volley is done at this time - xs = [0] - ys = [0] + self.__generateCache(fit, maxX) + currentY = None + xs = [] + ys = [] cache = self.cache[fit.ID] for time in sorted(cache): prevY = currentY currentX = time / 1000 - currentY = cache[time] - if currentY != prevY: - xs.append(currentX) + currentY = roundToPrec(cache[time], 6) + if currentX < minX: + continue + # First set of data points + if not xs: + # Start at exactly requested time, at last known value + initialY = prevY or 0 + xs.append(minX) + ys.append(initialY) + # If current time is bigger then starting, extend plot to that time with old value + if currentX > minX: + xs.append(currentX) + ys.append(initialY) + # If new value is different, extend it with new point to the new value + if currentY != prevY: + xs.append(currentX) + ys.append(currentY) + continue + # Last data point + if currentX > maxX: + xs.append(maxX) ys.append(prevY) + break + # Anything in-between + if currentY != prevY: + if prevY is not None: + xs.append(currentX) + ys.append(prevY) xs.append(currentX) ys.append(currentY) - if maxTime > max(xs): - xs.append(maxTime) - ys.append(ys[-1]) + if currentX >= maxX: + break return xs, ys def getYForX(self, fit, extraData, x): diff --git a/eos/graph/fitDpsVsTime.py b/eos/graph/fitDpsVsTime.py index c5399db37..19433f834 100644 --- a/eos/graph/fitDpsVsTime.py +++ b/eos/graph/fitDpsVsTime.py @@ -22,6 +22,7 @@ from itertools import chain from eos.graph import Graph from eos.utils.spoolSupport import SpoolType, SpoolOptions +from gui.utils.numberFormatter import roundToPrec class FitDpsTimeGraph(Graph): @@ -39,7 +40,7 @@ class FitDpsTimeGraph(Graph): for time in sorted(cache): prevY = currentY currentX = time / 1000 - currentY = cache[time] + currentY = roundToPrec(cache[time], 6) if currentX < minX: continue # First set of data points diff --git a/gui/builtinGraphs/fitDmgVsTime.py b/gui/builtinGraphs/fitDmgVsTime.py index 0b2315ce9..98b0d2567 100644 --- a/gui/builtinGraphs/fitDmgVsTime.py +++ b/gui/builtinGraphs/fitDmgVsTime.py @@ -40,8 +40,8 @@ class FitDmgVsTimeGraph(Graph): @property def yDefs(self): return OrderedDict([ - ('dps', YDef(switchLabel='DPS', axisLabel='DPS', eosGraph='eosGraphDps')), - ('damage', YDef(switchLabel='Damage inflicted', axisLabel='Damage', eosGraph='eosGraphDmg'))]) + ('damage', YDef(switchLabel='Damage inflicted', axisLabel='Damage', eosGraph='eosGraphDmg')), + ('dps', YDef(switchLabel='DPS', axisLabel='DPS', eosGraph='eosGraphDps'))]) FitDmgVsTimeGraph.register()