Creating a Report Element

Creates one of the following report elements:
  • Cell (only free cells, not cells in a table)
  • Section
  • Table (VTable, HTable, XTable, and Form)
  • Visualization (charts)
Remember You cannot create PageZone elements and table elements of type Cell.
Request

POST <webiURL>/documents/{documentId}/reports/{reportId}/elements?unit={unit}

Where:
  • {documentId} is the document identifier retrieved from the list of documents
  • {reportId} is the report identifier retrieved from the list of reports
  • {unit} is an optional parameter of type string that defines the unit of measurement used for all dimensional values such as size, padding, and position. Values are metric (default) , inch and centimeter.

Request type: application/xml or application/json

Request body: the valid definition of an element. See the Chart XML Grammar in case of a chart.

Elements are structured as a tree. There is a relationship of parent element and children. For instance, when you put a cell (ID = 5) into the body page zone (ID = 1), the parent ID of the cell is 1. This mechanism allows to add an element in the report structure with accuracy.

Some settings are common to all types of report elements, while some are only specific. These specific settings are located into content tags. The element is added and an ID attributed to the element.

Remember
  • You can create a report element with its expressions or create an empty report element, and add expressions in a second call using PUT <webiURL>/documents/{documentId}/reports/{reportId}/elements/{elementId}/axes/{axisId}/expressions.
  • You cannot change the type of chart after you create it.
Response

Response type: application/xml or application/json

The response is a message stating the success or failure of the request.

Example

Cell

POST <webiURL>/documents/127/reports/1/elements?unit=inch

In the request body, you define the cell dimensions, padding and contents.

<element type="Cell">
    <parentId>2</parentId>
    <size minimalWidth="2.23" minimalHeight="3.56" autofitWidth="false" autofitHeight="true"/>
    <padding left="0.069" right="0.069" top="0.069" bottom="0.069"/>
    <content>
        <expression>
            <formula type="Text" dataType="Numeric">=Sum([Sales revenue])</formula>
        </expression>
    </content>
</element>

Example

Section

POST <webiURL>/documents/127/reports/1/elements

In the request body, you define how duplicate row aggregation is managed and a formula.

<element type="Section">
    <parentId>2</parentId>
    <size minimalHeight="1000"/>  
    <padding bottom="1000"/>
    <position repeatOnEveryVerticalPage="true"/>  
    <style> 
        <background> 
            <color rgb="#0000ff"/> 
        </background> 
    </style>
    <content>
        <axes duplicateRowAggregation="true">
            <axis role="Row">
                <expressions>
                    <formula dataType="String">=[Year]</formula>
                </expressions>
            </axis>
        </axes>
    </content>
</element>

Example

Table

POST <webiURL>/documents/14695/reports/1/elements

Request body:

<element type="XTable">
    <parentId>2</parentId>
    <content>
        <axes>
            <axis role="Row">
                <expressions>
                    <formula dataType="String">=[Country]</formula>
                    <formula dataType="String">=[Year]</formula>
                </expressions>
            </axis>
            <axis role="Column">
                <expressions>
                    <formula dataType="String">=[Resort]</formula>
                    <formula dataType="String">=[Service]</formula>
                </expressions>
            </axis>
            <axis role="Body">
                 <expressions>
                    <formula dataType="Numeric">=[Number of guests]</formula>
                    <formula dataType="Numeric">=[Revenue]</formula>
                 </expressions>
            </axis>
        </axes>
    </content>
</element>

Example

Chart

POST <webiURL>/documents/13069/reports/6/elements?unit=centimeter

Request body:

<element type="Visualization">
    <parentId>2</parentId>
    <content>
        <chart type="HorizontalBar">
            <axes>
                <axis role="Color">
                    <expressions>
                        <formula dataType="String">=[Resort]</formula>
                        <formula dataType="String">=[Country]</formula>
                    </expressions>
                </axis>
                <axis role="Category">
                    <expressions>
                        <formula dataType="String">=[Year]</formula>
                    </expressions>
                </axis>
                <axis role="Value">
                    <expressions>
                        <formula dataType="Numeric">=[Revenue]</formula>
                    </expressions>
                </axis>
            </axes>
        </chart>
    </content>
</element>