Jump to content
We've recently updated our Privacy Statement, available here ×
  • Visualize.js - API Notes and Samples - Report


    nesterone

    API Reference

    Report Properties

    [toc on_off::hide=0 box::collapsed=1]
    {
        "title": "Report Properties",
        "description": "A JSON Schema describing a Report Properties",
        "$schema": ",
        "type": "object",
        "properties": {
            "server": {
                "type": "string",
                "description": "URL of JRS instance."
            },
            "resource": {
                "type": "string",
                "description": "Report resource URI.",
                "pattern": "^/[^/~!#\\$%^|\\s`@&*()\\+={}\\[\\]:;\"'<>,?/\\|\\\\]+(/[^/~!#\\$%^|\\s`@&*()\\+={}\\[\\]:;\"'<>,?/\\|\\\\]+)*$"
            },
            "container": {
                "type": "string",
                "description": "CSS selector for container to render report to."
            },
            "params": {
                "$ref": "#/definitions/params"
            },
            "pages": {
                "type": ["string", "integer"],
                "description": "Range of report's pages or single report page",
                "pattern": "^\\d+(\\-\\d+)?$",
                "default": 1
            },
            "linkOptions": {
                "type": "object",
                "description": "Customization for report's links",
                "properties": {
                    "beforeRender": {
                        "$ref": "#/definitions/Function",
                        "description": "Allows to change any link representation before report would be rendered"
                    },
                    "events": {
                        "$ref": "#/definitions/eventsMapper",
                        "description": "Allow to add listener by specific events to links representations by link name"
                    }
                }
            },
            "defaultJiveUi" : {
                "type": "object",
                "description": "Control default JIVE UI in report",
                "properties": {
                    "enabled": {
                        "type": "boolean",
                        "default": false
                    },
                    "onError":{
                        "$ref": "#/definitions/Function",
                        "description": "Jive UI error listener"
                    }
                }
            },
            "isolateDom": {
               "type": "boolean",
               "description": "Isolate report's DOM from third-party page CSS. Can't be set while default JIVE UI is enabled",
               "default": false
            }
        },
        "required": ["server", "resource"],
        "definitions": {
            "params": {
                "type": "object",
                "description": "Report's parameters values",
                "additionalProperties": {
                    "type": "array"
                }
            },
            "ExportOptions": {
                "title": "Report export options",
                "type": "object",
                "properties": {
                    "outputFormat": {
                        "enum": [
                            "pdf",
                            "xlsx",
                            "xls",
                            "rtf",
                            "csv",
                            "xml",
                            "odt",
                            "ods",
                            "docx"
                        ]
                    },
                    "pages": {
                        "type": ["string", "integer"],
                        "description": "Exports all pages if this property was not specified. Range of report's pages or single report page",
                        "pattern": "^\\d+(\\-\\d+)?$"
                    },
                    "paginated": {
                        "type": "boolean",
                        "description": "Control 'pagination' feature. Only 'xls' and 'xlsx' support it",
                        "default": "false"
                    }
                },
                "required": ["outputFormat"]
            },
            "Function": {
                "type": "object",
                "description": "JavaScript Function"
            },
            "eventsMapper": {
                "type": "object",
                "description": "Map events by name to user defined handler .For example: 'click', 'focus', etc ",
                "additionalProperties": {
                    "$ref": "#/definitions/Function"
                }
            },
            "chartComponent": {
                "description": "JIVE chart component schema",
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Chart component identifier"
                    },
                    "componentType": {
                        "enum": ["chart"]
                    },
                    "chartType": {
                        "description": "Special chart's type",
                        "enum": [
                            "Bar", "Column", "Line", "Area", "Spline",
                            "AreaSpline", "StackedBar", "StackedColumn", "StackedLine", "StackedArea",
                            "StackedSpline", "StackedAreaSpline", "StackedPercentBar", "StackedPercentColumn", "StackedPercentLine",
                            "StackedPercentArea", "StackedPercentSpline", "StackedPercentAreaSpline", "Pie",
                            "DualLevelPie", "TimeSeriesLine", "TimeSeriesArea", "TimeSeriesSpline",
                            "TimeSeriesAreaSpline", "ColumnLine", "ColumnSpline", "StackedColumnLine",
                            "StackedColumnSpline", "MultiAxisLine", "MultiAxisSpline", "MultiAxisColumn",
                            "Scatter", "Bubble", "SpiderColumn", "SpiderLine", "SpiderArea"
                        ]
                    }
                },
                "required": ["id"]
            }
        }
    }
    

    Report Module

    define(function () {
        /**
         * @param {Object} properties - report properties
         * @constructor
         */
        function Report(properties){}
        /**
         * Setters and Getters are functions around
         * schema for bi component at ./schema/ReportSchema.json
         * Each setter returns pointer to 'this' to provide chainable API
         */
     
        //Special  getters
     
        /**
         * Get any result after invoking run action, 'null' by default
         * @returns any data which supported by this bi component
         */
        Report.prototype.data = function(){};
    
        // Special setters
     
        /**
         * Attaches event handlers to some specific events.
         * New events overwrite old ones.
         * @param {Object} events - object containing event names as keys and event handlers as values
         * @return {Report} report - current Report instance (allows chaining)
         */
        Report.prototype.events = function(events){};
    
        //Actions
        
        /**
         * Perform main action for bi component
         * Callbacks will be attached to  deferred object.
         *
         * @param {Function} callback - optional, invoked in case of successful run
         * @param {Function} errorback - optional, invoked in case of failed run
         * @param {Function} always - optional, invoked always
         * @return {Deferred} dfd
         */
        Report.prototype.run = function(callback, errorback, always){};
     
        /**
         * Render report to container, previously specified in property.
         * Clean up all content of container before adding Report's content
         * @param {Function} callback - optional, invoked in case successful export
         * @param {Function} errorback - optional, invoked in case of failed export
         * @param {Function} always - optional, optional, invoked always
         * @return {Deferred} dfd
         */
        Report.prototype.render = function(callback, errorback, always){};
     
        /**
         * Cancel report execution
         * @param {Function} callback - optional, invoked in case of successful cancel
         * @param {Function} errorback - optional, invoked in case of failed cancel
         * @param {Function} always - optional, invoked optional, invoked always
         * @return {Deferred} dfd
         */
        Report.prototype.cancel = function(callback, errorback, always){};
    
    
        /**
         * Update report's component
         * @param {Object} component - jive component to update, should have id field
         * @param {Function} callback - optional, invoked in case of successful update
         * @param {Function} errorback - optional, invoked in case of failed update
         * @param {Function} always - optional, invoked optional, invoked always
         * @return {Deferred} dfd
         */
         Report.prototype.updateComponent = function(component, callback, errorback, always){};
    
        /**
         * Update report's component
         * @param {String} id - jive component id
         * @param {Object} properties - jive component's properties to update
         * @param {Function} callback - optional, invoked in case of successful update
         * @param {Function} errorback - optional, invoked in case of failed update
         * @param {Function} always - optional, invoked optional, invoked always
         * @return{Deferred} dfd
         */
         Report.prototype.updateComponent = function(id, properties, callback, errorback, always){};
    
         /**
         * Undo previous JIVE component update
         * @param {Function} callback - optional, invoked in case of successful update
         * @param {Function} errorback - optional, invoked in case of failed update
         * @param {Function} always - optional, invoked optional, invoked always
         * @return{Deferred} dfd
         */
         Report.prototype.undo = function(callback, errorback, always){};
    
         /**
         * Reset report to initial state
         * @param {Function} callback - optional, invoked in case of successful update
         * @param {Function} errorback - optional, invoked in case of failed update
         * @param {Function} always - optional, invoked optional, invoked always
         * @return{Deferred} dfd
         */
         Report.prototype.undoAll = function(callback, errorback, always){};
    
         /**
         * Redo next JIVE component update
         * @param {Function} callback - optional, invoked in case of successful update
         * @param {Function} errorback - optional, invoked in case of failed update
         * @param {Function} always - optional, invoked optional, invoked always
         * @return{Deferred} dfd
         */
         Report.prototype.redo = function(callback, errorback, always){};
    
        /**
         * Export report to specific format, execute only after report run action is finished
         * @param {ExportOptions} exportOptions - export options
         * @param {Function} callback - optional, invoked with link object
         * @param {Function} errorback - optional, invoked in case of failed export
         * @param {Function} always - optional, invoked optional, invoked always
         * @return{Deferred} dfd
         */
         Report.prototype.export = function(exportOptions, callback, errorback, always){};
     
     
        //TODO: discuss in compassion with 'cancel' action
        /**
         * Cancel all execution, destroy report representation if any, leave only
         * properties
         * @param {Function} callback - optional, invoked in case of successful cleanup
         * @param {Function} errorback - optional, invoked in case of failed cleanup
         * @param {Function} always - optional, invoked optional, invoked always
         * @return {Deferred} dfd
         */
        Report.prototype.destroy = function(callback, errorback, always){};
     
        return Report;
    });
    

    Report Data

    {
        "title": "Report Data",
        "description": "A JSON Schema describing a Report Data",
        "$schema": ",
        "type": "object",
        "properties": {
            "totalPages": {
                "type": "number",
                "description": "Report's page total count"
            },
            "links": {
                "type": "array",
                "description": "Links extracted from markup, so their quantity depends from pages you have requested",
                "items": {
                    "$ref": "#/definitions/jrLink"
                }
            },
            "components": {
                "type": "array",
                "description": "Components in report, their quantity depends from pages you have requested",
                "items": {
                    "type": "object",
                    "description": "JIVE components data"
                }
            }
        },
        "definitions": {
            "jrLink": {
                "title": "JR Hyperlink",
                "type": "object",
                "properties": {
                    "type": {
                        "oneOf": [
                            {
                                "$ref": "#/definitions/linkTypeReference"
                            },
                            {
                                "$ref": "#/definitions/linkTypeReportExecution"
                            }
                        ]
                    },
                    "tooltip": {
                        "type": "string",
                        "description": "Hyperlink tooltip"
                    },
                    "href": {
                        "type": "string",
                        "description": "Hyperlink reference"
                    },
                    "parameters": {
                        "type": "object"
                    }
                },
                "required": ["type"],
                "definitions": {
                    "linkTypeReference": {
                        "enum": ["Reference"],
                        "description": "The  hyperlink points to an external resource."
                    },
                    "linkTypeReportExecution": {
                        "enum": ["ReportExecution"],
                        "description": "The hyperlink points to JR report"
                    }
                }
            }
        }
    }
    

    JIVE

    Components

    NOTE: It's a ES5 compliant array with next additional methods

    NOTE: Open highcharts.xsd to discover all available chart types

    Table
    Column

    Expand source

    {
        "type": "object",
        "description": "JIVE column component schema",
        "oneOf": [
            { "$ref": "#/definitions/numericColumn" },
            { "$ref": "#/definitions/datetimeColumn" },
            { "$ref": "#/definitions/booleanColumn" },
            { "$ref": "#/definitions/stringColumn" },
            { "$ref": "#/definitions/timeColumn" }
        ],
        "definitions": {
            "numericColumn": {
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Column component identifier"
                    },
                    "componentType": {
                        "enum": ["tableColumn"]
                    },
                    "dataType": {
                        "enum": ["numeric"]
                    },
                    "label": {
                        "type": "string"
                    },
                    "sort": {
                        "$ref": "#/definitions/sort"
                    },
                    "filter": {
                        "type": "object",
                        "oneOf": [
                            {
                                "$ref": "#/definitions/singleNumericFilter"
                            },
                            {
                                "$ref": "#/definitions/rangeNumericFilter"
                            },
                            {
                                "$ref": "#/definitions/resetFilter"
                            }
                        ]
                    },
                    "headingFormat": {
                        "$ref": "#/definitions/headingFormat"
                    },
                    "detailsRowFormat": {
                        "type": "object",
                        "properties": {
                            "backgroundColor": {
                                "type": "string",
                                "pattern": "^(([a-fA-F0-9]{6})|(transparent))$"
                            },
                            "align": {
                                "enum": ["right", "left", "center"]
                            },
                            "font": {
                                "$ref": "#/definitions/font"
                            },
                            "pattern": {
                                "type": "object",
                                "properties": {
                                    "negativeFormat": {
                                        "enum": [
                                            "-###0",
                                            "###0-",
                                            "(###0)",
                                            "(-###0)",
                                            "(###0-)"
                                        ],
                                        "default": "-###0"
                                    },
                                    "grouping": {
                                        "type": "boolean",
                                        "default": false
                                    },
                                    "percentage": {
                                        "type": "boolean",
                                        "default": false
                                    },
                                    "currency": {
                                        "enum": [
                                            null,
                                            "USD",
                                            "EUR",
                                            "GBP",
                                            "YEN",
                                            "LOCALE_SPECIFIC"
                                        ]
                                    },
                                    "precision": {
                                        "type": "integer",
                                        "minimum": 0,
                                        "default": 0
                                    }
                                }
                            }
                        }
                    },
                    "conditions": {
                        "type": "array",
                        "items": {
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/singleNumericCondition"
                                },
                                {
                                    "$ref": "#/definitions/rangeNumericCondition"
                                }
                            ]
                        }
                    }
                },
                "required": ["id"]
            },
            "booleanColumn": {
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Column component identifier"
                    },
                    "componentType": {
                        "enum": ["tableColumn"]
                    },
                    "dataType": {
                        "enum": ["boolean"]
                    },
                    "label": {
                        "type": "string"
                    },
                    "sort": {
                        "$ref": "#/definitions/sort"
                    },
                    "filter": {
                        "type": "object",
                        "oneOf": [
                            {
                                "$ref": "#/definitions/booleanFilter"
                            },
                            {
                                "$ref": "#/definitions/resetFilter"
                            }
                        ]
                    },
                    "headingFormat": {
                        "$ref": "#/definitions/headingFormat"
                    },
                    "detailsRowFormat": {
                        "type": "object",
                        "properties": {
                            "backgroundColor": {
                                "type": "string",
                                "pattern": "^(([a-fA-F0-9]{6})|(transparent))$"
                            },
                            "align": {
                                "enum": ["right", "left", "center"]
                            },
                            "font": {
                                "$ref": "#/definitions/font"
                            }
                        }
                    },
                    "conditions": {
                        "type": "array",
                        "items": {
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/booleanCondition"
                                }
                            ]
                        }
                    }
                },
                "required": ["id"]
            },
            "datetimeColumn": {
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Column component identifier"
                    },
                    "componentType": {
                        "enum": ["tableColumn"]
                    },
                    "dataType": {
                        "enum": ["datetime"]
                    },
                    "label": {
                        "type": "string"
                    },
                    "sort": {
                        "$ref": "#/definitions/sort"
                    },
                    "filter": {
                        "type": "object",
                        "oneOf": [
                            {
                                "$ref": "#/definitions/singleDatetimeFilter"
                            },
                            {
                                "$ref": "#/definitions/rangeDatetimeFilter"
                            },
                            {
                                "$ref": "#/definitions/resetFilter"
                            }
                        ]
                    },
                    "headingFormat": {
                        "$ref": "#/definitions/headingFormat"
                    },
                    "detailsRowFormat": {
                        "type": "object",
                        "properties": {
                            "backgroundColor": {
                                "type": "string",
                                "pattern": "^(([a-fA-F0-9]{6})|(transparent))$"
                            },
                            "align": {
                                "enum": ["right", "left", "center"]
                            },
                            "font": {
                                "$ref": "#/definitions/font"
                            },
                            "pattern": {
                                "enum": [
                                    "dd/MM/yyyy",
                                    "MM/dd/yyyy",
                                    "yyyy/MM/dd",
                                    "EEEEE dd MMMMM yyyy",
                                    "MMMMM dd. yyyy",
                                    "dd/MM",
                                    "dd/MM/yy",
                                    "dd-MMM",
                                    "dd-MMM-yy",
                                    "MMM-yy",
                                    "MMMMM-yy",
                                    "dd/MM/yyyy h.mm a",
                                    "dd/MM/yyyy HH.mm.ss",
                                    "MMM",
                                    "d/M/yyyy",
                                    "dd-MMM-yyyy",
                                    "yyyy.MM.dd G 'at' HH:mm:ss z",
                                    "EEE. MMM d. ''yy",
                                    "yyyy.MMMMM.dd GGG hh:mm aaa",
                                    "EEE. d MMM yyyy HH:mm:ss Z",
                                    "yyMMddHHmmssZ"
                                ]
                            }
                        }
                    },
                    "conditions": {
                        "type": "array",
                        "items": {
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/singleDatetimeCondition"
                                },
                                {
                                    "$ref": "#/definitions/rangeDatetimeCondition"
                                }
                            ]
                        }
                    }
                },
                "required": ["id"]
            },
            "stringColumn": {
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Column component identifier"
                    },
                    "componentType": {
                        "enum": ["tableColumn"]
                    },
                    "dataType": {
                        "enum": ["string"]
                    },
                    "label": {
                        "type": "string"
                    },
                    "sort": {
                        "$ref": "#/definitions/sort"
                    },
                    "filter": {
                        "type": "object",
                        "oneOf": [
                            {
                                "$ref": "#/definitions/stringFilter"
                            },
                            {
                                "$ref": "#/definitions/resetFilter"
                            }
                        ]
                    },
                    "headingFormat": {
                        "$ref": "#/definitions/headingFormat"
                    },
                    "detailsRowFormat": {
                        "type": "object",
                        "properties": {
                            "backgroundColor": {
                                "type": "string",
                                "pattern": "^(([a-fA-F0-9]{6})|(transparent))$"
                            },
                            "align": {
                                "enum": ["right", "left", "center"]
                            },
                            "font": {
                                "$ref": "#/definitions/font"
                            }
                        }
                    },
                    "conditions": {
                        "type": "array",
                        "items": {
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/stringCondition"
                                }
                            ]
                        }
                    }
                },
                "required": ["id"]
            },
            "timeColumn": {
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "Column component identifier"
                    },
                    "componentType": {
                        "enum": ["tableColumn"]
                    },
                    "dataType": {
                        "enum": ["time"]
                    },
                    "label": {
                        "type": "string"
                    },
                    "sort": {
                        "$ref": "#/definitions/sort"
                    },
                    "filter": {
                        "type": "object",
                        "oneOf": [
                            {
                                "$ref": "#/definitions/singleTimeFilter"
                            },
                            {
                                "$ref": "#/definitions/rangeTimeFilter"
                            },
                            {
                                "$ref": "#/definitions/resetFilter"
                            }
                        ]
                    },
                    "headingFormat": {
                        "$ref": "#/definitions/headingFormat"
                    },
                    "detailsRowFormat": {
                        "type": "object",
                        "properties": {
                            "backgroundColor": {
                                "type": "string",
                                "pattern": "^(([a-fA-F0-9]{6})|(transparent))$"
                            },
                            "align": {
                                "enum": ["right", "left", "center"]
                            },
                            "font": {
                                "$ref": "#/definitions/font"
                            },
                            "pattern": {
                                "enum": [
                                    "hh:mm aaa",
                                    "hh:mm:ss aaa",
                                    "HH:mm",
                                    "HH:mm:ss"
                                ]
                            }
                        }
                    },
                    "conditions": {
                        "type": "array",
                        "items": {
                            "oneOf": [
                                {
                                    "$ref": "#/definitions/singleTimeCondition"
                                },
                                {
                                    "$ref": "#/definitions/rangeTimeCondition"
                                }
                            ]
                        }
                    }
                },
                "required": ["id"]
            },
            "sort": {
                "type": "object",
                "properties": {
                    "order": {
                        "enum": ["asc", "desc"]
                    }
                }
            },
            "singleNumericFilter": {
                "properties": {
                    "operator": {
                        "enum": [
                            "equal",
                            "not_equal",
                            "greater",
                            "greater_or_equal",
                            "less",
                            "less_or_equal"
                        ]
                    },
                    "value": {
                        "type": "number"
                    }
                },
                "required": ["operator", "value"]
            },
            "singleNumericCondition": {
                "allOf": [
                    {
                        "$ref": "#/definitions/singleNumericFilter"
                    },
                    {
                        "$ref": "#/definitions/conditionFormat"
                    }
                ]
            },
            "rangeNumericFilter": {
                "properties": {
                    "operator": {
                        "enum": [
                            "between",
                            "not_between"
                        ]
                    },
                    "value": {
                        "type": "array",
                        "items": {
                            "type": "number"
                        },
                        "minItems": 2,
                        "maxItems": 2
                    }
                },
                "required": ["operator", "value"]
            },
            "rangeNumericCondition": {
                "allOf": [
                    {
                        "$ref": "#/definitions/rangeNumericFilter"
                    },
                    {
                        "$ref": "#/definitions/conditionFormat"
                    }
                ]
            },
            "booleanFilter": {
                "properties": {
                    "operator": {
                        "enum": [
                            "equal",
                            "not_equal"
                        ]
                    },
                    "value": {
                        "type": "boolean"
                    }
                },
                "required": ["operator", "value"]
            },
            "booleanCondition": {
                "allOf": [
                    {
                        "$ref": "#/definitions/booleanFilter"
                    },
                    {
                        "$ref": "#/definitions/conditionFormat"
                    }
                ]
            },
            "stringFilter": {
                "properties": {
                    "operator": {
                        "enum": [
                            "equal",
                            "not_equal",
                            "contain",
                            "not_contain",
                            "start_with",
                            "not_start_with",
                            "end_with",
                            "not_end_with"
                        ]
                    },
                    "value": {
                        "type": "string"
                    }
                },
                "required": ["operator", "value"]
            },
            "stringCondition": {
                "allOf": [
                    {
                        "$ref": "#/definitions/stringFilter"
                    },
                    {
                        "$ref": "#/definitions/conditionFormat"
                    }
                ]
            },
            "singleDatetimeFilter": {
                "properties": {
                    "operator": {
                        "enum": [
                            "equal",
                            "not_equal",
                            "on_or_before",
                            "before",
                            "on_or_after",
                            "after"
                        ]
                    },
                    "value": {
                        "type": "string",
                        "format": "date-time"
                    }
                },
                "required": ["operator", "value"]
            },
            "singleDatetimeCondition": {
                "allOf": [
                    {
                        "$ref": "#/definitions/singleDatetimeFilter"
                    },
                    {
                        "$ref": "#/definitions/conditionFormat"
                    }
                ]
            },
            "rangeDatetimeFilter": {
                "properties": {
                    "operator": {
                        "enum": [
                            "between",
                            "not_between"
                        ]
                    },
                    "value": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "format": "date-time"
                        },
                        "minItems": 2,
                        "maxItems": 2
                    }
                },
                "required": ["operator", "value"]
            },
            "rangeDatetimeCondition": {
                "allOf": [
                    {
                        "$ref": "#/definitions/rangeDatetimeFilter"
                    },
                    {
                        "$ref": "#/definitions/conditionFormat"
                    }
                ]
            },
            "singleTimeFilter": {
                "properties": {
                    "operator": {
                        "enum": [
                            "equal",
                            "not_equal",
                            "on_or_before",
                            "before",
                            "on_or_after",
                            "after"
                        ]
                    },
                    "value": {
                        "type": "string",
                        "format": "time"
                    }
                },
                "required": ["operator", "value"]
            },
            "singleTimeCondition": {
                "allOf": [
                    {
                        "$ref": "#/definitions/singleTimeFilter"
                    },
                    {
                        "$ref": "#/definitions/conditionFormat"
                    }
                ]
            },
            "rangeTimeFilter": {
                "properties": {
                    "operator": {
                        "enum": [
                            "between",
                            "not_between"
                        ]
                    },
                    "value": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "format": "time"
                        },
                        "minItems": 2,
                        "maxItems": 2
                    }
                },
                "required": ["operator", "value"]
            },
            "rangeTimeCondition": {
                "allOf": [
                    {
                        "$ref": "#/definitions/rangeTimeFilter"
                    },
                    {
                        "$ref": "#/definitions/conditionFormat"
                    }
                ]
            },
            "resetFilter": {
                "properties": {},
                "additionalProperties": false
            },
            "simpleFont": {
                "type": "object",
                "properties": {
                    "bold": {
                        "type": "boolean",
                        "default": false
                    },
                    "italic": {
                        "type": "boolean",
                        "default": false
                    },
                    "underline": {
                        "type": "boolean",
                        "default": false
                    },
                    "color": {
                        "type": "string",
                        "pattern": "^[a-fA-F0-9]{6}$",
                        "default": "000000"
                    }
                }
            },
            "font": {
                "allOf": [
                    {
                        "$ref": "#/definitions/simpleFont"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string"
                            },
                            "size": {
                                "type": "number",
                                "minimum": 1,
                                "default": 11
                            }
                        }
                    }
                ]
            },
            "headingFormat": {
                "type": "object",
                "properties": {
                    "backgroundColor": {
                        "type": "string",
                        "pattern": "^(([a-fA-F0-9]{6})|(transparent))$"
                    },
                    "align": {
                        "enum": ["right", "left", "center"]
                    },
                    "font": {
                        "$ref": "#/definitions/font"
                    }
                },
                "additionalProperties": false
            },
            "conditionFormat": {
                "type": "object",
                "properties": {
                    "font": {
                        "$ref": "#/definitions/simpleFont"
                    },
                    "backgroundColor": {
                        "type": ["string", "null"],
                        "pattern": "^(([a-fA-F0-9]{6})|(transparent))$"
                    }
                }
            }
        }
    }
    
    Crosstab
    Row
     {
        "type": "object",
        "description": "JIVE crosstab row group component schema",
        "properties": {
            "id": {
                "type": "string",
                "description": "Crosstab component identifier"
            },
            "componentType": {
                "enum": ["crosstabRowGroup"]
            },
            "sort": {
                "type": "object",
                "properties": {
                    "order": {
                        "enum": ["asc", "desc"]
                    }
                }
            },
            "groupIndex" : {
                "type": "number",
                "description": "Absolute offset of the row group in crosstab",
                "minimum": 0
            }
        },
        "required": ["id"]
    }
    
    Column
     {
        "type": "object",
        "description": "JIVE crosstab data column component schema",
        "properties": {
            "id": {
                "type": "string",
                "description": "Crosstab component identifier"
            },
            "componentType": {
                "enum": ["crosstabDataColumn"]
            },
            "sort": {
                "type": "object",
                "properties": {
                    "order": {
                        "enum": ["asc", "desc"]
                    }
                }
            },
            "columnValues": {
                "type": "array",
                "descripton": "An array of labels of the crosstab data column"
            },
            "sortMeasureIndex" : {
                "type": "number",
                "description": "Absolute offset the column in crosstab",
                "minimum": 0
            }
        },
        "required": ["id"]
    }
    

    Workflows

    Create and run report

    var report = v.report({
        server: ",
        resource: "/public/Sample",
        container: "#container"
    });
    

    Change report parameters

    //update report but with new parameters
    report
        .params({ "Country": ["USA"] })
        .run();
    //later in code
    console.log(report.params()); //  {"Country": ["USA"] }
    

    Cancel report execution

    report
        .cancel()
        .done(function(){
            alert("Report Canceled");
        })
        .fail(function(){
            alert("Report Failed");
        });
    

    Pagination

    Change report page

    report
        .pages(5)
        .run(); //will re-render report with '5' page in container
    
    report
        .pages("2") // string is also possible
        .run();
    
    report
        .pages("4-6") // string range of numbers is also possible
        .run();
    

    Get pages total

    report
        .run()
        .then(function(data){
            console.log(data.totalPages); // 10 for example, but can be undefined
        });
    

    Events

    changeTotalPages

    Happens when number of report's pages is changed - when report execution is finished or after JIVE action (e.g. change of column font size).

    Total pages number is passed as an argument to event handler.

    report.events({
        changeTotalPages: function(totalPages) {
            console.log(totalPages);
        }
    });
    

    canUndo / canRedo

    Happens after JIVE actions (both through UI and API).

    Boolean value is passed as an argument to event handler meaning if undo or redo action is possible

    report.events({
        canUndo: function(undoPossible) {
            console.log(undoPossible);
        },
        canRedo: function(redoPossible) {
            console.log(redoPossible);
        }
    });
    

    pageFinal

    Happens after final HTML page markup is loaded from the server.

    HTML markup is passed as an argument to even handler. This event happen before markup rendering.

    report.events({
        pageFinal: function(html) {
            // do something with final HTML page
        }
    });
    

    reportCompleted

    Happens after report is completed. When report becomes in "failed" or "cancelled" status it happens just after report status is updated, while when report is in "ready" status, event happens when HTML export and JIVE components are re-fetched from server and applied to report.

    Report status ("ready", "failed" or "cancelled") and optional error object are passed as arguments to event handler.

    report.events({
        reportCompleted: function(status, error) {
            if (status === "ready") {
                // do something
            } else if (status === "failed") {
                error && alert(error);
            }
        }
    });
    

    beforeRender

    Happens before report is rendered. 

    report.events({
        beforeRender: function(html) {
                // do something with HTML before it is rendered
        }
    });
    

    Export

    NOTE: No exports to HTML format through this API

    NOTE: Execute export only after report run action is finished

    NOTE: Open applicationContext-remote-services.xml, search for remoteExportersMap to discover all available export format

    Export all report to PDF

    report.run(exportToPdf);
    function exportToPdf() {
        report
            .export({
                outputFormat: "pdf"
            })
            .done(function (link) {
                window.open(link.href); //open new window to download report
            })
            .fail(function (err) {
                alert(err.message);
            });
    }
    

    Export to 10 pages to paginated excel 

    report.run(exportToPaginatedExcel);
    function exportToPaginatedExcel() {
        report
            .export({
                outputFormat: "xls",
                pages: "1-10",
                paginated: true
            })
            .done(function(link){
                window.open(link.href); //open new window to download report
            })
            .fail(function(err){
                alert(err.message);
            });
    }
    

    Control report's DOM isolation

    NOTE: Prevent influence of third-party CSS rules on report

    var isolatedReport = v.report({
        resource: "/public/Sample",
        container: "#reportContainer",
        //very useful when user want's to export to PDF and see the same report on the page
        isolateDom : true
    });
    
    ///later in code
    isolatedReport
        .export({format: "pdf"})
        .done(function(link){
            window.href = link.href;
        });
    

    JIVE API

    Enable default JIVE UI

    var report = v.report({
        resource: "/public/SampleReport",
        defaultJiveUi : {
            enabled: true
        }
    });
    

    Components

    Each jive component should have static id which doesn't change from execution to execution.

    //data available after running report
    var components = report.data().components;
    

    Work with special component

    It's better to use 'name' property instead of 'id' because 'name' constant identifier and doesn't change between report execution.

    Component name could be customized through JRXML

    Find component by name

    //assume we have report with component 'sales'
    var salesColumn = report
                        .data()
                        .components
                        .filter(function(c){ return c.name === "sales"})
                        .pop();
    

    If you need just to update component with new values

    Find component by name

    //assume we have report with component 'sales'
    report.updateComponent("sales", {
        sort : {
            order : "asc"
        }
    });
    //or
               
    report.updateComponent({
        name: "sales",
        sort : {
            order : "asc"
        }
    });
    

    Look in limitations for more info about restrictions

    Chart

    Change chart type with available chart component
    //assume we already have found chart component
    mySalesChart.chartType = "Bar";
    
    report
        .updateComponent(mySalesChart)
        .done(function(){
            alert("Chart Type Changed!");
        })
        .fail(function(err){
            alert(err.message);
        });
    
    Change chart type
    report
        .updateComponent("my_sales", {
              chartType: "Bar"
        })
        .done(function(){
            alert("Chart Type Changed!");
        })
        .fail(function(err){
            alert(err.message);
        });
    

    Table

    Column

    Sort special column in report
    // set descending sorting for column 'dr_customers_name'
    report
        .updateComponent("dr_customers_name", {
            sort : {
                order: "desc"
            }
        })
        .done(function(){
            alert("Sorting applied!");
        })
        .fail(function(err){
            alert(err.message);
        });
    
    // reset sorting for column 'dr_customers_name'
    report
        .updateComponent("dr_customers_name", {
            sort : {}
        });
    
    Filter special column
    // set filtering for column 'sales'
    report
        .updateComponent("sales", {
            filter : {
                operator: "between",
                value: [1234.01, 5678.99]
            }
        })
        .done(function(){
            alert("Filtering applied!");
        })
        .fail(function(err){
            alert(err.message);
        });
    // reset filtering for column 'sales'
    report
        .updateComponent("sales", {
            filter : {}
        });
    
    Change heading format of a column
    report
        .updateComponent("sales", {
            headingFormat: {
                    align: "right",
                    backgroundColor: "DDEE99",
                    font: {
                        size: 15,
                        color: "AA32DD",
                        underline: true,
                        bold: true,
                        italic: true,
                        name: "Monospaced"
                    }
                }
        })
        .done(function(){
            alert("Formatting applied!");
        })
        .fail(function(err){
            alert(err.message);
        });
    
    Change format of details row of a column
    report
        .updateComponent("sales", {
            detailsRowFormat: {
                    align: "right",
                    backgroundColor: "DDEE99",
                    font: {
                        size: 15,
                        color: "AA32DD",
                        underline: true,
                        bold: true,
                        italic: true,
                        name: "Monospaced"
                    },
                    pattern: {
                        negativeFormat: "(-###0)",
                        precision: 4,
                        grouping: true,
                        percentage: true,
                        currency: "USD"
                    }
                }
        })
        .done(function(){
            alert("Formatting applied!");
        })
        .fail(function(err){
            alert(err.message);
        });
    
    Change column label
    report
        .updateComponent("sales", {
            label: "My Sales"
        })
        .done(function(){
            alert("Label changed!");
        })
        .fail(function(err){
            alert(err.message);
        });
    
    Change conditional formatting of a column
    report
        .updateComponent("sales", {
            conditions: [
                        {
                            operator: "greater",
                            value: 10,
                            backgroundColor: null,
                            font: {
                                color: "FF0000",
                                bold: true,
                                underline: true,
                                italic: true
                            }
                        },
                        {
                            operator: "between",
                            value: [5, 9],
                            backgroundColor: "00FF00",
                            font: {
                                color: "0000FF"
                            }
                        }
                    ]
        })
        .done(function(){
            alert("Formatting applied!");
        })
        .fail(function(err){
            alert(err.message);
        });
    

    Crosstab

    Change sorting of first sub column of second column
    //assume that we have a crosstab with id like 'my_crosstab'
    report
        .updateComponent("my_crosstab/dataColumns/1/0",   {
                sort: {
                    order: "asc"
                })
        .done(function(){
            alert("Crostab's sorted!");
        })
        .fail(function(err){
            alert(err.message);
        });
    
    //reset sorting
    
    report
        .updateComponent("my_crosstab/dataColumns/1/0", {
            sort : {}
        });
    
    Change row group sorting
    //assume that we have a crosstab with id like 'my_crosstab'
    report
        .updateComponent("my_crosstab/rowGroups/1",   {
                sort: {
                    order: "asc"
                }
        )
        .done(function(){
            alert("Crostab's sorted!");
        })
        .fail(function(err){
            alert(err.message);
        });
    
    //reset sorting
    report
        .updateComponent("my_crosstab/rowGroups/1", {
            sort : {}
        });
    

    Undo / Undo All / Redo JIVE changes

    $("#btn_redo").click(function(){
        report
            .redo()
            .fail(function(e){ alert("Cannot redo: " + e); });
    });
    $("#btn_undo").click(function(){
        report
            .undo()
            .fail(function(e){ alert("Cannot undo: " + e); });
    });
    
    $("#btn_undoAll").click(function(){
        report
            .undoAll()
            .fail(function(e){ alert("Cannot undo all: " + e); });
    });
    

    Hyperlinks

    For more information about it's implementation look in Hyperlinks from JR

    Add click handler to all links in report

    var report = new Report({
        resource: "/public/Sample",
        linkOptions: {
            events: {
                "click"  : function(evt, link){
                    console.log(evt.target); // prints dom elem which represents link in report
                    console.log(link); // print link's data look in report data schema
                }
            }
        }
    });
    

    Change elements appearance, highlight special element

     var report = new Report({
        resource: "/public/Sample",
        linkOptions: {
            beforeRender: function (linkToElemPairs) {
                    linkToElemPairs.forEach(function (pair) {
                        var el = pair.element;
                        el.style.backgroundColor = "red";
                    });
                }
        }
    });
    

    Build links from data

    function renderLink(link){
        if (link.title){
            var template = "<a href='{href}'>{title}</a>";
            $("#links_panel")
                    .append(template
                                .replace("{href}", link.href)
                                .replace("{title}", link.title)
                    );
        }
    }
    report.run(function(data){
        data.links.forEach(renderLink)
    });
    

    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...