Jump to content

Formatting a Worksheet's Scorecard Display with Seeq Data Lab


Kristopher Wiggins

Recommended Posts

  • Seeq Team

As covered in Push Scorecard from Seeq Data Lab, it is possible to push a scorecard from Seeq Data Lab into Seeq Workbench Analysis. In this post, we'll cover how we can format the display of a worksheet in Scorecard view. The scorecards can be pre-made in Workbench or have been previously pushed from Seeq Data Lab. Please refer to R21 Scorecard Metric for more information about how to modify scorecard display format in Workbench.  

To format the display of a worksheet, we will first need to access the worksheet to be changed. In these examples, we'll assume that we're modifying an existing worksheet. Similar logic can be applied to new worksheets being created.

Step 1: Pull in the worksheet 

First, using the spy.search and spy.pull commands we can pull information about the workbook of interest. We can then navigate through the workbook in Python to access the contents of the worksheet. 

# The output of this command is a list of pulled workbooks that match the criteria passed into the search command  
pulled_workbooks =  spy.workbooks.pull(spy.workbooks.search({"Workbook Type":"Analysis", "Name": "Example Analysis"}))

# You can then access the worksheet looking to be changed using the command below. A variation to access the worksheet by its location rather than its name is listed beneath
scorecard_worksheet = pulled_workbooks[0].worksheet("Scorecard Worksheet")
# scorecard_interested =pulled_workbooks[0].worksheets[1]

Step 2: Modifying the Scorecard View

We can then modify the format of the display using the code below. 

# This line is only needed if the worksheet is not in Scorecard view
scorecard_worksheet.view = "Scorecard"

# The lines below change the format to only show the Start time in an "l" format, which is m/d/yyyy 
scorecard_worksheet.scorecard_date_display = "Start"
scorecard_worksheet.scorecard_date_format = "l"

For additional options for formatting, please take a look at the code below

@property
    def scorecard_date_display(self):
        """
        Get/Set the date display for scorecards
        Parameters
        ----------
        str or None
            The dates that should be displayed for scorecards.
            Valid values are:
            =============== ================================
            Date Display    Result
            =============== ================================
            None            No date display
            'Start'         Start of the time period only
            'End'           End of the time period only
            'Start And End' Start and end of the time period
            =============== ================================
        Returns
        -------
        str or None
            The scorecard date display
        """
        return self._get_scorecard_date_display()
@property
    def scorecard_date_format(self):
        """
        Get/Set the format for scorecard date displays
        Parameters
        ----------
        str
            The string defining the date format. Formats are parsed using
            momentjs. The full documentation for the momentjs date parsing
            can be found at https://momentjs.com/docs/#/displaying/
        Examples
        --------
        "d/m/yyy" omitting leading zeros (eg, 4/27/2020): l
        "Mmm dd, yyyy, H:MM AM/PM" (eg, Apr 27, 2020 5:00 PM) : lll
        "H:MM AM/PM" (eg, "5:00 PM"): LT
        Returns
        -------
        str
            The formatting string
        """
        return self._get_scorecard_date_format()

Step 3: Push the workbook back to Workbench

Pushing the workbook back into Workbench will cause the existing workbook to update to match the formatting we specified in Seeq Data Lab.

# Push the workbook back into Workbench
spy.workbooks.push(workbooks= pulled_workbooks)

 

Link to comment
Share on other sites

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...