diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 87cdb50..ea9da49 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -517,6 +517,13 @@ def get_test_routes(app): pie.legend_at_bottom_columns = 4 return pie.render_response() + @app.route('/test/interpolate/secondary') + def test_interpolate_secondary(): + chart = Line(title=u'Some different points', interpolate='cubic') + chart.add('line', [1000, 2000, 7000]) + chart.add('other line', [100, 500, 500], secondary=True) + return chart.render_response() + @app.route('/test/legend_at_bottom/') def test_legend_at_bottom_for(chart): graph = CHARTS_BY_NAME[chart]() diff --git a/pygal/graph/bar.py b/pygal/graph/bar.py index 55b6680..5cf7543 100644 --- a/pygal/graph/bar.py +++ b/pygal/graph/bar.py @@ -61,9 +61,7 @@ class Bar(Graph): serie_node = self.svg.serie(serie) bars = self.svg.node(serie_node['plot'], class_="bars") if rescale and self.secondary_series: - points = [ - (x, self._scale_diff + (y - self._scale_min_2nd) * self._scale) - for x, y in serie.points if y is not None] + points = self._rescale(serie.points) else: points = serie.points diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index 3578610..87cf6be 100644 --- a/pygal/graph/graph.py +++ b/pygal/graph/graph.py @@ -419,6 +419,11 @@ class Graph(BaseGraph): x, y, self.interpolation_precision, **self.interpolation_parameters)) + def _rescale(self, points): + return [ + (x, self._scale_diff + (y - self._scale_min_2nd) * self._scale) + for x, y in points if y is not None] + def _tooltip_data(self, node, value, x, y, classes=None): self.svg.node(node, 'desc', class_="value").text = value if classes is None: diff --git a/pygal/graph/line.py b/pygal/graph/line.py index 65e92f2..fe16568 100644 --- a/pygal/graph/line.py +++ b/pygal/graph/line.py @@ -69,7 +69,11 @@ class Line(Graph): if y is not None: break else: - raise ValueError("Invalid value ({}) for config key 'missing_value_fill_truncation'; Use 'x', 'y' or 'either'".format(self.missing_value_fill_truncation)) + raise ValueError( + "Invalid value ({}) for config key " + "'missing_value_fill_truncation';" + " Use 'x', 'y' or 'either'".format( + self.missing_value_fill_truncation)) end -= 1 return ([(values[0][0], zero)] + @@ -80,9 +84,7 @@ class Line(Graph): """Draw the line serie""" serie_node = self.svg.serie(serie) if rescale and self.secondary_series: - points = [ - (x, self._scale_diff + (y - self._scale_min_2nd) * self._scale) - for x, y in serie.points if y is not None] + points = self._rescale(serie.points) else: points = serie.points view_values = list(map(self.view, points)) @@ -118,7 +120,10 @@ class Line(Graph): if serie.stroke: if self.interpolate: - view_values = list(map(self.view, serie.interpolated)) + points = serie.interpolated + if rescale and self.secondary_series: + points = self._rescale(points) + view_values = list(map(self.view, points)) if serie.fill: view_values = self._fill(view_values) self.svg.line(