Chris Brawn Posted February 14, 2020 Share Posted February 14, 2020 Hi All, I have the code below, which takes a string from a text area and adds it to the limit data expression of a visualisation. However when I try and make the change to a custom visualisation, I get the following error: - AttributeError: 'NoneType' object has no attribute 'Data' However when I add it to a Spotfire visualisation, it works fine with no issues. What do I need tochange in the code to add to the equivalent limit data by expression box (shown in attachment) in a js viz from Spotfire.Dxp.Application.Visuals import * from Spotfire.Dxp.Data import * for vis in Document.ActivePageReference.Visuals: if vis.Title == 'Chart wizard area': ta= vis.As[HtmlTextArea]().HtmlContent print ta for vis1 in Application.Document.ActivePageReference.Visuals: if vis1.Title == 'chart viz': #if statement for testing print 'hello' visual = vis.As[Visualization]() visual.Data.WhereClauseExpression = ta Link to comment Share on other sites More sharing options...
Dave Leigh Posted February 21, 2020 Share Posted February 21, 2020 JSViz uses it's own internal API which you can access through IronPython as described in Chapter 16 of the User Guide. Firstly you will need to include the references to the JSViz API: import clr clr.AddReference ( "SpotfirePS.Framework.JSVisualization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4d233badaf236513" ) # # Import the JS Visualization classes # from SpotfirePS.Framework.JSVisualization import * from SpotfirePS.Framework.JSVisualization.Core import * Then you will need to obtain a reference to the visual similar to what you have in your code above: jsviz = vis.As[JSVisualizationModel]()Now, given that JSViz can have multiple Data Settings objects, the following code will assume the first one, you may need additional logic: lstDataSettings = jsviz.DataSettings # # Check for empty list # if lstDataSettings.Count < 1: print "No current Data Setting" return # # Assume the first Data Settings # ds = lstDataSettings[ 0 ] # # Set the current Limit By Expression statement # ds.FilterExpression = '[ChartMap] = "BarClustered" and [ChartQuestionSeq] = 1' You can find more examples of JSViz Scripting in the example that ships with the JSViz download. Look in the "For Spotfire Analyst" folder for Scripting.dxp. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now