I fixed my issue using the below Ironpython script.
from Spotfire.Dxp.Application.Visuals import *
from System.Collections.Generic import List
from Spotfire.Dxp.Data import *
shapesTable = Document.Data.Tables["Shapefile"]
# Create a cursor for the 'Tag' column in the shapesTable
cursor = DataValueCursor.CreateFormatted(shapesTable.Columns["Tag"])
# Retrieve the marking selection
markings = Document.ActiveMarkingSelectionReference.GetSelection(shapesTable)
# Create a List object to store the retrieved data marking selection
markedTags = List[str]();
#Iterate through the data table rows to retrieve the marked rows
for row in shapesTable.GetRows(markings.AsIndexSet(),cursor):
value = cursor.CurrentValue
if value <> str.Empty:
markedTags.Add(value)
if len(markedTags) == 0:
markedTag = ["Tag 1", "Tag 2", "Tag 3", "Tag 4"]
#Clearing the line chart and plotting the selected Tags
# vis is a scripting parameter
vis = vis.As[LineChart]()
# Clear the Y-axis expression (removes all plotted lines)
vis.YAxis.Expression = ""
# Build the Y-axis expression (here it is the average)
y_axis_expression = ", ".join(["avg([" + col + "])" for col in markedTags])
# Apply the new Y-axis expression to the line chart
vis.YAxis.Expression = y_axis_expression