mirror of https://gitlab.com/pamhyr/pamhyr2
BC: Edit: Add plot display mode 'time' and 'date'.
parent
7a7e714ea4
commit
67af95cb40
|
|
@ -14,13 +14,16 @@ from View.BoundaryCondition.Edit.translate import *
|
|||
_translate = QCoreApplication.translate
|
||||
|
||||
class Plot(APlot):
|
||||
def __init__(self, canvas=None, data=None, toolbar=None):
|
||||
def __init__(self, canvas=None, data=None,
|
||||
mode = "time", toolbar=None):
|
||||
super(Plot, self).__init__(
|
||||
canvas=canvas,
|
||||
data=data,
|
||||
toolbar=toolbar
|
||||
)
|
||||
|
||||
self._mode = mode
|
||||
|
||||
def custom_ticks(self):
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
nb = len(self.data.data)
|
||||
|
|
@ -36,16 +39,24 @@ class Plot(APlot):
|
|||
)
|
||||
)
|
||||
xx = list(map(lambda v: v[0], fx))
|
||||
xt = list(
|
||||
map(
|
||||
lambda v: str(
|
||||
datetime.fromtimestamp(v[0]) - t0
|
||||
).split(",")[0]\
|
||||
.replace("days", _translate("BoundaryCondition", "days"))\
|
||||
.replace("day", _translate("BoundaryCondition", "day")),
|
||||
fx
|
||||
if self._mode == "time":
|
||||
xt = list(
|
||||
map(
|
||||
lambda v: str(
|
||||
datetime.fromtimestamp(v[0]) - t0
|
||||
).split(",")[0]\
|
||||
.replace("days", _translate("BoundaryCondition", "days"))\
|
||||
.replace("day", _translate("BoundaryCondition", "day")),
|
||||
fx
|
||||
)
|
||||
)
|
||||
else:
|
||||
xt = list(
|
||||
map(
|
||||
lambda v: str(datetime.fromtimestamp(v[0]).date()),
|
||||
fx
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self.canvas.axes.set_xticks(ticks=xx, labels=xt, rotation=45)
|
||||
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._data,
|
||||
mode = self._study.time_system,
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue