示例#1
0
    def draw(self):
        """
        Draw the shape, text, etc
        """
        self.Figure()

        self.DrawActual(self.x, self.y)
        self.DrawTarget(self.x + 70, self.y)
        canv_utils.DrawRectangle(self.canv, (self.x, -self.y),
                                 (self.width, self.height))
        canv_utils.DrawRectangle(self.canv, (self.x + 70, -self.y),
                                 (self.width, self.height))
示例#2
0
 def draw(self):
     """
     Draw the shape, text, etc
     """
     self.setTitle("--- Blood Pressure Graph ---")
     self.setXlabel("Time")
     self.setYLabel("Blood Pressure")
     canv_utils.DrawRectangle(self.canv, (0, 0), (self.width, self.height))
     # canv_utils.DrawRectangle(self.canv, (self.pX, self.pY), (self.pWidth, self.pHeight), color=(0.0, 0.0, 0.0, 0.1), fill=1)
     from datetime import datetime
     start = datetime(year=2000,
                      month=1,
                      day=1,
                      hour=0,
                      minute=0,
                      second=0,
                      microsecond=0).timestamp()
     end = datetime(year=2000,
                    month=1,
                    day=1,
                    hour=23,
                    minute=59,
                    second=59,
                    microsecond=999999).timestamp()
     data = generator.GenerateData(start, end)
     flowable = BPGraph(data, width=self.pWidth, height=self.pHeight)
     canv_utils.DrawCustomFlowable(self.canv, flowable, (self.pX, self.pY),
                                   (self.aw, self.ah))
示例#3
0
    def draw(self):
        """
        Draw the shape, text, etc
        """
        if self.dp.Title is not None: self.setTitle(self.dp.Title)
        if self.dp.xLabel is not None: self.setXlabel(self.dp.xLabel)
        if self.dp.yLabel is not None: self.setYLabel(self.dp.yLabel)
        if self.dp.Boundary:
            canv_utils.DrawRectangle(self.canv, (0, 0),
                                     (self.width, self.height))

        flowable = DrawAxis(self, width=self.pWidth, height=self.pHeight)
        canv_utils.DrawCustomFlowable(self.canv, flowable, (self.pX, self.pY),
                                      (self.aw, self.ah))

        for gd in self.dp.Plots:
            if gd['type'] in [
                    'lineplot', 'fillbetween', 'fillabove', 'fillbelow'
            ]:
                flowable = LineGraph(self,
                                     gd,
                                     width=self.pWidth,
                                     height=self.pHeight)
            elif gd['type'] == 'range':
                flowable = RangePlot(self,
                                     gd,
                                     width=self.pWidth,
                                     height=self.pHeight)
            else:
                print("We Don't Support Graph of Type", gd['type'])
                continue
            canv_utils.DrawCustomFlowable(self.canv, flowable,
                                          (self.pX, self.pY),
                                          (self.aw, self.ah))
示例#4
0
 def Figure(self, grid=False):
     canv_utils.DrawRectangle(self.canv, (0, 0), (self.width, self.height))
     self.canv.saveState()
     self.canv.setStrokeColor(Color(0.1, 0.1, 0.1, 0.3))
     self.canv.setFontSize(9)
     self.DrawVGrid(grid)
     self.DrawHGrid(grid)
     self.canv.restoreState()
示例#5
0
 def draw(self):
     """
     Draw the shape, text, etc
     """
     self.setTitle("--- Blood Pressure Graph ---")
     self.setXlabel("Time")
     self.setYLabel("Blood Pressure")
     canv_utils.DrawRectangle(self.canv, (0, 0), (self.width, self.height))
     # canv_utils.DrawRectangle(self.canv, (self.pX, self.pY), (self.pWidth, self.pHeight), color=(0.0, 0.0, 0.0, 0.1), fill=1)
     flowable = BPGraph(self.data, width=self.pWidth, height=self.pHeight)
     canv_utils.DrawCustomFlowable(self.canv, flowable, (self.pX, self.pY),
                                   (self.aw, self.ah))
