pax_global_header00006660000000000000000000000064123251060700014506gustar00rootroot0000000000000052 comment=c328233b16f48c3946304f03389571d7a4b37b09 pygooglechart-0.4.0+git20140622/000077500000000000000000000000001232510607000157565ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/.gitignore000066400000000000000000000000221232510607000177400ustar00rootroot00000000000000*.pyc *.pyo build pygooglechart-0.4.0+git20140622/CHANGELOG.markdown000066400000000000000000000057661232510607000210270ustar00rootroot00000000000000# ChangeLog ## 0.4.0 2013-06-02 * Python 3 compatibility (Geremy Condra) * Fix chco separator (Iacopo Spalletti) * Download to memory (Eduard Carreras) * Documentation work (WoLpH, Eduard Carreras) ## 0.3.0 2010-03-15 * Allow either arguments in `set_title_style()` (#16) (Alex Robinson) * Added MapChart helpers `set_codes()`, `set_geo_area()` and `add_data_dict()` (#23) (Andreas Schawo) * Added examples for MapChart * Reorganised and contributed to the test suite * Fixed examples - line endings to UNIX, correct hash bangs, inserted GPL. * Fixed a deprecation warning ## 0.2.1 2008-08-25 * Added support for QR Code chart (#8) * Added legend positioning (chdlp) (Steve Brandt) * Added line styles (chm=D) (Steve Brandt) * Added "colours within series" option to chart (chco=xxx|xxx) (Steve Brandt) * Added QR codes and more line examples * Axis labels are now casted to strings automatically * Bug fixed where pie charts stopped working due to automatic scaling * Bug fixed where the module would download twice (#7) (Evan Lezar) * Bug fixed when automatic scaling is on and None values are in a data set (#5) (Alec Thomas) * Bug fixed with auto-scaling, where the minimum y range was always 0. (#6) (Rohit Jenveja) * Bug fixed, replaced "1" with "0" in add_horizontal_range and add_vertical_range (incorrect syntax for Google) (Steve Brandt) * Better clipping checks ## 0.2.0 2008-04-26 * Automatic scaling, thanks to Trent Mick and Graham Ullrich * Added Sparklines, Radar, Google-o-Meter, Map chart types * Added priority to shape markers * Added zero line to bar charts * Grids and Line styles are not restricted to line charts any more. * Chart constructors get three new optional attributes: auto_scale, x_range, y_range * Data type detection has been re-written roughly following guidelines at http://code.google.com/apis/chart/#chart_data * BarChart now allows `bar_width` to not be set. * GroupedBarChart now supports the optional third value for 'chbh': spacing between bar groups (the "group_spacing" attribute). * Updated examples/line.py updated to use x_range and y_range * Added examples bar.py and scatter.py to demonstrate new functionality * Converted pygooglechart.py to use UNIX line breaks * Division by zero bug fix by Rob Hudson ## 0.1.2 2007-12-16 * Added more examples * Fixed pie labels encoding * Fixed MANIFEST.in to allow examples and COPYING in the source distribution * Added more metadata in setup.py ## 0.1.1 2007-12-14 * Renamed download_chart() to download() * Axis code refactored to allow for multiple axis labels (see examples for changes) * Fixed set_axis_labels() bug with non escaped characters * Added a few examples * download() checks for content type and raises on bad http codes * Added BadContentTypeException for unexpected responses from Google. * add_data() returns the index of the dataset * Line doesn't allow being an instance * Source code is more PEP8 friendly * Added COPYING, the GNU GPL licence file ## 0.1.0 2007-12-12 * Initial release pygooglechart-0.4.0+git20140622/COPYING000066400000000000000000000773311232510607000170240ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS pygooglechart-0.4.0+git20140622/MANIFEST.in000066400000000000000000000000611232510607000175110ustar00rootroot00000000000000recursive-include examples *.py include COPYING pygooglechart-0.4.0+git20140622/README.markdown000066400000000000000000000021741232510607000204630ustar00rootroot00000000000000Python Google Chart =================== pygooglechart is a complete Python wrapper for the Google Chart API. pygooglechart works with Linux, Windows and Mac OS X. ## Deprecation Warning Unfortunatelly Google has deprecated this API: The Image Charts portion of Google Chart Tools has been officially deprecated as of April 20, 2012. After April 20, 2015, this Deprecation Policy will not apply. Example ------- from pygooglechart import PieChart3D # Create a chart object of 250x100 pixels chart = PieChart3D(250, 100) # Add some data chart.add_data([20, 10]) # Assign the labels to the pie data chart.set_pie_labels(['Hello', 'World']) # Print the chart URL print chart.get_url() # Download the chart chart.download('pie-hello-world.png') There are more examples in [the examples directory](https://github.com/gak/pygooglechart/tree/master/examples). Installation ------------ There are a few ways of installing it from source: If you have setuptools installed, simply run the following: easy_install pygooglechart Or get the sources and run: python setup.py install pygooglechart-0.4.0+git20140622/docs/000077500000000000000000000000001232510607000167065ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/docs/.gitignore000066400000000000000000000000071232510607000206730ustar00rootroot00000000000000_build pygooglechart-0.4.0+git20140622/docs/Makefile000066400000000000000000000127501232510607000203530ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PythonGoogleChart.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PythonGoogleChart.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/PythonGoogleChart" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PythonGoogleChart" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." pygooglechart-0.4.0+git20140622/docs/_themes/000077500000000000000000000000001232510607000203325ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/docs/_themes/LICENSE000066400000000000000000000035541232510607000213460ustar00rootroot00000000000000Modifications: Copyright (c) 2012 Rick van Hattem. Original Projects: Copyright (c) 2010 Kenneth Reitz. Copyright (c) 2010 by Armin Ronacher. Some rights reserved. Redistribution and use in source and binary forms of the theme, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. We kindly ask you to only use these themes in an unmodified manner just for Flask and Flask-related products, not for unrelated projects. If you like the visual style and want to use it for your own projects, please consider making some larger changes to the themes (such as changing font faces, sizes, colors or margins). THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. pygooglechart-0.4.0+git20140622/docs/_themes/flask_theme_support.py000066400000000000000000000114131232510607000247620ustar00rootroot00000000000000# flasky extensions. flasky pygments style based on tango style from pygments.style import Style from pygments.token import Keyword, Name, Comment, String, Error, \ Number, Operator, Generic, Whitespace, Punctuation, Other, Literal class FlaskyStyle(Style): background_color = "#f8f8f8" default_style = "" styles = { # No corresponding class for the following: #Text: "", # class: '' Whitespace: "underline #f8f8f8", # class: 'w' Error: "#a40000 border:#ef2929", # class: 'err' Other: "#000000", # class 'x' Comment: "italic #8f5902", # class: 'c' Comment.Preproc: "noitalic", # class: 'cp' Keyword: "bold #004461", # class: 'k' Keyword.Constant: "bold #004461", # class: 'kc' Keyword.Declaration: "bold #004461", # class: 'kd' Keyword.Namespace: "bold #004461", # class: 'kn' Keyword.Pseudo: "bold #004461", # class: 'kp' Keyword.Reserved: "bold #004461", # class: 'kr' Keyword.Type: "bold #004461", # class: 'kt' Operator: "#582800", # class: 'o' Operator.Word: "bold #004461", # class: 'ow' - like keywords Punctuation: "bold #000000", # class: 'p' # because special names such as Name.Class, Name.Function, etc. # are not recognized as such later in the parsing, we choose them # to look the same as ordinary variables. Name: "#000000", # class: 'n' Name.Attribute: "#c4a000", # class: 'na' - to be revised Name.Builtin: "#004461", # class: 'nb' Name.Builtin.Pseudo: "#3465a4", # class: 'bp' Name.Class: "#000000", # class: 'nc' - to be revised Name.Constant: "#000000", # class: 'no' - to be revised Name.Decorator: "#888", # class: 'nd' - to be revised Name.Entity: "#ce5c00", # class: 'ni' Name.Exception: "bold #cc0000", # class: 'ne' Name.Function: "#000000", # class: 'nf' Name.Property: "#000000", # class: 'py' Name.Label: "#f57900", # class: 'nl' Name.Namespace: "#000000", # class: 'nn' - to be revised Name.Other: "#000000", # class: 'nx' Name.Tag: "bold #004461", # class: 'nt' - like a keyword Name.Variable: "#000000", # class: 'nv' - to be revised Name.Variable.Class: "#000000", # class: 'vc' - to be revised Name.Variable.Global: "#000000", # class: 'vg' - to be revised Name.Variable.Instance: "#000000", # class: 'vi' - to be revised Number: "#990000", # class: 'm' Literal: "#000000", # class: 'l' Literal.Date: "#000000", # class: 'ld' String: "#4e9a06", # class: 's' String.Backtick: "#4e9a06", # class: 'sb' String.Char: "#4e9a06", # class: 'sc' String.Doc: "italic #8f5902", # class: 'sd' - like a comment String.Double: "#4e9a06", # class: 's2' String.Escape: "#4e9a06", # class: 'se' String.Heredoc: "#4e9a06", # class: 'sh' String.Interpol: "#4e9a06", # class: 'si' String.Other: "#4e9a06", # class: 'sx' String.Regex: "#4e9a06", # class: 'sr' String.Single: "#4e9a06", # class: 's1' String.Symbol: "#4e9a06", # class: 'ss' Generic: "#000000", # class: 'g' Generic.Deleted: "#a40000", # class: 'gd' Generic.Emph: "italic #000000", # class: 'ge' Generic.Error: "#ef2929", # class: 'gr' Generic.Heading: "bold #000080", # class: 'gh' Generic.Inserted: "#00A000", # class: 'gi' Generic.Output: "#888", # class: 'go' Generic.Prompt: "#745334", # class: 'gp' Generic.Strong: "bold #000000", # class: 'gs' Generic.Subheading: "bold #800080", # class: 'gu' Generic.Traceback: "bold #a40000", # class: 'gt' } pygooglechart-0.4.0+git20140622/docs/_themes/wolph/000077500000000000000000000000001232510607000214635ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/docs/_themes/wolph/layout.html000066400000000000000000000017271232510607000236750ustar00rootroot00000000000000{%- extends "basic/layout.html" %} {%- block extrahead %} {{ super() }} {% if theme_touch_icon %} {% endif %} {% endblock %} {%- block relbar2 %}{% endblock %} {%- block footer %} {%- endblock %} pygooglechart-0.4.0+git20140622/docs/_themes/wolph/relations.html000066400000000000000000000011161232510607000243500ustar00rootroot00000000000000

