Beispiel #1
0
    def __init__(self, config, series, secondary_series, uuid, xml_filters):
        """Init the graph"""
        self.uuid = uuid
        self.__dict__.update(config.to_dict())
        self.config = config
        self.series = series or []
        self.secondary_series = secondary_series or []
        self.xml_filters = xml_filters or []
        self.horizontal = getattr(self, 'horizontal', False)
        self.svg = Svg(self)
        self._x_labels = None
        self._y_labels = None
        self._x_2nd_labels = None
        self._y_2nd_labels = None
        self.nodes = {}
        self.margin = Margin(*([self.margin] * 4))
        self._box = Box()
        self.view = None
        if self.logarithmic and self.zero == 0:
            # Explicit min to avoid interpolation dependency
            if self._dual:
                get = lambda x: x[1] or 1
            else:
                get = lambda x: x

            positive_values = list(filter(
                lambda x: x > 0,
                [get(val)
                 for serie in self.series for val in serie.safe_values]))

            self.zero = min(positive_values or (1,)) or 1
        self._draw()
        self.svg.pre_render()
Beispiel #2
0
    def __init__(self, config, series, secondary_series, uuid):
        """Init the graph"""
        self.uuid = uuid
        self.config = config
        self.series = series or []
        self.secondary_series = secondary_series or []
        self.horizontal = getattr(self, 'horizontal', False)
        self.svg = Svg(self)
        self._x_labels = None
        self._y_labels = None
        self._x_2nd_labels = None
        self._y_2nd_labels = None
        self.nodes = {}
        self.margin = Margin(*([self.margin] * 4))
        self._box = Box()
        self.view = None
        if self.logarithmic and self.zero == 0:
            # Explicit min to avoid interpolation dependency
            from pygal.graph.xy import XY
            if isinstance(self, XY):
                get = lambda x: x[1]
            else:
                get = lambda x: x

            positive_values = list(
                filter(lambda x: x > 0, [
                    get(val) for serie in self.series
                    for val in serie.safe_values
                ]))

            self.zero = min(positive_values) if positive_values else 0
        self._draw()
        self.svg.pre_render()
Beispiel #3
0
    def setup(self, **kwargs):
        """Set up the transient state prior rendering"""
        # Keep labels in case of map
        if getattr(self, 'x_labels', None) is not None:
            self.x_labels = list(self.x_labels)
        if getattr(self, 'y_labels', None) is not None:
            self.y_labels = list(self.y_labels)
        self.state = State(self, **kwargs)
        if isinstance(self.style, type):
            self.style = self.style()
        self.series = self.prepare_values([
            rs for rs in self.raw_series if not rs[1].get('secondary')
        ]) or []
        self.secondary_series = self.prepare_values([
            rs for rs in self.raw_series if rs[1].get('secondary')
        ], len(self.series)) or []
        self.horizontal = getattr(self, 'horizontal', False)
        self.svg = Svg(self)
        self._x_labels = None
        self._y_labels = None
        self._x_2nd_labels = None
        self._y_2nd_labels = None
        self.nodes = {}
        self.margin_box = Margin(
            self.margin_top or self.margin, self.margin_right or self.margin,
            self.margin_bottom or self.margin, self.margin_left or self.margin
        )
        self._box = Box()
        self.view = None
        if self.logarithmic and self.zero == 0:
            # Explicit min to avoid interpolation dependency
            positive_values = list(
                filter(
                    lambda x: x > 0, [
                        val[1] or 1 if self._dual else val
                        for serie in self.series for val in serie.safe_values
                    ]
                )
            )

            self.zero = min(positive_values or (1, )) or 1
        if self._len < 3:
            self.interpolate = None
        self._draw()
        self.svg.pre_render()
Beispiel #4
0
    def __init__(self, config, series):
        """Init the graph"""
        self.config = config
        self.series = series
        self.horizontal = getattr(self, 'horizontal', False)
        self.svg = Svg(self)
        self._x_labels = None
        self._y_labels = None
        self.nodes = {}
        self.margin = Margin(*([20] * 4))
        self._box = Box()
        self.view = None

        if self.series and self._has_data():
            self._draw()
        else:
            self.svg.draw_no_data()

        self.svg.pre_render()
Beispiel #5
0
 def __init__(self, config, series):
     """Init the graph"""
     self.config = config
     self.series = series or []
     self.horizontal = getattr(self, 'horizontal', False)
     self.svg = Svg(self)
     self._x_labels = None
     self._y_labels = None
     self.nodes = {}
     self.margin = Margin(*([20] * 4))
     self._box = Box()
     self.view = None
     if self.logarithmic and self.zero == 0:
         # Explicit min to avoid interpolation dependency
         self.zero = min(
             filter(lambda x: x > 0, [
                 val for serie in self.series for val in serie.safe_values
             ]))
     self._draw()
     self.svg.pre_render()
Beispiel #6
0
    def __init__(self, config, series):
        """Init the graph"""
        self.config = config
        self.series = series
        self.horizontal = getattr(self, 'horizontal', False)
        self.svg = Svg(self)
        self._x_labels = None
        self._y_labels = None
        self.nodes = {}
        self.margin = Margin(*([20] * 4))
        self._box = Box()
        self.view = None
        if self.logarithmic and self.zero == 0:
            # Explicit min to avoid interpolation dependency
            self.zero = min(val for serie in self.series
                            for val in serie.values)

        if self.series and self._has_data():
            self._draw()
        else:
            self.svg.draw_no_data()

        self.svg.pre_render()