Corda.com

 

PCScript

< BACK TO DATA SOURCES

PCScript (Presentation Control Script) is a scripting language for Corda Server. It provides you with an object-oriented interface for sending data and formatting options to Corda Server. You can do many things with PCScript, such as sending data to Corda Server, adding Drill-down effects and PopUp Text, or changing the text inside of a text box.

Top of Page

Consider the data table below.

  Arrivals Departures Unused Out of Commission
Atlanta 23 36 11 7
Boston 41 17 25 9

We could specify this as our graph's data with the following lines of PCScript:

graph.SetCategories(Arrivals; Departures; Unused; Out of Commission) graph.SetSeries(Atlanta; 23; 36; 11; 7) graph.SetSeries(Boston; 41; 17; 25; 9)

We could then send this PCScript to Corda Server by setting the pcScript attribute of the Corda Embedder, as shown below.

myImage.pcScript = "graph.SetCategories(Arrivals; Departures; Unused; Out of Commission)graph.SetSeries(Atlanta; 23; 36; 11; 7)graph.SetSeries(Boston; 41; 17; 25; 9)";

To see example code that specifies graph data with PCScript, view your web environment below:

Web Environment Application Code Examples
ASP PopChart Dynamic Graphs
ASP.NET PopChart Dynamic Graphs
ColdFusion PopChart Dynamic Graphs
JSP PopChart Dynamic Graphs
JSP Tag Library PopChart Dynamic Graphs
Java Servlet PopChart Dynamic Graphs
JavaScript PopChart Dynamic Graphs
Perl PopChart Dynamic Graphs
PHP PopChart Dynamic Graphs

Top of Page

Consider the data table below.

State Value
Texas 35000
California 42000
Wisconsin 9000
NY 53000
NJ 21500

We could specify this as our map's data with the following line of PCScript:

US.SetShapeValues(Texas,35000; California,42000; Wisconsin,9000; NY,53000; NJ,21500)

We could then send this PCScript to Corda Server by setting the pcScript attribute of the Corda Embedder, as shown below.

myImage.pcScript = "US.SetShapeValues(Texas,35000; California,42000; Wisconsin,9000; NY,53000; NJ,21500)";

To see example code that specifies map data with PCScript, click on your web environment below:

Web Environment Application Code Examples
ASP PopChart Dynamic Graphs
ASP.NET PopChart Dynamic Graphs
ColdFusion PopChart Dynamic Graphs
JSP PopChart Dynamic Graphs
JSP Tag Library PopChart Dynamic Graphs
Java Servlet PopChart Dynamic Graphs
JavaScript PopChart Dynamic Graphs
Perl PopChart Dynamic Graphs
PHP PopChart Dynamic Graphs

Top of Page

PCScript can also be used to specify dynamic effects, like PopUp text and drilldown. For example, suppose we wanted to do two other things to our graph�make the words "Look here" pop up over any item in the second row of data, and change the text in the title box to "Hello World." We could do this by adding the following lines to our PCScript:

graph.addPopUp(0,2,Look here) title.setText(Hello World)

To send these special effects to Corda Server, we simply append them to Corda Embedder's pcScript attribute, as shown below.

myImage.pcScript = "graph.SetCategories(Arrivals; Departures; Unused; Out of Commission)graph.SetSeries(Atlanta; 23; 36; 11; 7)graph.SetSeries(Boston; 41; 17; 25; 9)graph.addPopUp(0,2,Look here)title.setText(Hello World)";

Top of Page

Instead of having Corda Server import data directly from a database, most Corda Server developers write their own web applications that make SQL queries to their databases, process the results, and output the data in PCXML or PCScript.

This is by far the most powerful way of connecting to a database. For example, by letting you see your data before sending it to Corda Server, this methodology allows you to use if-then logic to analyze your data values and apply annotations or drill-down effects dynamically. Or you could perform statistical operations that would be difficult or impossible to set up in a database query.

The code segment below shows you how to do this for graph data in Java:

Class.forName("org.gjt.mm.mysql.Driver");
Connection connection = DriverManager.getConnection ("jdbc:mysql://mydata.com/population","","");
java.sql.Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("SELECT city,teamname,wins,losses FROM standings ORDER BY city");

myImage.pcScript += "graph.setCategories(Wins,Losses)";

while (rs.next()) {
myImage.pcScript += "graph.setSeries(" + rs.getString("city") + " " + rs.getString("teamname") + ";" + rs.getString("wins") + ";" + rs.getString("losses") + ")";
}

This next code segment shows you how to do this with map data.

Class.forName("org.gjt.mm.mysql.Driver");
Connection connection = DriverManager.getConnection ("jdbc:mysql://mydata.com/baseball","","");
java.sql.Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("SELECT State, Population FROM uspop");

myImage.pcScript += "US.setShapeValues(";

while (rs.next()) {
myImage.pcScript += rs.getString("State") + ", " + rs.getString("Population") + ";";
}

myImage.pcScript += ")";

To see complete example applications illustrating this strategy, view your web environment below:

Web Environment Application Code Examples
ASP PopChart Dynamic Graphs
ASP.NET PopChart Dynamic Graphs
ColdFusion PopChart Dynamic Graphs
JSP PopChart Dynamic Graphs
JSP Tag Library PopChart Dynamic Graphs
Java Servlet PopChart Dynamic Graphs
JavaScript PopChart Dynamic Graphs
Perl PopChart Dynamic Graphs
PHP PopChart Dynamic Graphs

Top of Page

For more information about PCScript, consult Chapter 4 of the PopChart and OptiMap Web Development manual. For a reference on all PCScript commands, see Chapter 3 of the PopChart and OptiMap Developer's Reference.