The content of this document may be incorrect or outdated.
Print this article Edit this article
Zope: Creating a Graph or Chart using OpenFlashChart
OpenFlashChart is an Adobe Flash object for rendering charts and graphs on web pages. The developer create a data source which provides formatted data to the Flash object. This data specifies what and how information should be presented.
Creating a Data Source
A data source will almost always be a Python Script. The script outputs a formatted file which is used by the Flash object to present data. Below is an example data source script.
graph = container.ECN.Ztools.OpenFlashChart.createData()
graph.title('Example Graph', '{font-size: 20px;}')
graph.line(2, '#FF0000', 'Data', 10)
graph.set_data([10, 20, 15, 5])
graph.set_x_labels(['Apples','Oranges','Bananas','Grapes'])
graph.set_y_max(25)
graph.y_label_steps(5)
return graph.render()
This example data source represents a graph with one line plotting four points. The first line in this script creates a 'graph' object which provides methods to assist in creating the chart data. View a full list of methods of the graph object.
Embedding the Chart
Once a data source is defined the chart can be embedded within an Page Template or DTML Document by calling the following method, where data_source_script is the path to your data source script.
ECN.Ztools.OpenFlashChart.render('data_source_script', width=500, height=300)
This will output an object and embed tag to include the chart within your page.
Examples
Last Modified:
Dec 19, 2016 11:12 am US/Eastern
Created:
Jan 16, 2008 9:47 am US/Eastern
by
admin
JumpURL:
Categories
- Knowledge Base > Web > Zope