Jump to content
Changes to the Jaspersoft community edition download ×
  • Adding Custom Visualization Components to TIBCO Jaspersoft® Studio 6.2


    elizam
    • Version: v6.2 Product: Jaspersoft® Studio

    In version 6.2, the Custom Visualization Component is a community-only feature, it is not yet supported in the professional software.

    In Jaspersoft Studio 6.2, we added a JSON descriptor format that allows you to register your custom visualization components (CVCs) with Jaspersoft Studio and create a specialised UI for the component. Two pre-installed sample CVCs, Figures and Radial Progress, implement the descriptor format.

    For more information, see the following:

    http://community.jaspersoft.com/wiki/new-features-jaspersoft-62

    Custom Visualization Component Descriptor

    The JSON descriptor for a CVC is composed of a JSON file and additional resources:

    • JSON file - Describes the CVC resource, references required assets (such as a JavaScript file), and  optionally defines a UI.
    • Preview image (optional) - Image used for the component in Jaspersoft Studio. This image appears in the component chooser dialog when a user creates a CVC and is also used as the image for a your component in Design view. 
    • Component-specific assets, such as a JavaScript file and a css file. All resources are referenced inside the JSON descriptor.

    JSON File Format

    To set up a JSON file for a CVC, use the following members:

    Property NameDefaultMandatoryDescription
    label-MandatoryName of the component shown in dialog boxes (for example, Cool Circle).
    description-OptionalA short description of the component; shown as a tooltip in the component chooser dialog when a user creates a CVC.
    module-Mandatory(Read only) Name of the requirejs module implemented by the minified JavaScript. Must be unique across your installed CVCs.
    thumbnail-OptionalA PNG used in the component chooser dialog; you can optionally configure your component to use this for the preview of the component in design view.
    ui-OptionalA nested descriptor of the properties and dataset required by this component
    css-OptionalOptional css file reference (it will be copied inside the report directory when the component is created with a wizard).
    script-MandatoryJavaScript reference (it will be copied inside the report directory when the component is created with a wizard).

     

    Adding Properties to the UI

    The Javascript, CSS, and module properties are shown on Data tab of the Properties view for your component in Jaspersoft Studio.  You can use additional properties in the JSON file to define additional UI, in the form of a set of input fields (text, numbers, combobox, etc...), and an optional list of datasets that can be used by the component implementation. The values entered by the user in the UI are passed to the JavaScript file specified in the script member.

    Property nameDefaultMandatoryDescription
    sections-OptionalList of available sections which collects properties, in addition to js, css, and module properties, which are always present and, if we manage the custom ui, presented as read only.
    dataset-OptionalSet of dataset definitions. A dataset describes the fields of the item in the set.

     

    Property description format:

    {
        "label": "Figures",
        "description": "Display a list of figures",
        "module": "figures",
        "thumbnail": "Figures.png",
        "sections": [
            {
              "name" : <string>,
              "expandable" : <true | false>, // optional, default is true. If true, the name is shown as label and the section can also collapse
              "properties" : [
                    {
                        "name": <string>,
                        "label": <string>,
                        "description": <string>,
                        "mandatory": <true | false>,
                        "defaultValue": <string>,
                        "type": <type>,   // Possible types are: "Path", "Text", "Float", "Integer", "Double", "Combo", "Color"
                        "min" : <number>,    // Valid for number types
                        "min" : <number>,    // Valid for number types
                        "options" : [{ "label": <string>, "value": <val>}, {"label": <string>, "value": <val>}, ... ]    // List of possible options, valid for combobox only
                        "readOnly" : <true | false>, // optional, default is false.
                    }, ...
                ]
            }, ...
          ],
        "datasets": [
            {
                "label": <string>,  // Used only in UI
                "cardinality" : <int>, // -1 = no limit, otherwise a specific number, i.e 1.
                "sections": [
                    {
                      "name" : <string>,
                      "properties" : [
                            {
                                // same as in sections
                            }, ...
                        ]
                    }, ...
                 ]
            }, ...
        ]
    }
    

     

    Adding a CVC to Jaspersoft Studio

    Requirements for Using CVCs

    • PhantomJS

    You must install PhantomJS before you can use a custom visualization component in Jaspersoft Studio. PhantomJS is available for all the major OSs here: http://phantomjs.org/

    Once you have installed PhantomJS, add it to your classpath.  As of Jaspersoft Studio 6.2, there is no additional configuration needed to use PhantomJS.

    The PhantomJS license is BSD, but third-party licenses prevent us from including it in our software.

    Specifying a CVC Location

    Once you have created a JSON descriptor for your CVC, you can add the descriptor location to your Jaspersoft Studio configuration as follows:

    1. Select Window > Preferences > Jaspersoft Studio > Resource Folder Locations > Custom Visualisation Component to open the Preferences dialog box.
    2. Click New, select the location for your JSON descriptor, and click OK.
    3. Click OK to close the Preferences dialog.

    cvc-preferences.png.3078b0cfdfa13eacc28332b997894a92.png

    Using a CVC in a Report

    Drag the Custom Visualization element cvc-icon.png.fd1a315d157b7a3a0fd8f3b788453bf5.png from the Palette to your report. If the JSON descriptor is correctly configured, you should see the component in the component chooser dialog box.

    CVC_in_dialog.png.54c902239b0bf0951bd46223001a5fe2.png

    Select the component you want to add to the report. The component assets (javascript and css) are copied into the report directory

    Pre-installed CVCs

    Jaspersoft Studio 6.2 includes two CVC (stored inside the CVC plugin), available out of the box: Figures and Radial Progress. These components are sample implementations of the JSON descriptor format.

    To add one of these components, drag the Custom Visualization element http://community-static.jaspersoft.com/sites/default/files/images/cvc-icon.png from the Palette to your report and select the component in the component chooser dialog box. The component assets (javascript and css) are copied into the report directory.  The first time you add a pre-installed CVC to a report, you are prompted to give access permission to the location where these components are stored. You only have to do this once.

    The Figures component

    The Figures component is often used in dashboards and infographics:

    cvc-figures-example.png.e2feef14ea25549a9edf5f6313519366.png

    It is used to show a set of figures and color them. The number of figures shown is based on two numbers: items value and items count. The items count is the number of figures shown. The items value is the number of figures to color with the primary color (black by default). The items value don't have to be an integer number, but partial figures can be also coloured (like in the image).

     

    Configuration settings

     

    NamePropertyDefaultMandatoryDescription
    Items ValueitemsValue1trueThe number of selected values.
    Items CountitemsCount1falseThe number of phantom figures. Phantom figures are figures which are not selected, the ones painted in gray in the figure. If not set, or 0, the first integer bigger or equal than itemsValues will be used
    figureFigureMaletrue

    The figure to show. The Figures component has two built-in figures: Male and Female, but it is possible to use any figure in form of SVG path. In this case the type should be set to Custom and the path should be set in the customPath property.
    Possible values for this property are: Male, Female, Custom

    cvc-figures-male.png.162fea20907ec61f14d32abd92b70b67.png

    customPathCustom Path false

    This property is used only if the figure is set to Custom. The value must represent a valid SVG path data (http://www.w3.org/TR/SVG/paths.html#PathData).

    The image shows the use o a very complex path, taken from this SVG picture: http://www.clipartsfree.net/clipart/88-albert-einstein-silhouette-clipart.html

    cvc-figures-custom.png.64948668772ca31bd442c92d7a26b8e3.png

    fgColorForeground Colour#000000 (black)falseThe default colour used to plot the figures
    fgOpacityForeground Colour opacity1.0falseOpacity of the figures. Opacity spans from 0 (transparent) to 1 (fully visible)
    bgColorBackground Colour#000000 (black)falseThe background colour used for the not selected figures.
    bgOpacityBackground Colour Opacity0.2falseOpacity of the not background color. Opacity spans from 0 (transparent) to 1 (fully visible)
    showBackgroundShow BackgroundtruefalseShow or hide the background figures
    rowsRows0falseIf different than 0, this property allows to pre-set the number of rows that should be used to layout the figures.
    columnsColumns0falseIf different than 0, this property allows to pre-set the number of columns that should be used to layout the figures.
    maximizeColumnNumberMaximize cols numbertruefalse

    Allows to maximize the number of columns number. This option only takes effect when the user set a specific number of rows to be used. In that case, if the number of figures is close to the number of rows, the figures could be either displayed filling the available area row by row, or column by column. If true, the chart will try to render as many figure as possible in each row, otherwise the priority will given to the rows.

    In these two images, the number of rows is set to 9, and the number of items is 30.

    cvc-figures-maximizeColumnNumber-true.png.406888fa7a1e071526ee99226b256867.png

    cvc-figures-maximizeColumnNumbers-false(4).png.5b32d55d8c0fa26c21f8bdbe63ac11ec.png

    vAlignVertical Alignmenttopfalse

    How to align the whole figure (vertically).

    cvc-figures-vAlign-top(2).png.7f349312738bd8e66b24a314ad89f83d.png

    cvc-figures-valign-bottom(1).png.11dee1b8d762599091ebd60f7b581497.png

    hAlignHorizontal Alignmentleftfalse

    Horizontal Alignment of the overall set of figures

    hPaddingHorizontal Padding10false

    The horizontal space between figures

    cvc-figures-hPadding(1).png.9efa7e6459512e2dcdb658fe47b200dd.png

    vPaddingVertical Padding10false

    The vertical space between figures

    cvc-figures-vPadding(1).png.659b32fa4b40958e83fb6511a070da49.png

     

    The Radial Progress component

    The Radial Progress component is often used in dashboards and infographics:
    cvc-radial-progress(1).png.efdb6516610af4a477eaef071a464dcc.png

    It is used to show a percentage. If the percentage is over 100%, other rings are shown until the full percentage is represented (or the number of maximum rings is reached).
    cvc-radial-progress-multiple-rings(1).png.4efc04a84769ba2bb4f48ced7d155260.png

    The percentage is calculated based on two numbers: value and target. In particular the percentage is value/target. If target is not specified, or it is 0, it set to 1.
    Each grey (background) ring represents 100% of the target.

    Configuration settings

    NamePropertyDefaultMandatoryDescription
    valueValue90trueThe value to represent. It is set to 90 mostly to present to the user how the component works.
    targetTarget100falseThe target representing 100%. It is set to 100 by default mostly to present to the user how the component works.
    valueFormatValue Format.1%false

    The format used to format the value when printed in the centre of the rings. This format follows the D3 format specifications available here:

    https://github.com/mbostock/d3/wiki/Formatting#d3_format

    autoFitAuto fittruefalseIf true, the font size of the label is automatically calculated.
    fgColorForeground Color#000000 (black)falseThe colour used to plot the value ring(s)
    fgOpacityForeground Opacity1.0falseOpacity of the foreground colour. Opacity spans from 0 (transparent) to 1 (fully visible)
    bgColorBackground Color#000000 (black)falseThe colour used to plot the background ring(s)
    bgOpacityBackground Opacity0.2falseOpacity of the background colour. Opacity spans from 0 (transparent) to 1 (fully visible)
    showBackgroundShow BackgroundtruefalseAllows to hide the background ring(s)
    ringThicknessRing Thickness4.0falseThe thickness of the rings
    ringPaddingRing Padding4.0falseDistance between rings
    maxRingsMax number of rings0falseThe maximum number of rings displayed (by default rings are shown until there is space).
    hPaddingHorizontal Padding10falseHorizontal Padding (left and right)
    vPaddingVertical Padding10falseVertical Padding (top and bottom)
    animationUse AnimationtruefalseUse an animation when displaying the component. (This property is automatically set to false when the report is not exported in HTML)

     

    The Sparkline component (added in 6.2.2)

    The Sparkline component is a minimalistic line chart, without axes or coordinates, that shows variation over time. It follows the guidelines of Edward Tufte here: http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR to represent a series of values.

    http://community-static.jaspersoft.com/sites/default/files/wiki_attachments/sparkline.png?_ga=1.248779716.2115103839.1448308340

     

    Configuration settings

     

    NamePropertyDefaultMandatoryDescription
    Line ColorlineColor#000000falseThe color used to plot the line
    Line OpacitylineOpacity1falseThe opacity of the line color (from 0 to 1)
    Line WidthlineStroke0.1falseLine width (in pixels)
    Interpolation typeinterpolationbasisfalse

    The type of interpolation used to plot the line.

    Interpolation types:

    linear

    http://community-static.jaspersoft.com/sites/default/files/wiki_attachments/sparkline-linear.png?_ga=1.15776629.2115103839.1448308340

    step-before

    http://community-static.jaspersoft.com/sites/default/files/wiki_attachments/sparkline-step-before.png?_ga=1.15776629.2115103839.1448308340

    step-after

    http://community-static.jaspersoft.com/sites/default/files/wiki_attachments/sparkline-step-before.png?_ga=1.15776629.2115103839.1448308340

    basis

    http://community-static.jaspersoft.com/sites/default/files/wiki_attachments/sparkline-basis.png?_ga=1.240300864.2115103839.1448308340

    cardinal

    http://community-static.jaspersoft.com/sites/default/files/wiki_attachments/sparkline-cardinal.png?_ga=1.182064868.2115103839.1448308340

     

    monotone

    http://community-static.jaspersoft.com/sites/default/files/wiki_attachments/sparkline-monotone.png?_ga=1.182064868.2115103839.1448308340

    Fill ColorfillColor#0000FFfalseThe color used to fill the line area
    Fill OpacityfillOpacity0.5falseThe opacity of the line area (from 0 to 1)
    Circe ColorcircleColor#FF0000falseThe color used to plot the circle on the last point
    Circle OpacitycircleOpacity1falseThe opacity of the circle on the last point (from 0 to 1)
    Circle RadiuscircleRadius2falseThe radius (in pixels) of the circle on the last point.

     

    Data settings

    The component requires a data item to provide a set of values that will be plotted. Series items must have the following properties:

    Item property nameType
    valuenumeric

     

    See Also


    User Feedback

    Recommended Comments



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...