示例#6
0
    def DrawTarget(self, x, y):
        current = 0
        font_size = 10

        canv_utils.WriteText(self.canv,
                             "Target",
                             x=x + 35,
                             y=y + 70,
                             rot=-0,
                             font_size=15)
        for i in range(len(self.data)):
            height = self.height * (self.data.iloc[i].target /
                                    self.Stats['target']['sum'])
            text_vloc = -(y - (self.height * self.TextPos[i]))
            center_of_graph = -(y - current) + (height / 2)

            # canv_utils.DrawLine(self.canv, (x - font_size - 18, text_vloc), (x, center_of_graph), color=self.Colors[i])
            # canv_utils.WriteText(self.canv, self.data.iloc[i].range, x=x - font_size - 20, y=text_vloc,
            #                      rot=-0, font_size=font_size)

            canv_utils.DrawLine(self.canv, (x + self.width, center_of_graph),
                                (x + font_size + self.width + 18, text_vloc),
                                color=self.Colors[i])
            canv_utils.WriteLeftAlignedText(self.canv,
                                            self.data.iloc[i].category,
                                            x=x + font_size + self.width + 20,
                                            y=text_vloc,
                                            rot=-0,
                                            font_size=font_size)

            canv_utils.DrawRectangle(self.canv, (x, -(y - current)),
                                     (self.width, height),
                                     fill=1,
                                     stroke=0,
                                     color=self.Colors[i])
            current += height
示例#7
0
    def DrawActual(self, x, y, border=False):
        current = 0
        font_size = 10

        canv_utils.WriteText(self.canv,
                             "Actual",
                             x=x + 35,
                             y=y + 70,
                             rot=-0,
                             font_size=15)
        for i in range(len(self.data)):
            height = self.height * (self.data.iloc[i].actual / 100)
            text_vloc = -(y - (self.height * self.TextPos[i]))
            center_of_graph = -(y - current) + (height / 2)

            canv_utils.DrawLine(self.canv, (x - font_size - 18, text_vloc),
                                (x, center_of_graph),
                                color=self.Colors[i])
            canv_utils.WriteText(self.canv,
                                 self.data.iloc[i].range,
                                 x=x - font_size - 20,
                                 y=text_vloc,
                                 rot=-0,
                                 font_size=font_size)

            # canv_utils.DrawLine(self.canv, (x + self.width, center_of_graph),
            #                     (x + font_size + self.width + 18, text_vloc), color=self.Colors[i])
            # canv_utils.WriteLeftAlignedText(self.canv, self.data.iloc[i].category, x=x + font_size + self.width + 20,
            #                                 y=text_vloc, rot=-0, font_size=font_size)

            canv_utils.DrawRectangle(self.canv, (x, -(y - current)),
                                     (self.width, height),
                                     fill=1,
                                     stroke=0,
                                     color=self.Colors[i])
            current += height
    def draw(self):
        """
        Draw the shape, text, etc
        """
        self.Figure(grid=True)
        area = self.Stats['xAxis']['major_size']
        padding = 0.07
        center_space = 0.07
        padding_size = padding * area
        center_size = center_space * area
        bar_size = (area - (padding_size * 2 + center_size)) / 2

        self.canv.saveState()
        self.canv.setFontSize(8)
        self.canv.setFillColorRGB(0.2, 0.2, 0.2, 1.0)
        for i in range(len(self.data)):
            data_row = self.data.iloc[i]
            actual = canv_utils.Point2Pixel(0, self.Stats['yAxis']['max'], 0,
                                            self.height,
                                            max(data_row.actual, 0.2))
            target = canv_utils.Point2Pixel(0, self.Stats['yAxis']['max'], 0,
                                            self.height,
                                            max(data_row.target, 0.2))
            xy = (padding_size + area * i, 0)
            wh = (bar_size, actual)

            xy2 = (padding_size + center_size + bar_size + area * i, 0)
            wh2 = (bar_size, target)

            # print("XY: ", xy)
            # print("WH: ", wh)
            # print("bar_size: ", bar_size, "padding_size: ", padding_size, "center_size",  center_size)
            # Actual Bar
            w_txt, h_txt = canv_utils.GetFontWidhHeight(
                f"A: {data_row.actual}%", self.canv._fontname,
                self.canv._fontsize)
            canv_utils.DrawRectangle(self.canv,
                                     xy,
                                     wh,
                                     fill=1,
                                     color=self.Colors[i],
                                     stroke=0)
            canv_utils.WriteText(self.canv,
                                 f"A: {data_row.actual}%",
                                 xy[0] + wh[0] / 2 + w_txt / 2,
                                 wh[1] / 2,
                                 rot=0)

            # Target Bar
            w_txt, h_txt = canv_utils.GetFontWidhHeight(
                f"T: {data_row.target}%", self.canv._fontname,
                self.canv._fontsize)
            canv_utils.DrawRectangle(self.canv,
                                     xy2,
                                     wh2,
                                     fill=1,
                                     color=self.Colors[i],
                                     stroke=0)
            canv_utils.WriteText(self.canv,
                                 f"T: {data_row.target}%",
                                 xy2[0] + wh2[0] / 2 + w_txt / 2,
                                 wh2[1] / 2,
                                 rot=0)

        self.canv.restoreState()
    def draw(self):

        canv_utils.DrawRectangle(self.canv, (0, 0), (self.width, self.height))
        self.DrawWeeks()