Jump to content
We've recently updated our Privacy Statement, available here. ×
  • How to implement "drill through" by clicking on a bar in a bar chart in Spotfire®


    This article provides guidelines on how to set up drill-through functionality, which allows users to navigate from an aggregated view (bar chart) to a more detailed view of the underlying data by interacting with the chart.

    Sometimes, you may want to create a dashboard or analytic application that lets an end user see an overview of the data on one page, and by clicking on an element in a visualization, drill to more details about the clicked category. For example, imagine seeing Sales per Region in a bar chart and when clicking on a bar for a particular region, you navigate to another page that displays more details about that region. This is sometimes called "drill through" and is natively possible to do in, for example, the KPI chart, text areas, and the graphical table. However, you might also want to use drill-through in other visualizations, like, for example, in a bar chart.

    This article shows a way of implementing this using a simple data function and an even simpler IronPython script.

     Video showing the end result, and below follows a description of how it is implemented. Please also note that there is an alternative way to implement this and similar functions using the Custom Datetime Data function available on TIBCO Exchange.

    The solution is based on:

    1. An overview page with a bar chart that shows Sales per Region.
    2. A data function that takes the Region column as input, and is limited by marking. The data function reads the Region value of the market data and writes it to a document property.
    3. An IronPython script that gets triggered when the document property changes, and then switches the page to a details page.
    4. The visualizations on the details page are limited to displaying data that matches the value of the document property. There is a "Back" button in a text area on the details page.

    Here is the code of the data function:

    # This script will set a document property to the first value in the
    # input parameter.
    # The input parameter ClickedCategory is intended to be limited by
    # the marking of a visualization where the user marks. 
    # When the user marks in a visualization with the mentioned marking,
    # this is intended to trigger an Iron Python script that will change
    # the page to a page with more details 
    # about the selected value.
    # This script is part of a DXP published on the TIBCO Community.
    
    l <- levels(factor(ClickedCategory));
    
    if (length(l) == 0)
    {
        selectedValue <- '';
    } else 
    {
        selectedValue <- l[1];
    }
     

    Here is the IronPython script:

    # This script just checks that there is a value in the input,
    # and if so changes the page
    #
    if selectedValue != "":
        Document.ActivePageReference = SelectedStatesPage
     

    And the DXP file itself is attached to this post.

    This method may be used for other purposes as well, it is essentially up to the Iron Python script that gets triggered when marking. It could, for example, reconfigure the actual visualization the user marks values in, in order to provide a visualization drill-down experience.

    clicktochangepagesalesandmarketing.zip

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...