spotfire reset markings

Spotfire IronPython: Reset Markings

Posted on Updated on

Here is a code snippet for removing markings across visualizations/data tables within an analyses. This script will not reset the filters and only work on the marking. To illustrate this, I have constricted the date range for couple of date filters in the filter column.

Reset_Markings_1

I will now make some selections on the bar chart

Reset_Markings_2

To remove the markings without resetting the applied filters, we can execute the script through the button Reset Markings

Reset_Markings_3

Code snippet for reference: Reset_Markings_4

# Import required libraries
from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Application.Filters import *

def resetMarking():
# Loop through each data table
for dataTable in Document.Data.Tables:
# Navigate through each marking in a given data table
for marking in Document.Data.Markings:
# Unmark the selection
rows = RowSelection(IndexSet(dataTable.RowCount, False))
marking.SetSelection(rows, dataTable)

# Call the function
resetMarking()

Below is one more use of the snippet applied for multiple visualizations which use cascading markings.

Reset_Markings_5

When the analysis contains multiple markings, then visualizations using these multiple markings have to be set individually. Below I am removing the marking for a single data table.

Reset_Markings_6

Though we Unmark marking for a single visualization, the markings which have got applied through cascading are not reset in other visualizations. In the bottom visualization, the markings are not reset as it inherits markings from the center visualization.

Reset_Markings_7

In such cases, our script should do the job.

Reset_Markings_8