Related Topics

pygooglechart-0.4.0+git20140622/docs/_themes/wolph/static/000077500000000000000000000000001232510607000227525ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/docs/_themes/wolph/static/flasky.css_t000066400000000000000000000156061232510607000253100ustar00rootroot00000000000000/* * flasky.css_t * ~~~~~~~~~~~~ * * :copyright: Copyright 2010 by Armin Ronacher. Modifications by Kenneth Reitz. * :license: Flask Design License, see LICENSE for details. */ {% set page_width = '940px' %} {% set sidebar_width = '220px' %} @import url("basic.css"); /* -- page layout ----------------------------------------------------------- */ body { font-family: 'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro'; font-size: 17px; background-color: white; color: #000; margin: 0; padding: 0; } div.document { width: {{ page_width }}; margin: 30px auto 0 auto; } div.documentwrapper { float: left; width: 100%; } div.bodywrapper { margin: 0 0 0 {{ sidebar_width }}; } div.sphinxsidebar { width: {{ sidebar_width }}; } hr { border: 1px solid #B1B4B6; } div.body { background-color: #ffffff; color: #3E4349; padding: 0 30px 0 30px; } img.floatingflask { padding: 0 0 10px 10px; float: right; } div.footer { width: {{ page_width }}; margin: 20px auto 30px auto; font-size: 14px; color: #888; text-align: right; } div.footer a { color: #888; } div.related { display: none; } div.sphinxsidebar a { color: #444; text-decoration: none; border-bottom: 1px dotted #999; } div.sphinxsidebar a:hover { border-bottom: 1px solid #999; } div.sphinxsidebar { font-size: 14px; line-height: 1.5; } div.sphinxsidebarwrapper { padding: 0px 10px; } div.sphinxsidebarwrapper p.logo { padding: 0 0 20px 0; margin: 0; text-align: center; } div.sphinxsidebar h3, div.sphinxsidebar h4 { font-family: 'Garamond', 'Georgia', serif; color: #555; font-size: 24px; font-weight: normal; margin: 0 0 5px 0; padding: 0; } div.sphinxsidebar h4 { font-size: 20px; } div.sphinxsidebar h3 a { color: #444; } div.sphinxsidebar p.logo a, div.sphinxsidebar h3 a, div.sphinxsidebar p.logo a:hover, div.sphinxsidebar h3 a:hover { border: none; } div.sphinxsidebar p { color: #555; margin: 10px 0; } div.sphinxsidebar ul { margin: 10px 0; padding: 0; color: #000; } div.sphinxsidebar input[type="text"] { width: 160px!important; } div.sphinxsidebar input { border: 1px solid #ccc; font-family: 'Georgia', serif; font-size: 1em; } /* -- body styles ----------------------------------------------------------- */ a { color: #004B6B; text-decoration: underline; } a:hover { color: #6D4100; text-decoration: underline; } div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { font-family: 'Garamond', 'Georgia', serif; font-weight: normal; margin: 30px 0px 10px 0px; padding: 0; } div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; } div.body h2 { font-size: 180%; } div.body h3 { font-size: 150%; } div.body h4 { font-size: 130%; } div.body h5 { font-size: 100%; } div.body h6 { font-size: 100%; } a.headerlink { color: #ddd; padding: 0 4px; text-decoration: none; } a.headerlink:hover { color: #444; background: #eaeaea; } div.body p, div.body dd, div.body li { line-height: 1.4em; } div.admonition { background: #fafafa; margin: 20px -30px; padding: 10px 30px; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; } div.admonition tt.xref, div.admonition a tt { border-bottom: 1px solid #fafafa; } dd div.admonition { margin-left: -60px; padding-left: 60px; } div.admonition p.admonition-title { font-family: 'Garamond', 'Georgia', serif; font-weight: normal; font-size: 24px; margin: 0 0 10px 0; padding: 0; line-height: 1; } div.admonition p.last { margin-bottom: 0; } div.highlight { background-color: white; } dt:target, .highlight { background: #FAF3E8; } div.note { background-color: #eee; border: 1px solid #ccc; } div.seealso { background-color: #ffc; border: 1px solid #ff6; } div.topic { background-color: #eee; } p.admonition-title { display: inline; } p.admonition-title:after { content: ":"; } pre, tt { font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 0.9em; } img.screenshot { } tt.descname, tt.descclassname { font-size: 0.95em; } tt.descname { padding-right: 0.08em; } img.screenshot { -moz-box-shadow: 2px 2px 4px #eee; -webkit-box-shadow: 2px 2px 4px #eee; box-shadow: 2px 2px 4px #eee; } table.docutils { border: 1px solid #888; -moz-box-shadow: 2px 2px 4px #eee; -webkit-box-shadow: 2px 2px 4px #eee; box-shadow: 2px 2px 4px #eee; } table.docutils td, table.docutils th { border: 1px solid #888; padding: 0.25em 0.7em; } table.field-list, table.footnote { border: none; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; } table.footnote { margin: 15px 0; width: 100%; border: 1px solid #eee; background: #fdfdfd; font-size: 0.9em; } table.footnote + table.footnote { margin-top: -15px; border-top: none; } table.field-list th { padding: 0 0.8em 0 0; } table.field-list td { padding: 0; } table.footnote td.label { width: 0px; padding: 0.3em 0 0.3em 0.5em; } table.footnote td { padding: 0.3em 0.5em; } dl { margin: 0; padding: 0; } dl dd { margin-left: 30px; } blockquote { margin: 0 0 0 30px; padding: 0; } ul, ol { margin: 10px 0 10px 30px; padding: 0; } pre { background: #eee; padding: 7px 30px; margin: 15px -30px; line-height: 1.3em; } dl pre, blockquote pre, li pre { margin-left: -60px; padding-left: 60px; } dl dl pre { margin-left: -90px; padding-left: 90px; } tt { background-color: #ecf0f3; color: #222; /* padding: 1px 2px; */ } tt.xref, a tt { background-color: #FBFBFB; border-bottom: 1px solid white; } a.reference { text-decoration: none; border-bottom: 1px dotted #004B6B; } a.reference:hover { border-bottom: 1px solid #6D4100; } a.footnote-reference { text-decoration: none; font-size: 0.7em; vertical-align: top; border-bottom: 1px dotted #004B6B; } a.footnote-reference:hover { border-bottom: 1px solid #6D4100; } a:hover tt { background: #EEE; } /* scrollbars */ ::-webkit-scrollbar { width: 6px; height: 6px; } ::-webkit-scrollbar-button:start:decrement, ::-webkit-scrollbar-button:end:increment { display: block; height: 10px; } ::-webkit-scrollbar-button:vertical:increment { background-color: #fff; } ::-webkit-scrollbar-track-piece { background-color: #eee; -webkit-border-radius: 3px; } ::-webkit-scrollbar-thumb:vertical { height: 50px; background-color: #ccc; -webkit-border-radius: 3px; } ::-webkit-scrollbar-thumb:horizontal { width: 50px; background-color: #ccc; -webkit-border-radius: 3px; } /* misc. */ .revsys-inline { display: none!important; } pygooglechart-0.4.0+git20140622/docs/_themes/wolph/static/small_flask.css000066400000000000000000000017201232510607000257540ustar00rootroot00000000000000/* * small_flask.css_t * ~~~~~~~~~~~~~~~~~ * * :copyright: Copyright 2010 by Armin Ronacher. * :license: Flask Design License, see LICENSE for details. */ body { margin: 0; padding: 20px 30px; } div.documentwrapper { float: none; background: white; } div.sphinxsidebar { display: block; float: none; width: 102.5%; margin: 50px -30px -20px -30px; padding: 10px 20px; background: #333; color: white; } div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p, div.sphinxsidebar h3 a { color: white; } div.sphinxsidebar a { color: #aaa; } div.sphinxsidebar p.logo { display: none; } div.document { width: 100%; margin: 0; } div.related { display: block; margin: 0; padding: 10px 0 20px 0; } div.related ul, div.related ul li { margin: 0; padding: 0; } div.footer { display: none; } div.bodywrapper { margin: 0; } div.body { min-height: 0; padding: 0; } pygooglechart-0.4.0+git20140622/docs/_themes/wolph/theme.conf000066400000000000000000000001721232510607000234340ustar00rootroot00000000000000[theme] inherit = basic stylesheet = flasky.css pygments_style = flask_theme_support.FlaskyStyle [options] touch_icon = pygooglechart-0.4.0+git20140622/docs/conf.py000066400000000000000000000201501232510607000202030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Python Google Chart documentation build configuration file, created by # sphinx-quickstart on Sun Jul 1 13:00:34 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0, os.path.join(os.path.abspath('..'), 'examples')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.mathjax', 'sphinx.ext.viewcode'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Python Google Chart' copyright = u'2012, Geremy Condra, Rick van Hattem' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '0.3.0' # The full version, including alpha/beta/rc tags. release = '0.3.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'wolph' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. html_theme_path = ['_themes'] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'PythonGoogleChartdoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'PythonGoogleChart.tex', u'Python Google Chart Documentation', u'Geremy Condra, Rick van Hattem', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'pythongooglechart', u'Python Google Chart Documentation', [u'Geremy Condra, Rick van Hattem'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'PythonGoogleChart', u'Python Google Chart Documentation', u'Geremy Condra, Rick van Hattem', 'PythonGoogleChart', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'http://docs.python.org/': None} pygooglechart-0.4.0+git20140622/docs/examples.all.rst000066400000000000000000000001441232510607000220240ustar00rootroot00000000000000all Module ========== .. automodule:: all :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.bar.rst000066400000000000000000000001441232510607000220200ustar00rootroot00000000000000bar Module ========== .. automodule:: bar :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.helper.rst000066400000000000000000000001551232510607000225350ustar00rootroot00000000000000helper Module ============= .. automodule:: helper :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.labels.rst000066400000000000000000000001551232510607000225200ustar00rootroot00000000000000labels Module ============= .. automodule:: labels :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.line.rst000066400000000000000000000001471232510607000222060ustar00rootroot00000000000000line Module =========== .. automodule:: line :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.mapchart.rst000066400000000000000000000001631232510607000230540ustar00rootroot00000000000000mapchart Module =============== .. automodule:: mapchart :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.pie.rst000066400000000000000000000001441232510607000220310ustar00rootroot00000000000000pie Module ========== .. automodule:: pie :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.qrcodes.rst000066400000000000000000000001601232510607000227120ustar00rootroot00000000000000qrcodes Module ============== .. automodule:: qrcodes :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.rst000066400000000000000000000003771232510607000212650ustar00rootroot00000000000000Examples ======== .. toctree:: :maxdepth: 2 examples.all examples.bar examples.helper examples.labels examples.line examples.mapchart examples.pie examples.qrcodes examples.scatter examples.settings examples.venn pygooglechart-0.4.0+git20140622/docs/examples.scatter.rst000066400000000000000000000001601232510607000227170ustar00rootroot00000000000000scatter Module ============== .. automodule:: scatter :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.settings.rst000066400000000000000000000001631232510607000231150ustar00rootroot00000000000000settings Module =============== .. automodule:: settings :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/examples.venn.rst000066400000000000000000000001471232510607000222250ustar00rootroot00000000000000venn Module =========== .. automodule:: venn :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/docs/index.rst000066400000000000000000000007531232510607000205540ustar00rootroot00000000000000.. Python Google Chart documentation master file, created by sphinx-quickstart on Sun Jul 1 13:00:34 2012. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to Python Google Chart's documentation! =============================================== Contents: .. toctree:: :maxdepth: 2 pygooglechart examples Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` pygooglechart-0.4.0+git20140622/docs/make.bat000066400000000000000000000117761232510607000203270ustar00rootroot00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\PythonGoogleChart.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\PythonGoogleChart.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end pygooglechart-0.4.0+git20140622/docs/pygooglechart.rst000066400000000000000000000002021232510607000223010ustar00rootroot00000000000000pygooglechart Module ==================== .. automodule:: pygooglechart :members: :undoc-members: :show-inheritance: pygooglechart-0.4.0+git20140622/examples/000077500000000000000000000000001232510607000175745ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/examples/.gitignore000066400000000000000000000000061232510607000215600ustar00rootroot00000000000000*.png pygooglechart-0.4.0+git20140622/examples/all.py000077500000000000000000000020111232510607000207130ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ # Change path so this module runs in any case import os os.chdir(os.path.abspath(os.path.dirname(__file__))) from glob import glob examples = glob('*.py') notexamples = ['settings.py', 'helper.py', 'all.py'] for example in examples: if example in notexamples: continue module = example[:-3] print(module) __import__(module).main() pygooglechart-0.4.0+git20140622/examples/bar.py000077500000000000000000000047141232510607000207230ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ import os import sys import math ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, '..')) from pygooglechart import StackedHorizontalBarChart, StackedVerticalBarChart, \ GroupedHorizontalBarChart, GroupedVerticalBarChart import settings def stacked_horizontal(): chart = StackedHorizontalBarChart(settings.width, settings.height, x_range=(0, 35)) chart.set_bar_width(10) chart.set_colours(['00ff00', 'ff0000']) chart.add_data([1,2,3,4,5]) chart.add_data([1,4,9,16,25]) chart.download('bar-horizontal-stacked.png') def stacked_vertical(): chart = StackedVerticalBarChart(settings.width, settings.height, y_range=(0, 35)) chart.set_bar_width(10) chart.set_colours(['00ff00', 'ff0000']) chart.add_data([1,2,3,4,5]) chart.add_data([1,4,9,16,25]) chart.download('bar-vertical-stacked.png') def grouped_horizontal(): chart = GroupedHorizontalBarChart(settings.width, settings.height, x_range=(0, 35)) chart.set_bar_width(5) chart.set_bar_spacing(2) chart.set_group_spacing(4) chart.set_colours(['00ff00', 'ff0000']) chart.add_data([1,2,3,4,5]) chart.add_data([1,4,9,16,25]) chart.download('bar-horizontal-grouped.png') def grouped_vertical(): chart = GroupedVerticalBarChart(settings.width, settings.height, y_range=(0, 35)) chart.set_bar_width(5) chart.set_colours(['00ff00', 'ff0000']) chart.add_data([1,2,3,4,5]) chart.add_data([1,4,9,16,25]) chart.download('bar-vertical-grouped.png') def main(): stacked_horizontal() stacked_vertical() grouped_horizontal() grouped_vertical() if __name__ == '__main__': main() pygooglechart-0.4.0+git20140622/examples/helper.py000077500000000000000000000017031232510607000214310ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ import random def random_data(points=50, maximum=100): return [random.random() * maximum for a in range(points)] def random_colour(min=20, max=200): func = lambda: int(random.random() * (max-min) + min) r, g, b = func(), func(), func() return '%02X%02X%02X' % (r, g, b) pygooglechart-0.4.0+git20140622/examples/helpers/000077500000000000000000000000001232510607000212365ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/examples/helpers/country_code_helper.py000066400000000000000000000025561232510607000256540ustar00rootroot00000000000000class CountryCodes: ''' This is just a helper to generate useful data files. It isn't directly used in these examples. ''' def __init__(self): self.parse_codes_data() def parse_codes_data(self): lines = open('iso3166-1-a2.txt', 'rb').read().split('\n') self.codes = dict([ a.split(' ', 1) for a in lines[:-1] ]) def get_country_code_from_name(self, guess_name): best_score = 100 best_code = None for code, name in self.codes.items(): score = self.levenshtein(guess_name, name) if score < best_score: best_score = score best_code = code return best_code def levenshtein(self, a, b): "Calculates the Levenshtein distance between a and b." n, m = len(a), len(b) if n > m: # Make sure n <= m, to use O(min(n,m)) space a,b = b,a n,m = m,n current = range(n+1) for i in range(1,m+1): previous, current = current, [i]+[0]*n for j in range(1,n+1): add, delete = previous[j]+1, current[j-1]+1 change = previous[j-1] if a[j-1] != b[i-1]: change = change + 1 current[j] = min(add, delete, change) return current[n] pygooglechart-0.4.0+git20140622/examples/helpers/iso3166-1-a2.txt000066400000000000000000000072711232510607000235560ustar00rootroot00000000000000AD Andorra AE United Arab Emirates AF Afghanistan AG Antigua and Barbuda AI Anguilla AL Albania AM Armenia AN Netherlands Antilles AO Angola AQ Antarctica AR Argentina AS American Samoa AT Austria AU Australia AW Aruba AX ?land Islands AZ Azerbaijan BA Bosnia and Herzegovina BB Barbados BD Bangladesh BE Belgium BF Burkina Faso BG Bulgaria BH Bahrain BI Burundi BJ Benin BL Saint Barth?lemy BM Bermuda BN Brunei Darussalam BO Bolivia BR Brazil BS Bahamas BT Bhutan BV Bouvet Island BW Botswana BY Belarus BZ Belize CA Canada CC Cocos (Keeling) Islands CD Congo, the Democratic Republic of the CF Central African Republic CG Congo CH Switzerland CI C?te d'Ivoire CK Cook Islands CL Chile CM Cameroon CN China CO Colombia CR Costa Rica CU Cuba CV Cape Verde CX Christmas Island CY Cyprus CZ Czech Republic DE Germany DJ Djibouti DK Denmark DM Dominica DO Dominican Republic DZ Algeria EC Ecuador EE Estonia EG Egypt EH Western Sahara ER Eritrea ES Spain ET Ethiopia FI Finland FJ Fiji FK Falkland Islands (Malvinas) FM Micronesia, Federated States of FO Faroe Islands FR France GA Gabon GB United Kingdom UK also exceptionally reserved on request of the United Kingdom GD Grenada GE Georgia GF French Guiana GG Guernsey GH Ghana GI Gibraltar GL Greenland GM Gambia GN Guinea GP Guadeloupe GQ Equatorial Guinea GR Greece GS South Georgia and the South Sandwich Islands GT Guatemala GU Guam GW Guinea-Bissau GY Guyana HK Hong Kong HM Heard Island and McDonald Islands HN Honduras HR Croatia HT Haiti HU Hungary ID Indonesia IE Ireland IL Israel IM Isle of Man IN India IO British Indian Ocean Territory IQ Iraq IR Iran, Islamic Republic of IS Iceland IT Italy JE Jersey JM Jamaica JO Jordan JP Japan KE Kenya KG Kyrgyzstan KH Cambodia KI Kiribati KM Comoros KN Saint Kitts and Nevis KP Korea, Democratic People's Republic of KR Korea, Republic of KW Kuwait KY Cayman Islands KZ Kazakhstan LA Lao People's Democratic Republic LB Lebanon LC Saint Lucia LI Liechtenstein LK Sri Lanka LR Liberia LS Lesotho LT Lithuania LU Luxembourg LV Latvia LY Libyan Arab Jamahiriya MA Morocco MC Monaco MD Moldova, Republic of ME Montenegro MF Saint Martin (French part) MG Madagascar MH Marshall Islands MK Macedonia, the former Yugoslav Republic of ML Mali MM Myanmar MN Mongolia MO Macao MP Northern Mariana Islands MQ Martinique MR Mauritania MS Montserrat MT Malta MU Mauritius MV Maldives MW Malawi MX Mexico MY Malaysia MZ Mozambique NA Namibia NC New Caledonia NE Niger NF Norfolk Island NG Nigeria NI Nicaragua NL Netherlands NO Norway NP Nepal NR Nauru NU Niue NZ New Zealand OM Oman PA Panama PE Peru PF French Polynesia PG Papua New Guinea PH Philippines PK Pakistan PL Poland PM Saint Pierre and Miquelon PN Pitcairn PR Puerto Rico PS Palestinian Territory, Occupied PT Portugal PW Palau PY Paraguay QA Qatar RE R?union RO Romania RS Serbia RU Russian Federation RW Rwanda SA Saudi Arabia SB Solomon Islands SC Seychelles SD Sudan SE Sweden SG Singapore SH Saint Helena SI Slovenia SJ Svalbard and Jan Mayen SK Slovakia SL Sierra Leone SM San Marino SN Senegal SO Somalia SR Suriname ST Sao Tome and Principe SV El Salvador SY Syrian Arab Republic SZ Swaziland TC Turks and Caicos Islands TD Chad TF French Southern Territories TG Togo TH Thailand TJ Tajikistan TK Tokelau TL Timor-Leste TM Turkmenistan TN Tunisia TO Tonga TR Turkey TT Trinidad and Tobago TV Tuvalu TW Taiwan, Province of China TZ Tanzania, United Republic of UA Ukraine UG Uganda UM United States Minor Outlying Islands US United States UY Uruguay UZ Uzbekistan VA Holy See (Vatican City State) VC Saint Vincent and the Grenadines VE Venezuela VG Virgin Islands, British VI Virgin Islands, U.S. VN Viet Nam VU Vanuatu WF Wallis and Futuna WS Samoa YE Yemen YT Mayotte ZA South Africa ZM Zambia ZW Zimbabwe pygooglechart-0.4.0+git20140622/examples/labels.py000077500000000000000000000045411232510607000214170ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ from __future__ import division import os import sys import math import random ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, '..')) from pygooglechart import SimpleLineChart from pygooglechart import Axis import settings import helper def cat_proximity(): """Cat proximity graph from http://xkcd.com/231/""" chart = SimpleLineChart(int(settings.width * 1.5), settings.height) chart.set_legend(['INTELLIGENCE', 'INSANITY OF STATEMENTS']) # intelligence data_index = chart.add_data([100. / y for y in range(1, 15)]) # insanity of statements chart.add_data([100. - 100 / y for y in range(1, 15)]) # line colours chart.set_colours(['208020', '202080']) # "Near" and "Far" labels, they are placed automatically at either ends. near_far_axis_index = chart.set_axis_labels(Axis.BOTTOM, ['FAR', 'NEAR']) # "Human Proximity to cat" label. Aligned to the center. index = chart.set_axis_labels(Axis.BOTTOM, ['HUMAN PROXIMITY TO CAT']) chart.set_axis_style(index, '202020', font_size=10, alignment=0) chart.set_axis_positions(index, [50]) chart.download('label-cat-proximity.png') def many_labels(): chart = SimpleLineChart(settings.width, settings.height) for a in range(3): for axis_type in (Axis.LEFT, Axis.RIGHT, Axis.BOTTOM): index = chart.set_axis_range(axis_type, 0, random.random() * 100) chart.set_axis_style(index, colour=helper.random_colour(), \ font_size=random.random() * 10 + 5) chart.add_data(helper.random_data()) chart.download('label-many.png') def main(): cat_proximity() many_labels() if __name__ == '__main__': main() pygooglechart-0.4.0+git20140622/examples/line.py000077500000000000000000000114641232510607000211060ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ from __future__ import division import os import sys import math ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, '..')) from pygooglechart import Chart from pygooglechart import SimpleLineChart from pygooglechart import XYLineChart from pygooglechart import SparkLineChart from pygooglechart import Axis import settings import helper def simple_random(): chart = SimpleLineChart(settings.width, settings.height, y_range=(0, 100)) chart.add_data(helper.random_data()) chart.download('line-simple-random.png') def xy_random(): chart = XYLineChart(settings.width, settings.height, x_range=(0, 100), y_range=(0, 100)) chart.add_data(helper.random_data()) chart.add_data(helper.random_data()) chart.download('line-xy-random.png') def xy_rect(): chart = XYLineChart(settings.width, settings.height, x_range=(0, 100), y_range=(0, 100)) chart.add_data([10, 90, 90, 10, 10]) chart.add_data([10, 10, 90, 90, 10]) chart.download('line-xy-rect.png') def xy_circle(): chart = XYLineChart(settings.width, settings.height, x_range=(0, 100), y_range=(0, 100)) steps = 40 xradius = 25 yradius = 45 xmid = 50 ymid = 50 xlist = [] ylist = [] for angle in range(0, steps + 1): angle = float(angle) / steps * math.pi * 2 xlist.append(math.cos(angle) * xradius + xmid) ylist.append(math.sin(angle) * yradius + ymid) chart.add_data(xlist) chart.add_data(ylist) chart.download('line-xy-circle.png') def sparklines(): chart = SparkLineChart(settings.width, settings.height) chart.add_data(helper.random_data()) chart.download('line-sparkline.png') def fill(): # Set the vertical range from 0 to 50 max_y = 50 chart = SimpleLineChart(200, 125, y_range=[0, max_y]) # First value is the highest Y value. Two of them are needed to be # plottable. chart.add_data([max_y] * 2) # 3 sets of real data chart.add_data([28, 30, 31, 33, 35, 36, 42, 48, 43, 37, 32, 24, 28]) chart.add_data([16, 18, 18, 21, 23, 23, 29, 36, 31, 25, 20, 12, 17]) chart.add_data([7, 9, 9, 12, 14, 14, 20, 27, 21, 15, 10, 3, 7]) # Last value is the lowest in the Y axis. chart.add_data([0] * 2) # Black lines chart.set_colours(['000000'] * 5) # Filled colours # from the top to the first real data chart.add_fill_range('76A4FB', 0, 1) # Between the 3 data values chart.add_fill_range('224499', 1, 2) chart.add_fill_range('FF0000', 2, 3) # from the last real data to the chart.add_fill_range('80C65A', 3, 4) # Some axis data chart.set_axis_labels(Axis.LEFT, ['', max_y / 2, max_y]) chart.set_axis_labels(Axis.BOTTOM, ['Sep', 'Oct', 'Nov', 'Dec']) chart.download('line-fill.png') def stripes(): # Set the vertical range from 0 to 100 max_y = 100 # Chart size of 200x125 pixels and specifying the range for the Y axis chart = SimpleLineChart(200, 125, y_range=[0, max_y]) # Add the chart data data = [ 32, 34, 34, 32, 34, 34, 32, 32, 32, 34, 34, 32, 29, 29, 34, 34, 34, 37, 37, 39, 42, 47, 50, 54, 57, 60, 60, 60, 60, 60, 60, 60, 62, 62, 60, 55, 55, 52, 47, 44, 44, 40, 40, 37, 34, 34, 32, 32, 32, 31, 32 ] chart.add_data(data) # Set the line colour to blue chart.set_colours(['0000FF']) # Set the vertical stripes chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2) # Set the horizontal dotted lines chart.set_grid(0, 25, 5, 5) # The Y axis labels contains 0 to 100 skipping every 25, but remove the # first number because it's obvious and gets in the way of the first X # label. left_axis = list(range(0, max_y + 1, 25)) left_axis[0] = '' chart.set_axis_labels(Axis.LEFT, left_axis) # X axis labels chart.set_axis_labels(Axis.BOTTOM, \ ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']) chart.download('line-stripes.png') def main(): simple_random() xy_random() xy_rect() xy_circle() sparklines() fill() stripes() if __name__ == '__main__': main() pygooglechart-0.4.0+git20140622/examples/mapchart-birth-rate.txt000066400000000000000000000030001232510607000241640ustar00rootroot00000000000000CD 49.6 GW 49.6 LR 49.6 NE 49.0 AF 48.2 ML 48.1 AO 47.3 BI 47.1 UG 46.6 SL 46.2 TD 45.5 RW 44.5 BF 44.0 SO 42.9 TL 42.1 MW 40.7 BJ 40.2 NG 39.9 GN 39.8 MZ 39.5 ER 39.3 ZM 39.3 KE 39.2 RO 39.0 GQ 38.5 YE 38.3 ET 38.2 TG 36.8 MG 36.4 CF 36.1 PS 35.9 CI 35.3 SN 35.2 IM 35.1 GM 34.9 CM 34.5 KM 33.4 GT 33.2 MR 32.5 ST 32.4 IQ 31.7 SD 31.5 SB 30.5 GH 29.6 PG 29.6 LS 29.0 CV 28.9 VU 28.8 DJ 28.7 SZ 28.5 NP 28.1 HT 27.9 HN 27.9 ZW 27.9 BO 27.3 TJ 27.3 PK 27.2 WS 26.8 RS 26.7 KH 26.4 JO 25.9 US 25.9 PH 25.8 GA 25.7 NA 25.7 TO 25.6 BZ 25.2 BW 24.9 NI 24.9 SA 24.9 BD 24.8 PY 24.8 WS 24.7 EG 24.2 GF 23.9 DO 23.5 CU 23.4 MV 23.4 EH 23.3 IN 23.0 SV 22.8 UZ 22.6 ZA 22.3 OM 22.1 KG 21.8 TM 21.8 BI 21.5 VE 21.4 FJ 21.1 EC 21.0 PE 20.9 DZ 20.8 PA 20.8 MY 20.6 MA 20.5 IQ 20.3 VC 20.1 JM 19.9 IL 19.7 KZ 19.7 SR 19.5 MX 19.3 BR 19.2 LC 19.1 VN 18.8 CO 18.7 ID 18.7 BT 18.5 US 18.5 MN 18.4 TR 18.4 PF 18.3 LB 18.2 MM 18.2 GD 18.0 RE 18.0 KW 17.9 CR 17.8 AR 17.5 BH 17.1 GY 17.1 BS 16.9 TN 16.7 NC 16.4 AL 16.3 AZ 16.2 QA 16.2 AE 16.2 IE 15.5 UY 15.1 CL 15.0 LK 15.0 MU 14.8 GP 14.8 TT 14.8 TH 14.6 IS 14.3 NL 14.1 US 14.0 NZ 13.7 ME 13.6 VG 13.4 US 13.3 ZA 13.2 KR 13.1 RS 12.8 AM 12.5 AN 12.5 AU 12.4 MQ 12.4 CY 12.2 GF 12.2 GB 12.0 NO 12.0 LU 11.5 BO 11.4 SE 11.3 DK 11.2 FI 11.2 NL 11.1 BB 11.0 NC 10.9 EE 10.8 GE 10.8 ES 10.8 TN 10.7 PT 10.5 BE 10.4 CA 10.3 CU 10.3 SK 10.0 MT 9.8 RO 9.8 PL 9.5 GB 9.4 BY 9.4 GR 9.3 HU 9.3 ZA 9.3 LV 9.3 AT 9.2 CZ 9.2 IT 9.2 CH 9.2 UA 9.2 LT 9.1 HR 9.0 SI 9.0 BG 8.9 BA 8.8 JP 8.3 DE 8.2 SG 8.2 CD 7.6 MD 7.6 pygooglechart-0.4.0+git20140622/examples/mapchart.py000077500000000000000000000032731232510607000217550ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ import os import sys ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, '..')) from pygooglechart import MapChart import settings import helper def birth_rate(): # Create a chart object of 200x100 pixels chart = MapChart(440, 220) # Load the data from a file, create a dict that looks like: # {'AU': 5, 'YE': 10} data = {} countries = open('mapchart-birth-rate.txt', 'r').read().split('\n') for line in countries[:-1]: code, score = line.split(' ', 1) data[code] = float(score) # Set the data dictionary for country codes to value mapping chart.add_data_dict(data) # Download the chart chart.download('mapchart-birth-rate.png') # Now do it in africa ... chart.set_geo_area('africa') # ... with white as the default colour and gradient from green to red chart.set_colours(('EEEEEE', '10A010', 'D03000')) chart.download('mapchart-birth-rate-africa.png') def main(): birth_rate() if __name__ == '__main__': main() pygooglechart-0.4.0+git20140622/examples/pie.py000077500000000000000000000032571232510607000207350ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ import os import sys ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, '..')) from pygooglechart import PieChart2D from pygooglechart import PieChart3D import settings import helper def hello_world(): # Create a chart object of 200x100 pixels chart = PieChart3D(250, 100) # Add some data chart.add_data([20, 10]) # Assign the labels to the pie data chart.set_pie_labels(['Hello', 'World']) # Download the chart chart.download('pie-hello-world.png') def house_explosions(): """ Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html """ chart = PieChart2D(int(settings.width * 1.7), settings.height) chart.add_data([10, 10, 30, 200]) chart.set_pie_labels([ 'Budding Chemists', 'Propane issues', 'Meth Labs', 'Attempts to escape morgage', ]) chart.download('pie-house-explosions.png') def main(): hello_world() house_explosions() if __name__ == '__main__': main() pygooglechart-0.4.0+git20140622/examples/qrcodes.py000077500000000000000000000022571232510607000216170ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ import os import sys import math ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, '..')) from pygooglechart import QRChart import settings import helper def hello(): # Create a 250x250 QR chart chart = QRChart(250, 250) # Add the text chart.add_data('Hello, World!') # "Level H" error correction with a 0 pixel margin chart.set_ec('H', 0) # Download chart.download('qr-hello.png') def main(): hello() if __name__ == '__main__': main() pygooglechart-0.4.0+git20140622/examples/scatter.py000077500000000000000000000043351232510607000216230ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ from __future__ import division import os import sys import math ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, '..')) from pygooglechart import ScatterChart import settings import helper def scatter_random(): chart = ScatterChart(settings.width, settings.height, x_range=(0, 100), y_range=(0, 100)) chart.add_data(helper.random_data()) chart.add_data(helper.random_data()) chart.download('scatter-random.png') def scatter_random_marker_sizes(): chart = ScatterChart(settings.width, settings.height, x_range=(0, 100), y_range=(0, 100)) chart.add_data(helper.random_data()) chart.add_data(helper.random_data()) chart.add_data(helper.random_data()) chart.download('scatter-random-marker-sizes.png') def scatter_circle(): chart = ScatterChart(settings.width, settings.height, x_range=(0, 100), y_range=(0, 100)) steps = 40 xradius = 25 yradius = 45 xmid = 50 ymid = 50 xlist = [] ylist = [] for angle in range(0, steps + 1): angle = float(angle) / steps * math.pi * 2 xlist.append(math.cos(angle) * xradius + xmid) ylist.append(math.sin(angle) * yradius + ymid) chart.add_data(xlist) chart.add_data(ylist) chart.add_data(list(range(len(ylist)))) chart.add_marker(0, 1.0, 'o', '00ff00', 10) chart.download('scatter-circle.png') def main(): scatter_random() scatter_random_marker_sizes() scatter_circle() if __name__ == '__main__': main() pygooglechart-0.4.0+git20140622/examples/settings.py000077500000000000000000000000611232510607000220060ustar00rootroot00000000000000#!/usr/bin/env python width = 250 height = 100 pygooglechart-0.4.0+git20140622/examples/venn.py000077500000000000000000000024401232510607000211170ustar00rootroot00000000000000#!/usr/bin/env python """ Copyright Gerald Kaszuba 2008 This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ import os import sys ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, '..')) from pygooglechart import VennChart import settings import helper def ultimate_power(): """ Data from http://indexed.blogspot.com/2007/08/real-ultimate-power.html """ chart = VennChart(settings.width, settings.height) chart.add_data([100, 100, 100, 20, 20, 20, 10]) chart.set_title('Ninjas or God') chart.set_legend(['unseen agents', 'super powerful', 'secret plans']) chart.download('venn-ultimate-power.png') def main(): ultimate_power() if __name__ == '__main__': main() pygooglechart-0.4.0+git20140622/pygooglechart.py000066400000000000000000001145511232510607000212060ustar00rootroot00000000000000#!/usr/bin/env python """ pygooglechart - A complete Python wrapper for the Google Chart API http://pygooglechart.slowchop.com/ Copyright 2007-2013 Gerald Kaszuba This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . """ # unnecessary on Python3, but harmless from __future__ import division import os import math import random import re import warnings import copy try: # we're on Python3 from urllib.request import urlopen from urllib.parse import quote except ImportError: # we're on Python2.x from urllib2 import urlopen from urllib import quote # Helper variables and functions # ----------------------------------------------------------------------------- __version__ = '0.4.0' __author__ = 'Gerald Kaszuba' reo_colour = re.compile('^([A-Fa-f0-9]{2,2}){3,4}$') def _check_colour(colour): if not reo_colour.match(colour): raise InvalidParametersException('Colours need to be in ' \ 'RRGGBB or RRGGBBAA format. One of your colours has %s' % \ colour) def _reset_warnings(): """Helper function to reset all warnings. Used by the unit tests.""" globals()['__warningregistry__'] = None # Exception Classes # ----------------------------------------------------------------------------- class PyGoogleChartException(Exception): pass class DataOutOfRangeException(PyGoogleChartException): pass class UnknownDataTypeException(PyGoogleChartException): pass class NoDataGivenException(PyGoogleChartException): pass class InvalidParametersException(PyGoogleChartException): pass class BadContentTypeException(PyGoogleChartException): pass class AbstractClassException(PyGoogleChartException): pass class UnknownChartType(PyGoogleChartException): pass class UnknownCountryCodeException(PyGoogleChartException): pass # Data Classes # ----------------------------------------------------------------------------- class Data(object): def __init__(self, data): if type(self) == Data: raise AbstractClassException('This is an abstract class') self.data = data @classmethod def float_scale_value(cls, value, range): lower, upper = range assert(upper > lower) scaled = (value - lower) * (cls.max_value / (upper - lower)) return scaled @classmethod def clip_value(cls, value): return max(0, min(value, cls.max_value)) @classmethod def int_scale_value(cls, value, range): return int(round(cls.float_scale_value(value, range))) @classmethod def scale_value(cls, value, range): scaled = cls.int_scale_value(value, range) clipped = cls.clip_value(scaled) Data.check_clip(scaled, clipped) return clipped @staticmethod def check_clip(scaled, clipped): if clipped != scaled: warnings.warn('One or more of of your data points has been ' 'clipped because it is out of range.') class SimpleData(Data): max_value = 61 enc_map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' def __repr__(self): encoded_data = [] for data in self.data: sub_data = [] for value in data: if value is None: sub_data.append('_') elif value >= 0 and value <= self.max_value: sub_data.append(SimpleData.enc_map[value]) else: raise DataOutOfRangeException('cannot encode value: %d' % value) encoded_data.append(''.join(sub_data)) return 'chd=s:' + ','.join(encoded_data) class TextData(Data): max_value = 100 def __repr__(self): encoded_data = [] for data in self.data: sub_data = [] for value in data: if value is None: sub_data.append(-1) elif value >= 0 and value <= self.max_value: sub_data.append("%.1f" % float(value)) else: raise DataOutOfRangeException() encoded_data.append(','.join(sub_data)) return 'chd=t:' + '%7c'.join(encoded_data) @classmethod def scale_value(cls, value, range): # use float values instead of integers because we don't need an encode # map index scaled = cls.float_scale_value(value, range) clipped = cls.clip_value(scaled) Data.check_clip(scaled, clipped) return clipped class ExtendedData(Data): max_value = 4095 enc_map = \ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.' def __repr__(self): encoded_data = [] enc_size = len(ExtendedData.enc_map) for data in self.data: sub_data = [] for value in data: if value is None: sub_data.append('__') elif value >= 0 and value <= self.max_value: first, second = divmod(int(value), enc_size) sub_data.append('%s%s' % ( ExtendedData.enc_map[first], ExtendedData.enc_map[second])) else: raise DataOutOfRangeException( \ 'Item #%i "%s" is out of range' % (data.index(value), \ value)) encoded_data.append(''.join(sub_data)) return 'chd=e:' + ','.join(encoded_data) # Axis Classes # ----------------------------------------------------------------------------- class Axis(object): BOTTOM = 'x' TOP = 't' LEFT = 'y' RIGHT = 'r' TYPES = (BOTTOM, TOP, LEFT, RIGHT) def __init__(self, axis_index, axis_type, **kw): assert(axis_type in Axis.TYPES) self.has_style = False self.axis_index = axis_index self.axis_type = axis_type self.positions = None def set_index(self, axis_index): self.axis_index = axis_index def set_positions(self, positions): self.positions = positions def set_style(self, colour, font_size=None, alignment=None): _check_colour(colour) self.colour = colour self.font_size = font_size self.alignment = alignment self.has_style = True def style_to_url(self): bits = [] bits.append(str(self.axis_index)) bits.append(self.colour) if self.font_size is not None: bits.append(str(self.font_size)) if self.alignment is not None: bits.append(str(self.alignment)) return ','.join(bits) def positions_to_url(self): bits = [] bits.append(str(self.axis_index)) bits += [str(a) for a in self.positions] return ','.join(bits) class LabelAxis(Axis): def __init__(self, axis_index, axis_type, values, **kwargs): Axis.__init__(self, axis_index, axis_type, **kwargs) self.values = [str(a) for a in values] def __repr__(self): return '%i:%%7c%s' % (self.axis_index, '%7c'.join(self.values)) class RangeAxis(Axis): def __init__(self, axis_index, axis_type, low, high, **kwargs): Axis.__init__(self, axis_index, axis_type, **kwargs) self.low = low self.high = high def __repr__(self): return '%i,%s,%s' % (self.axis_index, self.low, self.high) # Chart Classes # ----------------------------------------------------------------------------- class Chart(object): """Abstract class for all chart types. width are height specify the dimensions of the image. title sets the title of the chart. legend requires a list that corresponds to datasets. """ BASE_URL = 'http://www.google.com/chart' BACKGROUND = 'bg' CHART = 'c' ALPHA = 'a' VALID_SOLID_FILL_TYPES = (BACKGROUND, CHART, ALPHA) SOLID = 's' LINEAR_GRADIENT = 'lg' LINEAR_STRIPES = 'ls' def __init__(self, width, height, title=None, legend=None, colours=None, auto_scale=True, x_range=None, y_range=None, colours_within_series=None): if type(self) == Chart: raise AbstractClassException('This is an abstract class') assert(isinstance(width, int)) assert(isinstance(height, int)) self.width = width self.height = height self.data = [] self.set_title(title) self.set_title_style(None, None) self.set_legend(legend) self.set_legend_position(None) self.set_colours(colours) self.set_colours_within_series(colours_within_series) # Data for scaling. self.auto_scale = auto_scale # Whether to automatically scale data self.x_range = x_range # (min, max) x-axis range for scaling self.y_range = y_range # (min, max) y-axis range for scaling self.scaled_data_class = None self.scaled_x_range = None self.scaled_y_range = None self.fill_types = { Chart.BACKGROUND: None, Chart.CHART: None, Chart.ALPHA: None, } self.fill_area = { Chart.BACKGROUND: None, Chart.CHART: None, Chart.ALPHA: None, } self.axis = [] self.markers = [] self.line_styles = {} self.grid = None self.title_colour = None self.title_font_size = None # URL generation # ------------------------------------------------------------------------- def get_url(self, data_class=None): return self.BASE_URL + '?' + self.get_url_extension(data_class) def get_url_extension(self, data_class=None): url_bits = self.get_url_bits(data_class=data_class) return '&'.join(url_bits) def get_url_bits(self, data_class=None): url_bits = [] # required arguments url_bits.append(self.type_to_url()) url_bits.append('chs=%ix%i' % (self.width, self.height)) url_bits.append(self.data_to_url(data_class=data_class)) # optional arguments if self.title: url_bits.append('chtt=%s' % self.title) if self.title_colour and self.title_font_size: url_bits.append('chts=%s,%s' % (self.title_colour, \ self.title_font_size)) if self.legend: url_bits.append('chdl=%s' % '%7c'.join(self.legend)) if self.legend_position: url_bits.append('chdlp=%s' % (self.legend_position)) if self.colours: url_bits.append('chco=%s' % '|'.join(self.colours)) if self.colours_within_series: url_bits.append('chco=%s' % '%7c'.join(self.colours_within_series)) ret = self.fill_to_url() if ret: url_bits.append(ret) ret = self.axis_to_url() if ret: url_bits.append(ret) if self.markers: url_bits.append(self.markers_to_url()) if self.line_styles: style = [] for index in range(max(self.line_styles) + 1): if index in self.line_styles: values = self.line_styles[index] else: values = ('1', ) style.append(','.join(values)) url_bits.append('chls=%s' % '%7c'.join(style)) if self.grid: url_bits.append('chg=%s' % self.grid) return url_bits # Downloading # ------------------------------------------------------------------------- def download(self, file_name=False, use_post=True): if use_post: opener = urlopen(self.BASE_URL, self.get_url_extension().encode('utf-8')) else: opener = urlopen(self.get_url()) if opener.headers['content-type'] != 'image/png': raise BadContentTypeException('Server responded with a ' \ 'content-type of %s' % opener.headers['content-type']) if file_name: open(file_name, 'wb').write(opener.read()) else: return opener.read() # Simple settings # ------------------------------------------------------------------------- def set_title(self, title): if title: self.title = quote(title) else: self.title = None def set_title_style(self, colour=None, font_size=None): if not colour is None: _check_colour(colour) if not colour and not font_size: return self.title_colour = colour or '333333' self.title_font_size = font_size or 13.5 def set_legend(self, legend): """legend needs to be a list, tuple or None""" assert(isinstance(legend, list) or isinstance(legend, tuple) or legend is None) if legend: self.legend = [quote(a) for a in legend] else: self.legend = None def set_legend_position(self, legend_position): """Sets legend position. Default is 'r'. b - At the bottom of the chart, legend entries in a horizontal row. bv - At the bottom of the chart, legend entries in a vertical column. t - At the top of the chart, legend entries in a horizontal row. tv - At the top of the chart, legend entries in a vertical column. r - To the right of the chart, legend entries in a vertical column. l - To the left of the chart, legend entries in a vertical column. """ if legend_position: self.legend_position = quote(legend_position) else: self.legend_position = None # Chart colours # ------------------------------------------------------------------------- def set_colours(self, colours): # colours needs to be a list, tuple or None assert(isinstance(colours, list) or isinstance(colours, tuple) or colours is None) # make sure the colours are in the right format if colours: for col in colours: _check_colour(col) self.colours = colours def set_colours_within_series(self, colours): # colours needs to be a list, tuple or None assert(isinstance(colours, list) or isinstance(colours, tuple) or colours is None) # make sure the colours are in the right format if colours: for col in colours: _check_colour(col) self.colours_within_series = colours # Background/Chart colours # ------------------------------------------------------------------------- def fill_solid(self, area, colour): assert(area in Chart.VALID_SOLID_FILL_TYPES) _check_colour(colour) self.fill_area[area] = colour self.fill_types[area] = Chart.SOLID def _check_fill_linear(self, angle, *args): assert(isinstance(args, list) or isinstance(args, tuple)) assert(angle >= 0 and angle <= 90) assert(len(args) % 2 == 0) args = list(args) # args is probably a tuple and we need to mutate for a in range(int(len(args) / 2)): col = args[a * 2] offset = args[a * 2 + 1] _check_colour(col) assert(offset >= 0 and offset <= 1) args[a * 2 + 1] = str(args[a * 2 + 1]) return args def fill_linear_gradient(self, area, angle, *args): assert(area in Chart.VALID_SOLID_FILL_TYPES) args = self._check_fill_linear(angle, *args) self.fill_types[area] = Chart.LINEAR_GRADIENT self.fill_area[area] = ','.join([str(angle)] + args) def fill_linear_stripes(self, area, angle, *args): assert(area in Chart.VALID_SOLID_FILL_TYPES) args = self._check_fill_linear(angle, *args) self.fill_types[area] = Chart.LINEAR_STRIPES self.fill_area[area] = ','.join([str(angle)] + args) def fill_to_url(self): areas = [] for area in (Chart.BACKGROUND, Chart.CHART, Chart.ALPHA): if self.fill_types[area]: areas.append('%s,%s,%s' % (area, self.fill_types[area], \ self.fill_area[area])) if areas: return 'chf=' + '%7c'.join(areas) # Data # ------------------------------------------------------------------------- def data_class_detection(self, data): """Determines the appropriate data encoding type to give satisfactory resolution (http://code.google.com/apis/chart/#chart_data). """ assert(isinstance(data, list) or isinstance(data, tuple)) if not isinstance(self, (LineChart, BarChart, ScatterChart)): # From the link above: # Simple encoding is suitable for all other types of chart # regardless of size. return SimpleData elif self.height < 100: # The link above indicates that line and bar charts less # than 300px in size can be suitably represented with the # simple encoding. I've found that this isn't sufficient, # e.g. examples/line-xy-circle.png. Let's try 100px. return SimpleData else: return ExtendedData def _filter_none(self, data): return [r for r in data if r is not None] def data_x_range(self): """Return a 2-tuple giving the minimum and maximum x-axis data range. """ try: lower = min([min(self._filter_none(s)) for type, s in self.annotated_data() if type == 'x']) upper = max([max(self._filter_none(s)) for type, s in self.annotated_data() if type == 'x']) return (lower, upper) except ValueError: return None # no x-axis datasets def data_y_range(self): """Return a 2-tuple giving the minimum and maximum y-axis data range. """ try: lower = min([min(self._filter_none(s)) for type, s in self.annotated_data() if type == 'y']) upper = max([max(self._filter_none(s)) + 1 for type, s in self.annotated_data() if type == 'y']) return (lower, upper) except ValueError: return None # no y-axis datasets def scaled_data(self, data_class, x_range=None, y_range=None): """Scale `self.data` as appropriate for the given data encoding (data_class) and return it. An optional `y_range` -- a 2-tuple (lower, upper) -- can be given to specify the y-axis bounds. If not given, the range is inferred from the data: (0, ) presuming no negative values, or (, ) if there are negative values. `self.scaled_y_range` is set to the actual lower and upper scaling range. Ditto for `x_range`. Note that some chart types don't have x-axis data. """ self.scaled_data_class = data_class # Determine the x-axis range for scaling. if x_range is None: x_range = self.data_x_range() if x_range and x_range[0] > 0: x_range = (x_range[0], x_range[1]) self.scaled_x_range = x_range # Determine the y-axis range for scaling. if y_range is None: y_range = self.data_y_range() if y_range and y_range[0] > 0: y_range = (y_range[0], y_range[1]) self.scaled_y_range = y_range scaled_data = [] for type, dataset in self.annotated_data(): if type == 'x': scale_range = x_range elif type == 'y': scale_range = y_range elif type == 'marker-size': scale_range = (0, max(dataset)) scaled_dataset = [] for v in dataset: if v is None: scaled_dataset.append(None) else: scaled_dataset.append( data_class.scale_value(v, scale_range)) scaled_data.append(scaled_dataset) return scaled_data def add_data(self, data): self.data.append(data) return len(self.data) - 1 # return the "index" of the data set def data_to_url(self, data_class=None): if not data_class: data_class = self.data_class_detection(self.data) if not issubclass(data_class, Data): raise UnknownDataTypeException() if self.auto_scale: data = self.scaled_data(data_class, self.x_range, self.y_range) else: data = self.data return repr(data_class(data)) def annotated_data(self): for dataset in self.data: yield ('x', dataset) # Axis Labels # ------------------------------------------------------------------------- def set_axis_labels(self, axis_type, values): assert(axis_type in Axis.TYPES) values = [quote(str(a)) for a in values] axis_index = len(self.axis) axis = LabelAxis(axis_index, axis_type, values) self.axis.append(axis) return axis_index def set_axis_range(self, axis_type, low, high): assert(axis_type in Axis.TYPES) axis_index = len(self.axis) axis = RangeAxis(axis_index, axis_type, low, high) self.axis.append(axis) return axis_index def set_axis_positions(self, axis_index, positions): try: self.axis[axis_index].set_positions(positions) except IndexError: raise InvalidParametersException('Axis index %i has not been ' \ 'created' % axis) def set_axis_style(self, axis_index, colour, font_size=None, \ alignment=None): try: self.axis[axis_index].set_style(colour, font_size, alignment) except IndexError: raise InvalidParametersException('Axis index %i has not been ' \ 'created' % axis) def axis_to_url(self): available_axis = [] label_axis = [] range_axis = [] positions = [] styles = [] index = -1 for axis in self.axis: available_axis.append(axis.axis_type) if isinstance(axis, RangeAxis): range_axis.append(repr(axis)) if isinstance(axis, LabelAxis): label_axis.append(repr(axis)) if axis.positions: positions.append(axis.positions_to_url()) if axis.has_style: styles.append(axis.style_to_url()) if not available_axis: return url_bits = [] url_bits.append('chxt=%s' % ','.join(available_axis)) if label_axis: url_bits.append('chxl=%s' % '%7c'.join(label_axis)) if range_axis: url_bits.append('chxr=%s' % '%7c'.join(range_axis)) if positions: url_bits.append('chxp=%s' % '%7c'.join(positions)) if styles: url_bits.append('chxs=%s' % '%7c'.join(styles)) return '&'.join(url_bits) # Markers, Ranges and Fill area (chm) # ------------------------------------------------------------------------- def markers_to_url(self): return 'chm=%s' % '%7c'.join([','.join(a) for a in self.markers]) def add_marker(self, index, point, marker_type, colour, size, priority=0): self.markers.append((marker_type, colour, str(index), str(point), \ str(size), str(priority))) def add_horizontal_range(self, colour, start, stop): self.markers.append(('r', colour, '0', str(start), str(stop))) def add_data_line(self, colour, data_set, size, priority=0): self.markers.append(('D', colour, str(data_set), '0', str(size), \ str(priority))) def add_marker_text(self, string, colour, data_set, data_point, size, \ priority=0): self.markers.append((str(string), colour, str(data_set), \ str(data_point), str(size), str(priority))) def add_vertical_range(self, colour, start, stop): self.markers.append(('R', colour, '0', str(start), str(stop))) def add_fill_range(self, colour, index_start, index_end): self.markers.append(('b', colour, str(index_start), str(index_end), \ '1')) def add_fill_simple(self, colour): self.markers.append(('B', colour, '1', '1', '1')) # Line styles # ------------------------------------------------------------------------- def set_line_style(self, index, thickness=1, line_segment=None, \ blank_segment=None): value = [] value.append(str(thickness)) if line_segment: value.append(str(line_segment)) value.append(str(blank_segment)) self.line_styles[index] = value # Grid # ------------------------------------------------------------------------- def set_grid(self, x_step, y_step, line_segment=1, \ blank_segment=0): self.grid = '%s,%s,%s,%s' % (x_step, y_step, line_segment, \ blank_segment) class ScatterChart(Chart): def type_to_url(self): return 'cht=s' def annotated_data(self): yield ('x', self.data[0]) yield ('y', self.data[1]) if len(self.data) > 2: # The optional third dataset is relative sizing for point # markers. yield ('marker-size', self.data[2]) class LineChart(Chart): def __init__(self, *args, **kwargs): if type(self) == LineChart: raise AbstractClassException('This is an abstract class') Chart.__init__(self, *args, **kwargs) class SimpleLineChart(LineChart): def type_to_url(self): return 'cht=lc' def annotated_data(self): # All datasets are y-axis data. for dataset in self.data: yield ('y', dataset) class SparkLineChart(SimpleLineChart): def type_to_url(self): return 'cht=ls' class XYLineChart(LineChart): def type_to_url(self): return 'cht=lxy' def annotated_data(self): # Datasets alternate between x-axis, y-axis. for i, dataset in enumerate(self.data): if i % 2 == 0: yield ('x', dataset) else: yield ('y', dataset) class BarChart(Chart): def __init__(self, *args, **kwargs): if type(self) == BarChart: raise AbstractClassException('This is an abstract class') Chart.__init__(self, *args, **kwargs) self.bar_width = None self.zero_lines = {} def set_bar_width(self, bar_width): self.bar_width = bar_width def set_zero_line(self, index, zero_line): self.zero_lines[index] = zero_line def get_url_bits(self, data_class=None, skip_chbh=False): url_bits = Chart.get_url_bits(self, data_class=data_class) if not skip_chbh and self.bar_width is not None: url_bits.append('chbh=%i' % self.bar_width) zero_line = [] if self.zero_lines: for index in range(max(self.zero_lines) + 1): if index in self.zero_lines: zero_line.append(str(self.zero_lines[index])) else: zero_line.append('0') url_bits.append('chp=%s' % ','.join(zero_line)) return url_bits class StackedHorizontalBarChart(BarChart): def type_to_url(self): return 'cht=bhs' class StackedVerticalBarChart(BarChart): def type_to_url(self): return 'cht=bvs' def annotated_data(self): for dataset in self.data: yield ('y', dataset) class GroupedBarChart(BarChart): def __init__(self, *args, **kwargs): if type(self) == GroupedBarChart: raise AbstractClassException('This is an abstract class') BarChart.__init__(self, *args, **kwargs) self.bar_spacing = None self.group_spacing = None def set_bar_spacing(self, spacing): """Set spacing between bars in a group.""" self.bar_spacing = spacing def set_group_spacing(self, spacing): """Set spacing between groups of bars.""" self.group_spacing = spacing def get_url_bits(self, data_class=None): # Skip 'BarChart.get_url_bits' and call Chart directly so the parent # doesn't add "chbh" before we do. url_bits = BarChart.get_url_bits(self, data_class=data_class, skip_chbh=True) if self.group_spacing is not None: if self.bar_spacing is None: raise InvalidParametersException('Bar spacing is required ' \ 'to be set when setting group spacing') if self.bar_width is None: raise InvalidParametersException('Bar width is required to ' \ 'be set when setting bar spacing') url_bits.append('chbh=%i,%i,%i' % (self.bar_width, self.bar_spacing, self.group_spacing)) elif self.bar_spacing is not None: if self.bar_width is None: raise InvalidParametersException('Bar width is required to ' \ 'be set when setting bar spacing') url_bits.append('chbh=%i,%i' % (self.bar_width, self.bar_spacing)) elif self.bar_width: url_bits.append('chbh=%i' % self.bar_width) return url_bits class GroupedHorizontalBarChart(GroupedBarChart): def type_to_url(self): return 'cht=bhg' class GroupedVerticalBarChart(GroupedBarChart): def type_to_url(self): return 'cht=bvg' def annotated_data(self): for dataset in self.data: yield ('y', dataset) class PieChart(Chart): def __init__(self, *args, **kwargs): if type(self) == PieChart: raise AbstractClassException('This is an abstract class') Chart.__init__(self, *args, **kwargs) self.pie_labels = [] if self.y_range: warnings.warn('y_range is not used with %s.' % \ (self.__class__.__name__)) def set_pie_labels(self, labels): self.pie_labels = [quote(a) for a in labels] def get_url_bits(self, data_class=None): url_bits = Chart.get_url_bits(self, data_class=data_class) if self.pie_labels: url_bits.append('chl=%s' % '%7c'.join(self.pie_labels)) return url_bits def annotated_data(self): # Datasets are all y-axis data. However, there should only be # one dataset for pie charts. for dataset in self.data: yield ('x', dataset) def scaled_data(self, data_class, x_range=None, y_range=None): if not x_range: x_range = [0, sum(self.data[0])] return Chart.scaled_data(self, data_class, x_range, self.y_range) class PieChart2D(PieChart): def type_to_url(self): return 'cht=p' class PieChart3D(PieChart): def type_to_url(self): return 'cht=p3' class VennChart(Chart): def type_to_url(self): return 'cht=v' def annotated_data(self): for dataset in self.data: yield ('y', dataset) class RadarChart(Chart): def type_to_url(self): return 'cht=r' class SplineRadarChart(RadarChart): def type_to_url(self): return 'cht=rs' class MapChart(Chart): def __init__(self, *args, **kwargs): Chart.__init__(self, *args, **kwargs) self.geo_area = 'world' self.codes = [] self.__areas = ('africa', 'asia', 'europe', 'middle_east', 'south_america', 'usa', 'world') self.__ccodes = ( 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'ST', 'SV', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW') def type_to_url(self): return 'cht=t' def set_codes(self, codes): '''Set the country code map for the data. Codes given in a list. i.e. DE - Germany AT - Austria US - United States ''' codemap = '' for cc in codes: cc = cc.upper() if cc in self.__ccodes: codemap += cc else: raise UnknownCountryCodeException(cc) self.codes = codemap def set_geo_area(self, area): '''Sets the geo area for the map. * africa * asia * europe * middle_east * south_america * usa * world ''' if area in self.__areas: self.geo_area = area else: raise UnknownChartType('Unknown chart type for maps: %s' %area) def get_url_bits(self, data_class=None): url_bits = Chart.get_url_bits(self, data_class=data_class) url_bits.append('chtm=%s' % self.geo_area) if self.codes: url_bits.append('chld=%s' % ''.join(self.codes)) return url_bits def add_data_dict(self, datadict): '''Sets the data and country codes via a dictionary. i.e. {'DE': 50, 'GB': 30, 'AT': 70} ''' self.set_codes(list(datadict.keys())) self.add_data(list(datadict.values())) class GoogleOMeterChart(PieChart): """Inheriting from PieChart because of similar labeling""" def __init__(self, *args, **kwargs): PieChart.__init__(self, *args, **kwargs) if self.auto_scale and not self.x_range: warnings.warn('Please specify an x_range with GoogleOMeterChart, ' 'otherwise one arrow will always be at the max.') def type_to_url(self): return 'cht=gom' class QRChart(Chart): def __init__(self, *args, **kwargs): Chart.__init__(self, *args, **kwargs) self.encoding = None self.ec_level = None self.margin = None def type_to_url(self): return 'cht=qr' def data_to_url(self, data_class=None): if not self.data: raise NoDataGivenException() return 'chl=%s' % quote(self.data[0]) def get_url_bits(self, data_class=None): url_bits = Chart.get_url_bits(self, data_class=data_class) if self.encoding: url_bits.append('choe=%s' % self.encoding) if self.ec_level: url_bits.append('chld=%s%%7c%s' % (self.ec_level, self.margin)) return url_bits def set_encoding(self, encoding): self.encoding = encoding def set_ec(self, level, margin): self.ec_level = level self.margin = margin class ChartGrammar(object): def __init__(self): self.grammar = None self.chart = None def parse(self, grammar): self.grammar = grammar self.chart = self.create_chart_instance() for attr in self.grammar: if attr in ('w', 'h', 'type', 'auto_scale', 'x_range', 'y_range'): continue # These are already parsed in create_chart_instance attr_func = 'parse_' + attr if not hasattr(self, attr_func): warnings.warn('No parser for grammar attribute "%s"' % (attr)) continue getattr(self, attr_func)(grammar[attr]) return self.chart def parse_data(self, data): self.chart.data = data @staticmethod def get_possible_chart_types(): possible_charts = [] for cls_name in list(globals().keys()): if not cls_name.endswith('Chart'): continue cls = globals()[cls_name] # Check if it is an abstract class try: a = cls(1, 1, auto_scale=False) del a except AbstractClassException: continue # Strip off "Class" possible_charts.append(cls_name[:-5]) return possible_charts def create_chart_instance(self, grammar=None): if not grammar: grammar = self.grammar assert(isinstance(grammar, dict)) # grammar must be a dict assert('w' in grammar) # width is required assert('h' in grammar) # height is required assert('type' in grammar) # type is required chart_type = grammar['type'] w = grammar['w'] h = grammar['h'] auto_scale = grammar.get('auto_scale', None) x_range = grammar.get('x_range', None) y_range = grammar.get('y_range', None) types = ChartGrammar.get_possible_chart_types() if chart_type not in types: raise UnknownChartType('%s is an unknown chart type. Possible ' 'chart types are %s' % (chart_type, ','.join(types))) return globals()[chart_type + 'Chart'](w, h, auto_scale=auto_scale, x_range=x_range, y_range=y_range) def download(self): pass pygooglechart-0.4.0+git20140622/scripts/000077500000000000000000000000001232510607000174455ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/scripts/make_dist.sh000077500000000000000000000003131232510607000217410ustar00rootroot00000000000000#!/bin/bash rm -fr dist python setup.py sdist --formats=gztar,zip python setup.py bdist --formats=wininst python setup.py register scp dist/* slowchop.com:/var/www/slowchop.com/pygooglechart/download/ pygooglechart-0.4.0+git20140622/setup.py000066400000000000000000000016461232510607000174770ustar00rootroot00000000000000from distutils.core import setup try: from setuptools import setup except ImportError: pass from pygooglechart import __version__ setup(name='pygooglechart', version=__version__, py_modules=['pygooglechart'], description='A complete Python wrapper for the Google Chart API', author='Gerald Kaszuba', author_email='gerald@geraldkaszuba.com', url='https://github.com/gak/pygooglechart', download_url='http://slowchop.com/pygooglechart/download/' \ 'pygooglechart-%s.tar.gz' % __version__, classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Topic :: Scientific/Engineering :: Visualization', 'Topic :: Software Development :: Libraries :: Python Modules', ], ) pygooglechart-0.4.0+git20140622/test/000077500000000000000000000000001232510607000167355ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/test/__init__.py000066400000000000000000000000001232510607000210340ustar00rootroot00000000000000pygooglechart-0.4.0+git20140622/test/test_base.py000066400000000000000000000017441232510607000212660ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest import sys import os import warnings try: import urllib.request, urllib.parse, urllib.error except ImportError: import urllib2 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.insert(0, ROOT) import pygooglechart as gc class TestBase(unittest.TestCase): def setUp(self): # All tests require warnings to be raised self.raise_warnings(True) self.temp_image = 'temp.png' def tearDown(self): if os.path.exists(self.temp_image): os.unlink(self.temp_image) def raise_warnings(self, rw): gc._reset_warnings() if rw: warnings.simplefilter('error') else: # Don't print out warnings if we're expecting them--so we can have # nicer looking tests! :) warnings.simplefilter('ignore') def assertChartURL(self, url, query): self.assertTrue(url.endswith(query)) pygooglechart-0.4.0+git20140622/test/test_bugs.py000066400000000000000000000006231232510607000213070ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest import sys import os import warnings try: import urllib.request, urllib.parse, urllib.error except ImportError: import urllib2 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.insert(0, ROOT) from test.test_base import TestBase import pygooglechart as gc if __name__ == "__main__": unittest.main() pygooglechart-0.4.0+git20140622/test/test_general.py000066400000000000000000000141371232510607000217710ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest import sys import os import warnings try: import urllib.request, urllib.parse, urllib.error except ImportError: import urllib2 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.insert(0, ROOT) from test.test_base import TestBase import pygooglechart as gc class TestDataTypes(TestBase): def test_simple_data(self): s = gc.SimpleData([list(range(0, 62)), [0, 1, 60, 61]]) self.assertEqual(repr(s), 'chd=s:ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz0123456789,AB89') def test_text_data(self): s = gc.TextData([[0, 1, 99.9]]) self.assertEqual(repr(s), 'chd=t:0.0,1.0,99.9') def test_ext_data(self): s = gc.ExtendedData([[0, 1, 4095]]) self.assertEqual(repr(s), 'chd=e:AAAB..') class TestScaling(TestBase): def test_simple_scale(self): sv = gc.SimpleData.scale_value self.raise_warnings(False) # We know some of these give warnings self.assertEqual(sv(-10, [0, 1]), 0) self.assertEqual(sv(0, [0, 1]), 0) # XXX this will change depending on whether we're in 2.x or 3.x; the # XXX behavior seems sufficient either way but it should be checked # XXX more thoroughly if sys.version_info >= (3, 0): expected = 30 else: expected = 31 self.assertEqual(sv(.5, [0, 1]), expected) self.assertEqual(sv(30, [0, 1]), 61) self.assertEqual(sv(2222, [0, 10000]), 14) # Test for warnings self.raise_warnings(True) self.assertRaises(UserWarning, sv, -10, [0, 1]) self.assertRaises(UserWarning, sv, 30, [0, 1]) def test_text_scale(self): sv = gc.TextData.scale_value self.raise_warnings(False) self.assertEqual(sv(-10, [0, 1]), 0) self.assertEqual(sv(0, [0, 1]), 0) self.assertEqual(sv(.5, [0, 1]), 50) self.assertEqual(sv(30, [0, 1]), 100) self.assertEqual(sv(2222, [0, 10000]), 22.22) self.raise_warnings(True) self.assertRaises(UserWarning, sv, -10, [0, 1]) self.assertRaises(UserWarning, sv, 30, [0, 1]) def test_ext_scale(self): sv = gc.ExtendedData.scale_value self.raise_warnings(False) self.assertEqual(sv(-10, [0, 1]), 0) self.assertEqual(sv(0, [0, 1]), 0) self.assertEqual(sv(.5, [0, 1]), 2048) self.assertEqual(sv(30, [0, 1]), 4095) self.assertEqual(sv(2222, [0, 10000]), 910) self.raise_warnings(True) self.assertRaises(UserWarning, sv, -10, [0, 1]) self.assertRaises(UserWarning, sv, 30, [0, 1]) class TestTitleStyle(TestBase): def test_title_style(self): chart = gc.SimpleLineChart(300, 100) chart.set_title_style() self.assertEqual(chart.title_colour, None) self.assertEqual(chart.title_font_size, None) chart = gc.SimpleLineChart(300, 100) chart.set_title_style(font_size=30) self.assertEqual(chart.title_colour, '333333') self.assertEqual(chart.title_font_size, 30) chart = gc.SimpleLineChart(300, 100) chart.set_title_style(colour='123456') self.assertEqual(chart.title_colour, '123456') self.assertEqual(chart.title_font_size, 13.5) chart = gc.SimpleLineChart(300, 100) chart.set_title_style(font_size=100, colour='123456') self.assertEqual(chart.title_colour, '123456') self.assertEqual(chart.title_font_size, 100) class TestLineChart(TestBase): def test_none_data(self): chart = gc.SimpleLineChart(300, 100) chart.add_data([1, 2, 3, None, 5]) print(chart.get_url()) self.assertChartURL(chart.get_url(), \ '?cht=lc&chs=300x100&chd=e:AAMzZm__zM') class TestQRChart(TestBase): def assertQRImage(self, chart, text): try: import PyQrcodec except ImportError: print('PyQrCodec not installed. Can not test QR code image') return chart.download(self.temp_image) status, string = PyQrcodec.decode(self.temp_image) self.assertTrue(status) self.assertEqual(text, string) def test_simple(self): text = 'Hello World' chart = gc.QRChart(100, 150) chart.add_data(text) self.assertChartURL(chart.get_url(), \ '?cht=qr&chs=100x150&chl=Hello%20World') def test_encoding(self): chart = gc.QRChart(100, 100) chart.add_data('Hello World') self.assertChartURL(chart.get_url(), \ '?cht=qr&chs=100x100&chl=Hello%20World') def test_no_data(self): chart = gc.QRChart(100, 100) self.assertRaises(gc.NoDataGivenException, chart.get_url) def test_validate_image(self): text = 'Hello World' chart = gc.QRChart(100, 100) chart.add_data(text) chart.set_ec('H', 0) # PyQrcodec seems to only work on higher EC self.assertQRImage(chart, text) def test_validate_utf8(self): text = 'こんにちは世界' # Hello world in Japanese UTF-8 chart = gc.QRChart(100, 100) chart.add_data(text) chart.set_ec('H', 0) self.assertQRImage(chart, text) class TestGrammar(TestBase): types = ('Venn', 'GroupedHorizontalBar', 'GoogleOMeter', 'Scatter', 'StackedVerticalBar', 'Map', 'StackedHorizontalBar', 'SimpleLine', 'SparkLine', 'GroupedVerticalBar', 'SplineRadar', 'XYLine', 'Radar', 'QR') def test_chart_types(self): ret = gc.ChartGrammar.get_possible_chart_types() diff = set(ret).symmetric_difference(set(TestGrammar.types)) self.assertTrue(not diff) def test_google_chart(self): g = { 'type': 'GoogleOMeter', 'w': 100, 'h': 100, 'auto_scale': True, 'x_range': [ 0, 10 ], 'data': [ [ 1, 5, 10 ] ], } grammar = gc.ChartGrammar() chart = grammar.parse(g) # print chart.get_url() # chart.download('meh.png') if __name__ == "__main__": unittest.main()