diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 97c05d6..5a77701 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -672,6 +672,29 @@ def get_test_routes(app): graph.legend_at_bottom = True return graph.render_response() + @app.route('/test/sparkline/label/') + def test_sparkline_label_for(chart): + graph = CHARTS_BY_NAME[chart](**dict( + width=200, + height=50, + show_dots=False, + show_legend=False, + # show_y_labels=False, + # show_x_labels=False, + spacing=0, + margin=5, + min_scale=2, + max_scale=2, + explicit_size=True + )) + graph.add('1', [1, 3, 12, 3, 4, None, 9]) + graph.add('2', [7, -4, 10, None, 8, 3, 1]) + graph.add('3', [7, -14, -10, None, 8, 3, 1]) + graph.add('4', [7, 4, -10, None, 8, 3, 1]) + graph.x_labels = ('a', 'b', 'c', 'd', 'e', 'f', 'g') + graph.legend_at_bottom = True + return graph.render_response() + @app.route('/test/normal/') def test_normal_for(chart): graph = CHARTS_BY_NAME[chart]() diff --git a/docs/documentation/sparks.rst b/docs/documentation/sparks.rst index c36dbd0..7d1b1e0 100644 --- a/docs/documentation/sparks.rst +++ b/docs/documentation/sparks.rst @@ -22,16 +22,26 @@ Sparklines support the same options as normal charts but for those that are over .. pygal-code:: sparkline chart = pygal.Line(interpolate='cubic') - chart.add('', [1, 3, 5, 16, 13, 3, 7]) + chart.add('', [1, 3, 5, 16, 13, 3, 7]) chart.render_sparkline() .. pygal-code:: sparkline from pygal.style import LightSolarizedStyle chart = pygal.Line(style=LightSolarizedStyle) - chart.add('', [1, 3, 5, 16, 13, 3, 7, 9, 2, 1, 4, 9, 12, 10, 12, 16, 14, 12, 7, 2]) + chart.add('', [1, 3, 5, 16, 13, 3, 7, 9, 2, 1, 4, 9, 12, 10, 12, 16, 14, 12, 7, 2]) chart.render_sparkline(width=500, height=25, show_dots=True) +With labels: + +.. pygal-code:: sparkline + + from pygal.style import LightSolarizedStyle + chart = pygal.Line(style=LightSolarizedStyle) + chart.add('', [1, 3, 5, 16, 13, 3, 7]) + chart.x_labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] + chart.render_sparkline(show_x_labels=True, show_y_labels=True) + Sparktext --------- diff --git a/pygal/graph/public.py b/pygal/graph/public.py index 7736a54..afc01e3 100644 --- a/pygal/graph/public.py +++ b/pygal/graph/public.py @@ -139,6 +139,8 @@ class PublicApi(BaseGraph): show_y_labels=False, spacing=0, margin=5, + min_scale=1, + max_scale=2, explicit_size=True ) spark_options.update(kwargs)