Creating a Report Element

Usage
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 /documents/<documentID>/reports/<reportID>/elements?unit=<unit>

Where:
  • <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 Response Body Schema in the case of a chart.

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 /documents/<documentID>/reports/<reportID>/elements/<elementID>/axes/<axisID>/expressions.
  • You can change the type of report element after you create it by calling PUT /documents/<documentID>/reports/<reportID>/elements/<elementID>.
Response

Response type: application/xml or application/json

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

Example

Cell

POST /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 /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 /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 /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>