ChartDirector 5.1 (Python Edition)
Installation
Python Version Compatibility
ChartDirector for Python requires at least Python 1.5, and has been tested up to Python 3.2 (the latest Python release as of the date of this document).
Installing ChartDirector for Python
ChartDirector for Python is released as a zip file on Windows, and as a tar.gz file on Linux, FreeBSD, Mac OS X and Solaris. To install ChartDirector for Python:
- Extract the files from distribution.
- On Windows, you may use the Windows Explorer's built-in compressed folder support, 7-Zip or similar tools to extract the zip file.
- On Linux, FreeBSD, Mac OS X and Solaris, you may use:
gunzip [chartdir_file_name].tar.gz
tar xvf [chartdir_file_name].tar
- The files for the ChartDirector for Python module are in "ChartDirector/lib". Copy *everything* in "ChartDirector/lib" (including the fonts subdirectory in Linux, FreeBSD and Solaris versions) to a directory in your Python module search path.
If you do not know what is the Python module search path in your system, you may enter the following command to find out.
python -c "import sys;print(sys.path)"
If you could not access any of the directories in the default Python module search path (e.g. you are using a virtual web host, and the system directories are inaccessible to you), there are a number of alternative methods to install the ChartDirector for Python module. For example:
- Copy *everything* in "ChartDirector/lib" to the same directory as the script.
- Set the PYTHONPATH environment variable to add an extra directory to the Python module search path.
- Directly manipulate the "sys.path" variable in your Python script to change the Python module search path for your script.
Running ChartDirector Sample Programs
ChartDirector for Python comes with numerous sample Python scripts under the "ChartDirector/pythondemo" and "ChartDirector/pythondemo_cgi" directories. The former is for standalone scripts, while the latter is for CGI scripts. They are good examples and tutorials on how to use ChartDirector.
You may run these sample scripts to verify that ChartDirector is correctly installed.
To run the standalone ChartDirector sample scripts:
To run the ChartDirector sample CGI scripts:
- Copy all files in "ChartDirector/pythondemo_cgi" to your web server's CGI directory.
Note: If you have not installed the ChartDirector for Python module in a directory in your Python module search path, you would need to copy *everything* in "ChartDirector/lib" the same CGI script directory as the ChartDirector sample scripts.
- Browse the sample scripts by using a browser to access the sample scripts index page "index.py".
Note for Linux, FreeBSD, Mac OS X and Solaris: All ChartDirector sample scripts assume the Python interpreter is at "#!/usr/bin/python
" for Linux and Mac OS X, and "#!/usr/local/bin/python
" for FreeBSD and Solaris. If your Python interpreter is not at the expected location, you may create a symbolic link at the expected location to point to the actual location of your Python interpreter. (Of course, you may also change all scripts to use the actual location of your Python interpreter, but it is much easier to just make a link.)
If for some reason, you cannot see the charts, please click on the "check installation" link on main index page. This will perform a diagnostic test and display any error encountered.
Using ChartDirector for Python in Your Own Scripts
Any Python program that uses ChartDirector should include the following statement:
from pychartdir import *
or
import pychartdir
Depending on how you have installed ChartDirector, you may need to copy the ChartDirector for Python module files (*everything* in "ChartDirector/lib") to your script directory.
Installing the ChartDirector License
If you have purchased a license to use ChartDirector, you should have a license key delivered to your via email and postal mail.
If your license key is for upgrading from a previous version of ChartDirector, you need to append the upgrade license key to the previous version license key, and use the combined license key.
There are two alternative methods to install the license key.
- Create a one-line ASCII file using Notepad or other text editor, and put the license key in that line. The whole file should contain only the license key. Name that file "chartdir.lic" and put the file in the same directory as the active "libchartdir.so" (for Linux, FreeBSD, Mac OS X and Solaris) or "chartdir.dll" (for Windows), which should be in the directory where the ChartDirector for Python module is installed or copied to.
If the license file appears to have no effect (does not disable the yellow banner line), and you are running on a web server environment, please make sure the web server "anonymous user" has read access to the "chartdir.lic" file. You may copy the file "ChartDirector/pythondemo_cgi/cdinfo.py" to your web server and access it using a browser. It will display a diagnostic page explaining why the license cannot be loaded.
Make sure your license file is called "chartdir.lic". In particular, Notepad may automatically append ".txt" to the file name when creating a new file. So even if the file is saved as "chartdir.lic", it may end up as "chartdir.lic.txt". If this is the case, please rename the file back to "chartdir.lic".
- An alternative method is to hard code the license key into the source code by using the pychartdir.setLicenseCode API. This method is recommended if your are redistributing ChartDirector, because your customer will then be unable to see the license key (unless your software is open source).
setLicenseCode(".....your-license-key.....")
© 2012 Advanced Software Engineering Limited. All rights reserved.