Charts > Example: Variable number of items from a PageIN Event

Example: Variable number of items from a PageIN Event
In this example, you create a chart for different types of articles showing the name of the article (Label), and the number of articles sold (Value) during a month.
The article items are defined in a block in the PageIN tool, which means you cannot tell how many items to include in the chart. You must therefore create a script that generates an array for the values, and another array for the labels.
Assigning variables in the Event
This example uses a PageIN Event containing the block Articles. This block has one field for the article name, and one field for the number of articles sold.
Assign a variable to the name field ($label_article), and another variable to the amount field ($value_article).
Creating arrays in the Process
Add the following script to the Articles block in the PageOUT Process:
$arr_label_article[$i]=$label_article;
$arr_value_article[$i]=$value_article;
$i++;
The script generates one array for the values, and one array for the labels.
Making sure that the arrays contain all required values
Before the chart is generated, you must make sure that the arrays contain all required values. How you do this will depend on what data you want to include in the chart. In this example, you first insert the chart in a free block inserted directly on the PageOUT sheet. You then call the free block after the frame that includes the Articles block.
Adding variables to the Process
Add a new item in the Chart Properties dialog box. Select the Array option, and enter the Value ($arr_value_article) and Label ($arr_label_article) variables.
OpenText StreamServe 5.6 Updated: 2013-03-01