Data

After you have sent the appearance file to PopChart Server, you will usually want to override its data. You can do this by sending a segment of PopChart XML to PopChart Server that contains nothing but a Chart element with GraphData element(s).

The format of PopChart XML data (as well as much of the information in this section) is available "Sending Data with PopChart XML" in Chapter 6.

You will need to generate this PopChart XML yourself. Most people will generate their PopChart XML data in one of four ways:

Important: In order for PopChart Server to load any kind of file or data source, it must be given permission to read data from the specified path or domain. See "Setting Path Permissions" in Chapter 3 for more information.

In the first two scenarios, you will need to tell PopChart Server the source of the PopChart XML data that it should load into the graph using either the loadPCXML(String) PopChart Embedder method, or the @_LOADPCXML server command. For example, to load data from http://database.mycompany.com/sales?Month=May, you would use the following line of code in the PopChart Embedder.

myPopChart.loadPCXML("http://database.mycompany.com/sales?Month=May");

Or, you would add the following command to your server command string:

@_LOADPCXMLhttp://database.mycompany.com/sales?Month=May

If you want to test this out, there is a directory containing sample PopChart XML data at chart_root/examples/pcxml. There are several files containing data suitable for the bar graph that we have been building throughout this documentation. One of those is p_medals.xml. By adding this line to the code form Example 4.7, you could have PopChart Server load the data from this file the example PopChart image.

myPopChart.loadPCXML("examples/pcxml/p_medals.xml");


In the last scenario, you would use PopChart Server's addPCXML(String). This accepts a string containing PopChart XML. The following statement streams a small segment of PopChart XML data to PopChart Server.

myPopChart.addPCXML("<Chart> <GraphData Name='graph'> <Categories> <Category Name='Arrivals'/> <Category Name='Departures'/> <Category Name='Unused'/> <Category Name='Out of Commission'/> </Categories> <Series Name='Atlanta'> <Data Value='23.0'/> <Data Value='36.0'/> <Data Value='11.0'/> <Data Value='7.0'/> </Series><Series Name='Boston'> <Data Value='41.0'/> <Data Value='17.0'/><Data Value='25.0'/> <Data Value='9.0'/> </Series> </GraphData> </Chart>");

Note: Both of these methods will override any data in your appearance file. If you instead wish to append data to the appearance file (or to any data that has already been loaded using loadPCXML(String), you should place a Method="Append" attribute in your GraphData tag.

Using Data Specific Special Effects

If you intend to use data-specific special effects, like drill-down or PopUp text on key data items, you will probably want to combine the process of generating these effects with the process of translating your data to PopChart XML. For example, if you have a PopUp text box that needs to be displayed for the highest and lowest data values retrieved, the only way to do this without using PCScript is to include a PopUp attribute in the actual Data elements for highest and lowest data values (see "PopUp Text" in Chapter 7).