From ebfe90a553a49d4a16286fe11d1807cefd243974 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Tue, 23 Feb 2016 15:41:13 +0100 Subject: [PATCH] Update documentation --- demo/moulinrouge/tests.py | 11 +++++++++++ docs/api/pygal.graph.rst | 2 ++ docs/documentation/configuration/serie.rst | 16 ++++++++++++++++ docs/documentation/types/line.rst | 19 ++++++------------- docs/documentation/types/xy.rst | 8 +++++--- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 3bc6d0c..9176b44 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -1071,6 +1071,17 @@ def get_test_routes(app): chart.range = (30, 200) return chart.render_response() + @app.route('/test/interruptions') + def test_interruptions(): + chart = Line(allow_interruptions=True) + chart.add( + 'interrupt', [22, 34, 43, 12, None, 12, 55, None, 56], + allow_interruptions=False) + chart.add('not interrupt', [ + -a if a else None + for a in (22, 34, 43, 12, None, 12, 55, None, 56)]) + return chart.render_response() + return list(sorted(filter( lambda x: x.startswith('test') and not x.endswith('_for'), locals())) ) + list(sorted(filter( diff --git a/docs/api/pygal.graph.rst b/docs/api/pygal.graph.rst index 05f78b1..93f021f 100644 --- a/docs/api/pygal.graph.rst +++ b/docs/api/pygal.graph.rst @@ -22,7 +22,9 @@ Submodules pygal.graph.histogram pygal.graph.horizontal pygal.graph.horizontalbar + pygal.graph.horizontalline pygal.graph.horizontalstackedbar + pygal.graph.horizontalstackedline pygal.graph.line pygal.graph.map pygal.graph.pie diff --git a/docs/documentation/configuration/serie.rst b/docs/documentation/configuration/serie.rst index 9f3a3d8..8165dfb 100644 --- a/docs/documentation/configuration/serie.rst +++ b/docs/documentation/configuration/serie.rst @@ -122,3 +122,19 @@ inner_radius chart = pygal.Pie() for i in range(10): chart.add(str(i), i, inner_radius=(10 - i) / 10) + + + +allow_interruptions +~~~~~~~~~~~~~~~~~~~ + +You can set `allow_interruptions` to True in order to break lines on None values. + +.. pygal-code:: + + interrupted_chart = pygal.Line() + interrupted_chart.add( + 'Temperature', [22, 34, 43, 12, None, 12, 55, None, 56], + allow_interruptions=True) + interrupted_chart.add( + 'Temperature', [11, 17, 21.5, 6, None, 6, 27.5, None, 28]) diff --git a/docs/documentation/types/line.rst b/docs/documentation/types/line.rst index 287aec1..071b941 100644 --- a/docs/documentation/types/line.rst +++ b/docs/documentation/types/line.rst @@ -17,19 +17,6 @@ Basic simple line graph: line_chart.add('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5]) - Interruptions - ^^^^^^^^^^^^^ - - If you happen to want a break in the middle of a plot, you can pass None values. Additionally, - you will need to specify allow_interruptions=True in the constructor, in order for the behaviour - to be supported correctly - - .. pygal-code:: - - interrupted_chart = pygal.Line(allow_interruptions=True) - interrupted_chart.add('Temperature', [22, 34, 43, 12, None, 12, 55, None, 56]) - - Stacked ~~~~~~~ @@ -61,3 +48,9 @@ For time related plots, just format your labels or use `one variant of xy charts datetime(2013, 2, 2), datetime(2013, 2, 22)]) date_chart.add("Visits", [300, 412, 823, 672]) + + +None values +~~~~~~~~~~~ + +None values will be skipped. It is also possible to `break lines <../configuration/serie.html#allow-interruptions>`_. diff --git a/docs/documentation/types/xy.rst b/docs/documentation/types/xy.rst index b804688..e0318ef 100644 --- a/docs/documentation/types/xy.rst +++ b/docs/documentation/types/xy.rst @@ -63,9 +63,6 @@ DateTime Date ++++ -If you want to plot date/time-series with breaks inside the plot, pass allow_interruptions=True to -the constructor. See Line on how to do it - .. pygal-code:: from datetime import date @@ -117,3 +114,8 @@ TimeDelta (timedelta(days=3, microseconds=30), 12), (timedelta(weeks=1), 10), ]) + +None values +~~~~~~~~~~~ + +None values will be skipped. It is also possible to `break lines <../configuration/serie.html#allow-interruptions>`_.