diff --git a/pages/chart_types.rst b/pages/chart_types.rst index 7c6fb8a..8b2f709 100644 --- a/pages/chart_types.rst +++ b/pages/chart_types.rst @@ -179,7 +179,26 @@ Simple Kiviat diagram: radar_chart = pygal.Radar() radar_chart.title = 'V8 benchmark results' radar_chart.x_labels = ['Richards', 'DeltaBlue', 'Crypto', 'RayTrace', 'EarleyBoyer', 'RegExp', 'Splay', 'NavierStokes'] - radar_chart.add('Chrome', [4074, 3458, 12942, 3541, 10799, 1863, 657, 5918]) - radar_chart.add('Firefox', [3100, 2579, 3638, 2524, 3800, 552, 3675, 9043]) + radar_chart.add('Chrome', [6395, 8212, 7520, 7218, 12464, 1660, 2123, 8607]) + radar_chart.add('Firefox', [7473, 8099, 11700, 2651, 6361, 1044, 3797, 9450]) + radar_chart.add('Opera', [3472, 2933, 4203, 5229, 5810, 1828, 9013, 4669]) + radar_chart.add('IE', [43, 41, 59, 79, 144, 136, 34, 102]) +Dot charts +------------ + +Basic +^^^^^ + +Punch card like chart: + +.. pygal-code:: + + dot_chart = pygal.Dot(x_label_rotation=30) + dot_chart.title = 'V8 benchmark results' + dot_chart.x_labels = ['Richards', 'DeltaBlue', 'Crypto', 'RayTrace', 'EarleyBoyer', 'RegExp', 'Splay', 'NavierStokes'] + dot_chart.add('Chrome', [6395, 8212, 7520, 7218, 12464, 1660, 2123, 8607]) + dot_chart.add('Firefox', [7473, 8099, 11700, 2651, 6361, 1044, 3797, 9450]) + dot_chart.add('Opera', [3472, 2933, 4203, 5229, 5810, 1828, 9013, 4669]) + dot_chart.add('IE', [43, 41, 59, 79, 144, 136, 34, 102]) diff --git a/pages/documentation.rst b/pages/documentation.rst index ae7004a..e52e31c 100644 --- a/pages/documentation.rst +++ b/pages/documentation.rst @@ -11,6 +11,7 @@ User documentation - `Styles `_ - change the style. - `Basic customizations `_ - start to improve your chats. - `Interpolations `_ - smooth your lines. +- `Metadata `_ - enrich your graph. - `Other customizations `_ - customize all the things. diff --git a/pages/home.rst b/pages/home.rst index 7ff0a1f..e893bcc 100644 --- a/pages/home.rst +++ b/pages/home.rst @@ -39,6 +39,13 @@ pygal is a dynamic SVG charting library. chart.add('red', [1, 2, 3, 1, 2]) chart.add('green', [4, 3, 0, 1, 2]) + .. pygal:: 300 200 + + chart = pygal.Dot(style=pygal.style.NeonStyle) + chart.x_labels = 'one', 'two', 'three', 'four', 'five' + chart.add('red', [1, 2, 3, 1, 2]) + chart.add('green', [4, 3, 0, 1, 2]) + It features various graph types: @@ -52,6 +59,8 @@ It features various graph types: - `Radar charts `_ +- `Dot charts `_ + Python/Css styling with some packaged themes (`default `_, `light `_, diff --git a/pages/metadata.rst b/pages/metadata.rst new file mode 100644 index 0000000..5f2c5bc --- /dev/null +++ b/pages/metadata.rst @@ -0,0 +1,99 @@ +=============== + Documentation +=============== + + +Metadata +======== + +.. contents:: + + +Labels +------ + +You can add per value metadata like labels, by specifying a dictionary instead of a value: + +.. pygal-code:: + + chart = pygal.Bar() + chart.add('Red', {'value': 2, 'label': 'This is red'}) + chart.add('Green', {'value': 4, 'label': 'This is green'}) + chart.add('Yellow', 7) + chart.add('Blue', {'value': 5}) + chart.add('Violet', {'value': 3, 'label': 'This is violet'}) + + +Links +----- + +Basic +^^^^^ + +You can also add hyper links: + +.. pygal-code:: + + chart = pygal.Bar() + chart.add('Red', { + 'value': 2, + 'label': 'This is red', + 'xlink': 'http://en.wikipedia.org/wiki/Red'}) + + chart.add('Green', { + 'value': 4, + 'label': 'This is green', + 'xlink': 'http://en.wikipedia.org/wiki/Green'}) + + chart.add('Yellow', 7) + + chart.add('Blue', { + 'value': 5, + 'xlink': 'http://en.wikipedia.org/wiki/Blue'}) + + chart.add('Violet', { + 'value': 3, + 'label': 'This is violet', + 'xlink': 'http://en.wikipedia.org/wiki/Violet_(color)'}) + + +Advanced +^^^^^^^^ + +You can specify a dictionary to xlink with all links attributes: + +.. pygal-code:: + + chart = pygal.Bar() + chart.add('Red', { + 'value': 2, + 'label': 'This is red', + 'xlink': {'href': 'http://en.wikipedia.org/wiki/Red'}}) + + chart.add('Green', { + 'value': 4, + 'label': 'This is green', + 'xlink': { + 'href': 'http://en.wikipedia.org/wiki/Green', + 'target': '_top'} + }) + + chart.add('Yellow', 7) + + chart.add('Blue', { + 'value': 5, + 'xlink': { + 'href': 'http://en.wikipedia.org/wiki/Blue', + 'target': '_blank'} + }) + + chart.add('Violet', { + 'value': 3, + 'label': 'This is violet', + 'xlink': { + 'href': 'http://en.wikipedia.org/wiki/Violet_(color)', + 'target': '_self'} + }) + + + diff --git a/pages/other_customizations.rst b/pages/other_customizations.rst index b69bf7b..0f53320 100644 --- a/pages/other_customizations.rst +++ b/pages/other_customizations.rst @@ -78,26 +78,6 @@ It can be disabled by setting `print_values` to `False`. ``print_zeroes`` can be enabled to display static values even if equal to zero. -Tooltip animation ------------------ - -``animation_steps`` - -.. caution:: - Experimental (might be slow acconding to particular conditions) - -If you want some smoothing in tooltip display you can set animation_steps to a number. -The greater the number the slowest but detailed the animation: - - -.. pygal-code:: - - chart = pygal.Line(animation_steps=20) - values = [1, 3, 43, 123, 1231, 23192] - chart.x_labels = map(str, values) - chart.add('log example', values) - - Disable xml declaration ----------------------- diff --git a/pages/styles.rst b/pages/styles.rst index 6904a58..da772c9 100644 --- a/pages/styles.rst +++ b/pages/styles.rst @@ -129,8 +129,11 @@ You can instantiate the `Style` class with some customizations for quick styling Using a custom css ^^^^^^^^^^^^^^^^^^ -You can also specify a file containing a custom css for more customization. -(See the `default 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 `_) .. pygal-code:: @@ -184,7 +187,9 @@ You can also specify a file containing a custom css for more customization. custom_css_file = '/tmp/pygal_custom_style.css' with open(custom_css_file, 'w') as f: f.write(custom_css) - chart = pygal.StackedLine(fill=True, interpolate='cubic', base_css=custom_css_file) + 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])