Distrotech / reportlab

Mirror of https://bitbucket.org/rptlab/reportlab
Other
61 stars 41 forks source link

Time Plot #6

Open pabloariasmora opened 6 years ago

pabloariasmora commented 6 years ago

Hi! I'm trying to plot time chart, time(hours) vs temperature.

class simple_time_chart(_DrawingEditorMixin, Drawing):
    def __init__(self, width=600, height=400, *args, **kw):
        Drawing.__init__(self, width, height, *args, **kw)
        self._add(self, SimpleTimeSeriesPlot(), name='chart', validate=None,
                  desc=None)
        self.chart.x = 30
        self.chart.y = 30
        self.chart.height = 90
        self.chart.yValueAxis.forceZero = 0
        self._add(self, String(10, 10, 'text'), name='title', validate=None,
                  desc=None)
        self.title.text = 'Prueba'
        self.title.fontSize = 16
        self.chart.lines[0].strokeColor = PCMYKColor(100, 0, 90, 50, alpha=100)
        self.chart.lines.strokeWidth = 1
        self.chart.xValueAxis.labelTextFormat  = '{dd} {mm} {YY} {HH}:{MM}:{SS}'
        self.chart.data = [[('21 01 2018 15:23:27', 10), ('21 01 2018 15:24:14', 100), ('21 01 2018 15:24:24', 200), ('21 01 2018 15:24:26', 30)]]
        self.chart.width = 335
        self.title.y = 160
        self.title.x = 115

simple_time_chart (width=600, height=400)

But it fails showing this error:

reportlab.lib.normalDate.NormalDateException: unable to setNormalDate('21 01 2018 15:23:27')

As far as I could understand on the NormalDate class hours are not allowed. So in order to create a graph with time as part of it, what will be the best approach?