(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY)
Draw the heatmap based on tracks.
Draw the heatmap based on tracks.
Draw the heatmap based on tracks .
def draw(self, dr: svgwrite.Drawing, g: svgwrite.container.Group, size: XY, offset: XY) -> None:
        """Draw the heatmap based on tracks."""
        bbox = self._determine_bbox()
        line_transparencies_and_widths = self._get_line_transparencies_and_widths(bbox)
        year_groups: Dict[int, svgwrite.container.Group] = {}
        for tr in self.poster.tracks:
            year = tr.start_time().year
            if year not in year_groups:
                g_year = dr.g(id=f"year{year}")
                g.add(g_year)
                year_groups[year] = g_year
            else:
                g_year = year_groups[year]
            color = self.color(self.poster.length_range, tr.length(), tr.special)
            for line in utils.project(bbox, size, offset, tr.polylines):
                for opacity, width in line_transparencies_and_widths:
                    g_year.add(
                        dr.polyline(
                            points=line,
                            stroke=color,
                            stroke_opacity=opacity,
                            fill="none",
                            stroke_width=width,
                            stroke_linejoin="round",
                            stroke_linecap="round",
                        )
                    )
def draw ( self , dr : svgwrite . Drawing , g : svgwrite . container . Group , size : XY , offset : XY ) -> None : bbox = self . _determine_bbox ( ) line_transparencies_and_widths = self . _get_line_transparencies_and_widths ( bbox ) year_groups : Dict [ int , svgwrite . container . Group ] = { } for tr in self . poster . tracks : year = tr . start_time ( ) . year if year not in year_groups : g_year = dr . g ( id = f"year{year}" ) g . add ( g_year ) year_groups [ year ] = g_year else : g_year = year_groups [ year ] color = self . color ( self . poster . length_range , tr . length ( ) , tr . special ) for line in utils . project ( bbox , size , offset , tr . polylines ) : for opacity , width in line_transparencies_and_widths : g_year . add ( dr . polyline ( points = line , stroke = color , stroke_opacity = opacity , fill = "none" , stroke_width = width , stroke_linejoin = "round" , stroke_linecap = "round" , ) )