work on DateAxisItem
This commit is contained in:
parent
2ca4cddff7
commit
dde6a2ac4c
@ -16,19 +16,34 @@ class DateAxis(pg.AxisItem):
|
|||||||
def tickStrings(self, values, scale, spacing):
|
def tickStrings(self, values, scale, spacing):
|
||||||
strns = []
|
strns = []
|
||||||
rng = max(values)-min(values)
|
rng = max(values)-min(values)
|
||||||
if rng < 120:
|
#if rng < 120:
|
||||||
return pg.AxisItem.tickStrings(self, values, scale, spacing)
|
# return pg.AxisItem.tickStrings(self, values, scale, spacing)
|
||||||
elif rng >= 120 and rng < 3600*24:
|
if rng < 3600*24:
|
||||||
string = '%H:%M:%S'
|
string = '%H:%M:%S'
|
||||||
|
label1 = '%b %d -'
|
||||||
|
label2 = ' %b %d, %Y'
|
||||||
elif rng >= 3600*24 and rng < 3600*24*30:
|
elif rng >= 3600*24 and rng < 3600*24*30:
|
||||||
string = '%d'
|
string = '%d'
|
||||||
elif rng >= 3600*24*30:
|
label1 = '%b - '
|
||||||
string = '%b %Y'
|
label2 = '%b, %Y'
|
||||||
|
elif rng >= 3600*24*30 and rng < 3600*24*30*24:
|
||||||
|
string = '%b'
|
||||||
|
label1 = '%Y -'
|
||||||
|
label2 = ' %Y'
|
||||||
|
elif rng >=3600*24*30*24:
|
||||||
|
string = '%Y'
|
||||||
|
label1 = ''
|
||||||
|
label2 = ''
|
||||||
for x in values:
|
for x in values:
|
||||||
try:
|
try:
|
||||||
strns.append(time.strftime(string, time.localtime(x)))
|
strns.append(time.strftime(string, time.localtime(x)))
|
||||||
except ValueError: ## Windows can't handle dates before 1970
|
except ValueError: ## Windows can't handle dates before 1970
|
||||||
strns.append('')
|
strns.append('')
|
||||||
|
try:
|
||||||
|
label = time.strftime(label1, time.localtime(min(values)))+time.strftime(label2, time.localtime(max(values)))
|
||||||
|
except ValueError:
|
||||||
|
label = ''
|
||||||
|
#self.setLabel(text=label)
|
||||||
return strns
|
return strns
|
||||||
|
|
||||||
class CustomViewBox(pg.ViewBox):
|
class CustomViewBox(pg.ViewBox):
|
||||||
|
Loading…
Reference in New Issue
Block a user