https://github.com/s3rvac/pygal-toggle-graphs
Toggle the visibility of graphs in a pygal chart by clicking on the legend.
https://github.com/s3rvac/pygal-toggle-graphs
chart graph pygal toggle
Last synced: over 1 year ago
JSON representation
Toggle the visibility of graphs in a pygal chart by clicking on the legend.
- Host: GitHub
- URL: https://github.com/s3rvac/pygal-toggle-graphs
- Owner: s3rvac
- Created: 2014-03-31T14:08:05.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-03-22T17:49:55.000Z (about 9 years ago)
- Last Synced: 2025-01-12T10:24:42.413Z (over 1 year ago)
- Topics: chart, graph, pygal, toggle
- Language: JavaScript
- Size: 81.1 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
pygal-toggle-graphs
===================
A JavaScript module that allows you to toggle the visibility of graphs in the
charts generated by [pygal](https://github.com/Kozea/pygal) when viewing them in
a browser.
Usage
-----
When you generate the charts in Python, simply append a link to this module in
the list of JavaScript modules that should be embedded in the chart:
```python
import pygal
js = [
'https://kozea.github.com/pygal.js/javascripts/svg.jquery.js', # Original
'https://kozea.github.com/pygal.js/javascripts/pygal-tooltips.js', # Original
'https://rawgit.com/s3rvac/pygal-toggle-graphs/master/pygal-toggle-graphs.js'
]
line_chart = pygal.Line(js=js)
# Populate the chart with data.
# ...
line_chart.render_to_file('graph.svg')
```
After that, when viewing the chart on a website, click on a legend to toggle
the visibility of the corresponding graph (show/hide). For a description of how
to embed a chart on your website, consult the [documentation of
pygal](http://pygal.org/documentation/).
Example
-------
An online example can be seen
[here](https://projects.petrzemek.net/pygal-toggle-graphs/) or in the GIF
screencast below.
[](example/screencast.gif)
Notes
-----
* The module should work with any type of a chart.
* It requires the presence of the original JavaScript modules that are
distributed with [pygal](https://github.com/Kozea/pygal). At the time of
writing, these are the two modules listed above in the usage description.
* It was tested with [pygal](https://github.com/Kozea/pygal) 1.4-2.3 and
[Mozilla Firefox](https://www.mozilla.org/en/firefox/) 27-52,
[Google Chrome](https://www.google.com/intl/en/chrome/browser/) 33-57,
[Opera](https://www.opera.com) 20-36, and
[Apple Safari](https://www.apple.com/safari/) 5.1.
* The implementation is inspired by the scripts in
[pygal.js](https://github.com/Kozea/pygal.js/).
License
-------
Copyright (c) 2014 Petr Zemek
Distributed under GNU LGPLv3:
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see .