Embedding a PopChart image is a four step process. Although the exact code that you use will vary depending on the language or environment that you are programming in, you will still follow this same process.
Table 4.1 shows you where you can find the PopChart Embedder utility for each of the languages and environments mentioned above.
Language / Environment | File Name |
---|---|
Java | dev_tools/java_embedder/PopChartEmbedder.jar |
JavaBean | dev_tools/java_embedder/PopChartEmbedder.jar |
JavaScript | lib/fallback.js, lib/gifonly.js 1 |
COM | dev_tools/COM_embedder/PCEmbedder.dll |
.NET | dev_tools/dotnet_embedder/PCNetEmbedder.dll |
PHP | dev_tools/php_embedder/PopChartEmbedder.php |
C++ | dev_tools/cpp_embedder2 |
These are the templates for the JavaScript PopChart Embedder. The JavaScript PopChart Embedder, itself, should be loaded from PopChart Server (refer to "Importing the PopChart Embedder Library" in Chapter 4 in the PopChart Server User Guide). The C++ PopChart Embedder is currently of beta quality and is undocumented. It requires an Enterprise or Pro license. |
1. Include or import the PopChart Embedder class into your operating environment.
In Java, for example, you would do this by making sure that the PopChartEmbedder.jar file is in your classpath and including the statement:
import com.corda.pcis.PopChartEmbedder;
2. Instantiate a PopChart Embedder object.
In Java, for example, you would use this statement:
PopChartEmbedder myPopChart = new PopChartEmbedder();
3. Tell the PopChart Embedder object where PopChart Server is located.
You need to give PopChart Embedder two addressesyour external server address (the PopChart Server address that the client will use) and the internal comm port address (the PopChart Server that the PopChart Embedder will use). For example, in Java you would say:
myPopChart.externalServerAddress = "http://localhost:2001";
myPopChart.internalCommPortAddress = "http://localhost:2002";
4. Send data and formatting options to your PopChart image.
You can do this by manipulating the attributes (e.g. appearanceFile, imageType, width) of your PopChart Embedder object. For example, if you have named your PopChart Embedder object myPopChart, you can specify an appearance file for your PopChart image with this Java statement:
myPopChart.appearanceFile = "apfiles/bar.pcxml";
5. Request and output the embedding HTML.
The getEmbeddingHTML() will return a string with the HTML necessary to embed your PopChart image, which you can then write to your web page. For example, you could write the embedding HTML in a Java Server Page with this statement:
<%= myPopChart.getEmbeddingHTML() %>
You can learn more about how to set up and use the PopChart Embedder in different web environments in Chapter 4 and Chapter 5 of the PopChart Server User Guide.