Skip to content

Commit

Permalink
fixes the date display in plots
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Dec 10, 2024
1 parent 78b5714 commit 7b058c2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/asammdf/blocks/mdf_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -9494,7 +9494,7 @@ def save(
dl_block = DataList(**kwargs)

for i, data__ in enumerate(data):

data_ = data__[0]

if compression and self.version >= "4.10":
Expand Down
13 changes: 7 additions & 6 deletions src/asammdf/gui/widgets/formated_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ def tickStrings(self, values, scale, spacing):
strns = [str(timedelta(seconds=val)) for val in values]
elif self.format == "date":
strns = (
pd.to_datetime(
np.array(values) + self.origin.timestamp(),
unit="s",
errors="coerce",
(
pd.to_timedelta(
np.array(values),
unit="s",
errors="coerce",
)
+ self.origin
)
.tz_localize("UTC")
.tz_convert(LOCAL_TIMEZONE)
.astype(str)
.to_list()
)
Expand Down
4 changes: 3 additions & 1 deletion src/asammdf/gui/widgets/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
from traceback import format_exc
from zipfile import ZIP_DEFLATED, ZipFile

import dateutil.tz
import numpy as np
import pyqtgraph as pg
from pyqtgraph import Qt
import pyqtgraph.functions as fn
from PySide6 import QtCore, QtGui, QtWidgets

PLOT_BUFFER_SIZE = 4000
LOCAL_TIMEZONE = dateutil.tz.tzlocal()


from ... import tool as Tool
Expand Down Expand Up @@ -3682,7 +3684,7 @@ def __init__(
else:
fmt = "phys"
self.x_axis.format = fmt
self.x_axis.origin = origin
self.x_axis.origin = origin.astimezone(LOCAL_TIMEZONE)

self.y_axis = FormatedAxis(
"left", maxTickLength=-5, background=self.backgroundBrush().color(), linked_signal=(self, None)
Expand Down
1 change: 0 additions & 1 deletion src/asammdf/gui/widgets/tabular_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,6 @@ def to_config(self):
return config

def time_as_date_changed(self, state):
s = self.start
count = self.filters.count()

if state == QtCore.Qt.CheckState.Checked:
Expand Down

0 comments on commit 7b058c2

Please sign in to comment.