From f89e709be54a4a983f3b129554d165fa8e91f6b1 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Mon, 30 Apr 2012 17:44:00 +0200 Subject: [PATCH] Add new options doc --- pages/basic_customizations.rst | 32 ++++++++++++++++++++++++++++++++ pages/chart_types.rst | 2 +- pages/other_customizations.rst | 33 ++++++++++++++++++++++++++++----- static/css/style.css | 2 +- 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/pages/basic_customizations.rst b/pages/basic_customizations.rst index 5c64595..984f05f 100644 --- a/pages/basic_customizations.rst +++ b/pages/basic_customizations.rst @@ -157,6 +157,21 @@ You can remove legend and dots by setting these at `False` chart = pygal.Line(show_dots=False) chart.add('line', [.0002, .0005, .00035]) + +Legend at bottom +---------------- + +``legend_at_bottom`` + +You can put legend at bottom by setting `legend_at_bottom` at True: + + +.. pygal-code:: + + chart = pygal.Line(legend_at_bottom=True) + chart.add('line', [.0002, .0005, .00035]) + + Rendering --------- @@ -220,6 +235,23 @@ Allow label rotation (in degrees) to avoid axis cluttering: chart.add('line', [0, .0002, .0005, .00035]) +Text truncation +--------------- + +``truncate_legend, truncate_label`` + +By default long text are automatically truncated at reasonable length which fit in the graph. + +You can override that by setting truncation lenght with `truncate_legend` and `truncate_label`. + + +.. pygal-code:: + + chart = pygal.Line(truncate_legend=3, truncate_label=17) + chart.x_labels = ['This is the first point !', 'This is the second point !', 'This is the third point !', 'This is the fourth point !'] + chart.add('line', [0, .0002, .0005, .00035]) + + Human readable -------------- diff --git a/pages/chart_types.rst b/pages/chart_types.rst index c8f2fe4..543271b 100644 --- a/pages/chart_types.rst +++ b/pages/chart_types.rst @@ -267,7 +267,7 @@ Population pyramid: 'Males divorced', 'Females divorced'] pyramid_chart = pygal.Pyramid(human_readable=True, legend_at_bottom=True) - pyramid_chart.title = 'England population by age (source: ons.gov.uk)' + pyramid_chart.title = 'England population by age in 2010 (source: ons.gov.uk)' pyramid_chart.x_labels = map(lambda x: str(x) if not x % 5 else '', range(90)) for type, age in zip(types, ages): pyramid_chart.add(type, age) diff --git a/pages/other_customizations.rst b/pages/other_customizations.rst index 0f53320..70a5fbd 100644 --- a/pages/other_customizations.rst +++ b/pages/other_customizations.rst @@ -31,10 +31,20 @@ You can set the scale to be logarithmic: Custom css and js ----------------- -``base_css, base_js`` +``css, js`` -You can specify a css/js file to replace the one by default using `base_css` and `base_js` options. -These options take a filename in parameter. +You can add or replace css/js files in pygal using the `css` and `js` array options. +These lists contain absolute filenames and/or external URI. (Relative filenames are relative to pygal internal files) + +Default: + +.. code-block:: + + css = ['style.css', 'graph.css'] + js = [ + 'https://raw.github.com/Kozea/pygal.js/master/svg.jquery.js', + 'https://raw.github.com/Kozea/pygal.js/master/pygal-tooltips.js' + ] Legend box size @@ -53,7 +63,7 @@ You can change the size of the rectangle next to the legend: Rounded bars ---------------- +------------ ``rounded_bars`` @@ -65,6 +75,19 @@ You can add a round effect to bar diagrams with `rounded_bars`: chart.add('rounded', [3, 10, 7, 2, 9, 7]) +Pretty print +------------ + +``pretty_print`` + +You can enable pretty print if you want to edit the source at hand (look at this frame source): + +.. pygal-code:: + + chart = pygal.Bar(pretty_print=True) + chart.add('rounded', [3, 10, 7, 2, 9, 7]) + + Static options -------------- @@ -75,7 +98,7 @@ viewer or as an image, all the values are displayed on the graph. It can be disabled by setting `print_values` to `False`. -``print_zeroes`` can be enabled to display static values even if equal to zero. +`print_zeroes` can be enabled to display static values even if equal to zero. Disable xml declaration diff --git a/static/css/style.css b/static/css/style.css index a3ef94d..a2e9e9b 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -241,7 +241,7 @@ section pre { padding: 1em; background-color: #0a0a0a; border: 1px solid black; - width: 100%; + max-width: 100%; overflow-x: auto; }