From af5a5d3eb362ed31ca15e5b75bef212fa14aa297 Mon Sep 17 00:00:00 2001 From: Megan Kratz Date: Sat, 10 Nov 2012 11:22:56 -0500 Subject: [PATCH] Start of work on DateAxis --- examples/customPlot.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/customPlot.py b/examples/customPlot.py index 451ae501..187da5e9 100644 --- a/examples/customPlot.py +++ b/examples/customPlot.py @@ -15,9 +15,18 @@ import time class DateAxis(pg.AxisItem): def tickStrings(self, values, scale, spacing): strns = [] + rng = max(values)-min(values) + if rng < 120: + return pg.AxisItem.tickStrings(self, values, scale, spacing) + elif rng >= 120 and rng < 3600*24: + string = '%H:%M:%S' + elif rng >= 3600*24 and rng < 3600*24*30: + string = '%d' + elif rng >= 3600*24*30: + string = '%b %Y' for x in values: try: - strns.append(time.strftime('%b %Y', time.localtime(x))) + strns.append(time.strftime(string, time.localtime(x))) except ValueError: ## Windows can't handle dates before 1970 strns.append('') return strns