diff --git a/eos/graph/fitDmgVsTime.py b/eos/graph/fitDmgVsTime.py index 3be53bf29..c73df8b1d 100644 --- a/eos/graph/fitDmgVsTime.py +++ b/eos/graph/fitDmgVsTime.py @@ -57,7 +57,7 @@ class FitDmgVsTimeGraph(Graph): ys.append(currentY) continue # Last data point - if currentX > maxX: + if currentX >= maxX: xs.append(maxX) ys.append(prevY) break @@ -68,8 +68,6 @@ class FitDmgVsTimeGraph(Graph): ys.append(prevY) xs.append(currentX) ys.append(currentY) - 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 e6a075d27..20023a388 100644 --- a/eos/graph/fitDpsVsTime.py +++ b/eos/graph/fitDpsVsTime.py @@ -25,7 +25,7 @@ from eos.utils.spoolSupport import SpoolType, SpoolOptions from gui.utils.numberFormatter import roundToPrec -class FitDpsTimeGraph(Graph): +class FitDpsVsTimeGraph(Graph): def getPlotPoints(self, fit, extraData, xRange, xAmount): # We deliberately ignore xAmount here to build graph which will reflect @@ -59,7 +59,7 @@ class FitDpsTimeGraph(Graph): ys.append(currentY) continue # Last data point - if currentX > maxX: + if currentX >= maxX: xs.append(maxX) ys.append(prevY) break @@ -70,8 +70,6 @@ class FitDpsTimeGraph(Graph): ys.append(prevY) xs.append(currentX) ys.append(currentY) - if currentX >= maxX: - break return xs, ys def getYForX(self, fit, extraData, x): diff --git a/gui/builtinGraphs/fitDmgVsTime.py b/gui/builtinGraphs/fitDmgVsTime.py index 4603e38c6..4dc22dc22 100644 --- a/gui/builtinGraphs/fitDmgVsTime.py +++ b/gui/builtinGraphs/fitDmgVsTime.py @@ -21,7 +21,7 @@ from collections import OrderedDict from eos.graph.fitDmgVsTime import FitDmgVsTimeGraph as EosGraphDmg -from eos.graph.fitDpsVsTime import FitDpsTimeGraph as EosGraphDps +from eos.graph.fitDpsVsTime import FitDpsVsTimeGraph as EosGraphDps from gui.graph import Graph, XDef, YDef diff --git a/gui/graphFrame.py b/gui/graphFrame.py index 69f4c3ed8..abdafe1de 100644 --- a/gui/graphFrame.py +++ b/gui/graphFrame.py @@ -155,6 +155,7 @@ class GraphFrame(wx.Frame): self.graphCtrlPanel.SetSizer(ctrlPanelSizer) self.showY0 = True + self.selectedY = None for view in Graph.views: view = view() @@ -257,9 +258,15 @@ class GraphFrame(wx.Frame): return values def OnShowY0Update(self, event): + event.Skip() self.showY0 = self.showY0Cb.GetValue() self.draw() + def OnYTypeUpdate(self, event): + event.Skip() + self.selectedY = event.GetInt() + self.draw() + def updateGraphWidgets(self): view = self.getView() view.clearCache() @@ -274,8 +281,15 @@ class GraphFrame(wx.Frame): self.showY0Cb = wx.CheckBox(self.graphCtrlPanel, wx.ID_ANY, "Always show Y = 0", wx.DefaultPosition, wx.DefaultSize, 0) self.showY0Cb.SetValue(self.showY0) self.showY0Cb.Bind(wx.EVT_CHECKBOX, self.OnShowY0Update) - viewSizer.Add(self.showY0Cb, 0, wx.ALL | wx.EXPAND, 5) - + viewSizer.Add(self.showY0Cb, 0, wx.ALL | wx.EXPAND, 0) + if len(view.yDefs) > 1: + self.selectedYRb = wx.RadioBox( + self.graphCtrlPanel, 0, 'Graph type', wx.DefaultPosition, wx.DefaultSize, + [yDef.switchLabel for yDef in view.yDefs.values()], 1, wx.RA_SPECIFY_COLS) + self.selectedYRb.SetSelection(self.selectedY or 0) + self.selectedYRb.Bind(wx.EVT_RADIOBOX, self.OnYTypeUpdate) + viewSizer.Add(self.selectedYRb, 0, wx.ALL | wx.EXPAND, 0) + viewSizer.Layout() # Setup inputs for fieldHandle, fieldDef in (('x', view.xDef), *view.extraInputs.items()): @@ -329,10 +343,10 @@ class GraphFrame(wx.Frame): xRange = values['x'] extraInputs = {ih: values[ih] for ih in view.extraInputs} - chosenY = None - for handle in view.yDefs: - chosenY = handle - break + try: + chosenY = [i for i in view.yDefs.keys()][self.selectedY or 0] + except IndexError: + chosenY = [i for i in view.yDefs.keys()][0] self.subplot.set(xlabel=view.xDef.axisLabel, ylabel=view.yDefs[chosenY].axisLabel)