mirror of https://github.com/Kozea/pygal.git
Florian Mounier
12 years ago
14 changed files with 936 additions and 255 deletions
@ -0,0 +1,206 @@ |
|||||||
|
=============== |
||||||
|
Documentation |
||||||
|
=============== |
||||||
|
|
||||||
|
|
||||||
|
Built-in Styles |
||||||
|
=============== |
||||||
|
|
||||||
|
pygal provides 14 built-in styles: |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
Default |
||||||
|
------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic') |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Neon |
||||||
|
---- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import NeonStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=NeonStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Dark Solarized |
||||||
|
-------------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import DarkSolarizedStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=DarkSolarizedStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Light Solarized |
||||||
|
--------------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightSolarizedStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=LightSolarizedStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Light |
||||||
|
----- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=LightStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Clean |
||||||
|
----- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import CleanStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=CleanStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Red Blue |
||||||
|
-------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import RedBlueStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=RedBlueStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Dark Colorized |
||||||
|
-------------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import DarkColorizedStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=DarkColorizedStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Light Colorized |
||||||
|
--------------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightColorizedStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=LightColorizedStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Turquoise |
||||||
|
--------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import TurquoiseStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=TurquoiseStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Light green |
||||||
|
----------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightGreenStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=LightGreenStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Dark green |
||||||
|
---------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import DarkGreenStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=DarkGreenStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Dark green blue |
||||||
|
--------------- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import DarkGreenBlueStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=DarkGreenBlueStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Blue |
||||||
|
---- |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import BlueStyle |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=BlueStyle) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
@ -0,0 +1,116 @@ |
|||||||
|
=============== |
||||||
|
Documentation |
||||||
|
=============== |
||||||
|
|
||||||
|
|
||||||
|
Custom Styles |
||||||
|
============= |
||||||
|
|
||||||
|
pygal provides 2 ways to customize styles: |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
Using Style class |
||||||
|
----------------- |
||||||
|
|
||||||
|
You can instantiate the `Style` class with some customizations for quick styling: |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import Style |
||||||
|
custom_style = Style( |
||||||
|
background='transparent', |
||||||
|
plot_background='transparent', |
||||||
|
foreground='#53E89B', |
||||||
|
foreground_light='#53A0E8', |
||||||
|
foreground_dark='#630C0D', |
||||||
|
opacity='.6', |
||||||
|
opacity_hover='.9', |
||||||
|
transition='400ms ease-in', |
||||||
|
colors=('#E853A0', '#E8537A', '#E95355', '#E87653', '#E89B53')) |
||||||
|
|
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=custom_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Using a custom css |
||||||
|
------------------ |
||||||
|
|
||||||
|
You can also specify a file containing a custom css for more customization. The css option is an array containing included css by default (except from ``base.css`` which is always included). |
||||||
|
|
||||||
|
It supports local file names and external stylesheet too, just append your URI in the list. |
||||||
|
|
||||||
|
(See the `default css <https://github.com/Kozea/pygal/blob/master/pygal/css/>`_) |
||||||
|
|
||||||
|
NB: Now the css rules are prefixed by an unique id, to prevent collisions when including several svg dirctly into a web page. You can disable it with the `no_prefix` option. |
||||||
|
|
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from tempfile import NamedTemporaryFile |
||||||
|
custom_css = ''' |
||||||
|
{{ id }}text { |
||||||
|
fill: green; |
||||||
|
font-family: monospace; |
||||||
|
} |
||||||
|
{{ id }}.legends .legend text { |
||||||
|
font-size: {{ font_sizes.legend }}; |
||||||
|
} |
||||||
|
{{ id }}.axis { |
||||||
|
stroke: #666; |
||||||
|
} |
||||||
|
{{ id }}.axis text { |
||||||
|
font-size: {{ font_sizes.label }}; |
||||||
|
font-family: sans; |
||||||
|
stroke: none; |
||||||
|
} |
||||||
|
{{ id }}.axis.y text { |
||||||
|
text-anchor: end; |
||||||
|
} |
||||||
|
{{ id }}#tooltip text { |
||||||
|
font-size: {{ font_sizes.tooltip }}; |
||||||
|
} |
||||||
|
{{ id }}.dot { |
||||||
|
fill: yellow; |
||||||
|
} |
||||||
|
{{ id }}.color-0 { |
||||||
|
stroke: #ff1100; |
||||||
|
fill: #ff1100; |
||||||
|
} |
||||||
|
{{ id }}.color-1 { |
||||||
|
stroke: #ffee00; |
||||||
|
fill: #ffee00; |
||||||
|
} |
||||||
|
{{ id }}.color-2 { |
||||||
|
stroke: #66bb44; |
||||||
|
fill: #66bb44; |
||||||
|
} |
||||||
|
{{ id }}.color-3 { |
||||||
|
stroke: #88bbdd; |
||||||
|
fill: #88bbdd; |
||||||
|
} |
||||||
|
{{ id }}.color-4 { |
||||||
|
stroke: #0000ff; |
||||||
|
fill: #0000ff; |
||||||
|
} |
||||||
|
''' |
||||||
|
custom_css_file = '/tmp/pygal_custom_style.css' |
||||||
|
with open(custom_css_file, 'w') as f: |
||||||
|
f.write(custom_css) |
||||||
|
config = pygal.Config(fill=True, interpolate='cubic') |
||||||
|
config.css.append(custom_css_file) |
||||||
|
chart = pygal.StackedLine(config) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Next: `Basic customizations </basic_customizations>`_ |
||||||
|
|
@ -0,0 +1,174 @@ |
|||||||
|
=============== |
||||||
|
Documentation |
||||||
|
=============== |
||||||
|
|
||||||
|
|
||||||
|
Parametric Styles |
||||||
|
================= |
||||||
|
|
||||||
|
pygal provides 5 parametric styles: |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
Usage |
||||||
|
----- |
||||||
|
|
||||||
|
A parametric style is initiated with a default color and the other are generated from this one: |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightenStyle |
||||||
|
dark_lighten_style = LightenStyle('#336676') |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=dark_lighten_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
You can set the `step` parameter to tell between how much colors the color modifier will be applied |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightenStyle |
||||||
|
dark_lighten_style = LightenStyle('#336676', step=5) |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=dark_lighten_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
and the `max_` to limit the amplitude at a certain value (in % for all color operation except rotate which is 360): |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightenStyle |
||||||
|
dark_lighten_style = LightenStyle('#336676', step=5, max_=10) |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=dark_lighten_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
You can tell the style to inheritate all the styles from another theme: |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightenStyle, LightColorizedStyle |
||||||
|
dark_lighten_style = LightenStyle('#336676', base_style=LightColorizedStyle) |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=dark_lighten_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
And you can manually set the properties just like any other theme: |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightenStyle, LightColorizedStyle |
||||||
|
dark_lighten_style = LightenStyle('#336676', base_style=LightColorizedStyle) |
||||||
|
dark_lighten_style.background = '#ffcccc' |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=dark_lighten_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Styles |
||||||
|
------ |
||||||
|
|
||||||
|
|
||||||
|
Rotate |
||||||
|
~~~~~~ |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import RotateStyle |
||||||
|
dark_rotate_style = RotateStyle('#9e6ffe') |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=dark_rotate_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import RotateStyle, LightColorizedStyle |
||||||
|
dark_rotate_style = RotateStyle('#75ff98', base_style=LightColorizedStyle) |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=dark_rotate_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Lighten |
||||||
|
~~~~~~~ |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import LightenStyle |
||||||
|
dark_lighten_style = LightenStyle('#004466') |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=dark_lighten_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Darken |
||||||
|
~~~~~~ |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import DarkenStyle |
||||||
|
darken_style = DarkenStyle('#ff8723') |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=darken_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Saturate |
||||||
|
~~~~~~~~ |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import SaturateStyle |
||||||
|
saturate_style = SaturateStyle('#609f86') |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=saturate_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
||||||
|
|
||||||
|
|
||||||
|
Desaturate |
||||||
|
~~~~~~~~~~ |
||||||
|
|
||||||
|
.. pygal-code:: |
||||||
|
|
||||||
|
from pygal.style import DesaturateStyle |
||||||
|
desaturate_style = DesaturateStyle('#8322dd') |
||||||
|
chart = pygal.StackedLine(fill=True, interpolate='cubic', style=desaturate_style) |
||||||
|
chart.add('A', [1, 3, 5, 16, 13, 3, 7]) |
||||||
|
chart.add('B', [5, 2, 3, 2, 5, 7, 17]) |
||||||
|
chart.add('C', [6, 10, 9, 7, 3, 1, 0]) |
||||||
|
chart.add('D', [2, 3, 5, 9, 12, 9, 5]) |
||||||
|
chart.add('E', [7, 4, 2, 1, 2, 10, 0]) |
@ -0,0 +1,78 @@ |
|||||||
|
=============== |
||||||
|
Documentation |
||||||
|
=============== |
||||||
|
|
||||||
|
|
||||||
|
Embedding in a web page |
||||||
|
======================= |
||||||
|
|
||||||
|
.. contents:: |
||||||
|
|
||||||
|
|
||||||
|
Within an embed tag |
||||||
|
------------------- |
||||||
|
|
||||||
|
First setup an url entry point for you svg: `/mysvg.svg` don't forget to set the mime-type to `image/svg+xml`. (If you are using flask you can use the `render_response` method.) |
||||||
|
|
||||||
|
Then in your html put an embed tag like this: |
||||||
|
|
||||||
|
.. code-block:: html |
||||||
|
|
||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<!-- ... --> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<figure> |
||||||
|
<embed type="image/svg+xml" src="/mysvg.svg" /> |
||||||
|
</figure> |
||||||
|
</body> |
||||||
|
</html> |
||||||
|
|
||||||
|
You can also use an iframe tag, but automatic sizing with `width: 100%` will not work. |
||||||
|
|
||||||
|
|
||||||
|
Directly in the html |
||||||
|
-------------------- |
||||||
|
|
||||||
|
You can insert it directly in a html page with the use of `disable_xml_declaration`. |
||||||
|
You have to put the javascript manually in you webpage, for instance: |
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: html |
||||||
|
|
||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<script type="text/javascript" src="http://kozea.github.com/pygal.js/javascripts/svg.jquery.js"></script> |
||||||
|
<script type="text/javascript" src="http://kozea.github.com/pygal.js/javascripts/pygal-tooltips.js"></script> |
||||||
|
<!-- ... --> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<figure> |
||||||
|
<!-- Pygal render() result: --> |
||||||
|
<svg |
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||||
|
xmlns="http://www.w3.org/2000/svg" |
||||||
|
id="chart-e6700c90-7a2b-4602-961c-83ccf5e59204" |
||||||
|
class="pygal-chart" |
||||||
|
viewBox="0 0 800 600"> |
||||||
|
<!--Generated with pygal 1.0.0 ©Kozea 2011-2013 on 2013-06-25--> |
||||||
|
<!--http://pygal.org--> |
||||||
|
<!--http://github.com/Kozea/pygal--> |
||||||
|
<defs> |
||||||
|
<!-- ... --> |
||||||
|
</defs> |
||||||
|
<title>Pygal</title> |
||||||
|
<g class="graph bar-graph vertical"> |
||||||
|
<!-- ... --> |
||||||
|
</g> |
||||||
|
</svg> |
||||||
|
<!-- End of Pygal render() result: --> |
||||||
|
</figure> |
||||||
|
</body> |
||||||
|
</html> |
||||||
|
|
||||||
|
You can use `explicit_size` to set the svg size from the `width`, `height` properties. |
||||||
|
|
Loading…
Reference in new issue