(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY)
Iterate through the Poster's years, creating a calendar for each.
Iterate through the Poster's years, creating a calendar for each.
Iterate through the Poster s years creating a calendar for each .
def draw(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY) -> None:
        """Iterate through the Poster's years, creating a calendar for each."""
        if self.poster.tracks is None:
            raise PosterError("No tracks to draw.")
        years = self.poster.years.count()
        _, counts = utils.compute_grid(years, size)
        if counts is None:
            raise PosterError("Unable to compute grid.")
        count_x, count_y = counts[0], counts[1]
        x, y = 0, 0
        cell_size = size * XY(1 / count_x, 1 / count_y)
        margin = XY(4, 8)
        if count_x <= 1:
            margin.x = 0
        if count_y <= 1:
            margin.y = 0
        sub_size = cell_size - 2 * margin

        for year in self.poster.years.iter():
            g_year = dr.g(id=f"year{year}")
            g.add(g_year)
            self._draw(dr, g_year, sub_size, offset + margin + cell_size * XY(x, y), year)
            x += 1
            if x >= count_x:
                x = 0
                y += 1
def draw ( self , dr : svgwrite . Drawing , g : svgwrite . container . Group , size : XY , offset : XY ) -> None : if self . poster . tracks is None : raise PosterError ( "No tracks to draw." ) years = self . poster . years . count ( ) _ , counts = utils . compute_grid ( years , size ) if counts is None : raise PosterError ( "Unable to compute grid." ) count_x , count_y = counts [ 0 ] , counts [ 1 ] x , y = 0 , 0 cell_size = size * XY ( 1 / count_x , 1 / count_y ) margin = XY ( 4 , 8 ) if count_x <= 1 : margin . x = 0 if count_y <= 1 : margin . y = 0 sub_size = cell_size - 2 * margin for year in self . poster . years . iter ( ) : g_year = dr . g ( id = f"year{year}" ) g . add ( g_year ) self . _draw ( dr , g_year , sub_size , offset + margin + cell_size * XY ( x , y ) , year ) x += 1 if x >= count_x : x = 0 y += 1