user3639100
user3639100

Reputation: 346

Data limiting with a button in spotfire

im trying to change the data limiting expression on a bar chart in spotfire by pressing a button, using an ironpython script.

from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Data import *
for vis in Application.Document.ActivePageReference.Visuals:
    if vis.Title == "BarChart1":
    vis.Data.WhereClauseExpression = "[Column1]=Test"

So in the above example im trying to change the filtering expression to show only the data that has "Test" in column1. The error im getting is the following:

AttributeError: 'Visual' object has no attribute 'Data'

What does that exactly means and how can i fix it?

(I have not added any parameters)

Upvotes: 2

Views: 945

Answers (1)

Mark P.
Mark P.

Reputation: 1827

from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Data import *
for vis in Application.Document.ActivePageReference.Visuals:
    if vis.Title == "BarChart1":
        visualContentObject = vis.As[Visualization]()
        visualContentObject.Data.WhereClauseExpression = '[Column1]=Test'

Also, I would recommend doing this as a parameter and not by title in case your title becomes dynamic.

Upvotes: 3

Related Questions