Jump to content

Add/Remove Line from Column in Scatter Plot(lines and curves) using IronPython


Steve Ennis

Recommended Posts

The link in the "IronPython Scripting in TIBCO Spotfire" for Add Line from Column Values to a Visualizationdoes not work. I would love to see this script because I am exactly trying to include a toggle button to add/remove specific lines(from column values) from my scatter plot. It appears it was once there but now the link doesn't work. Please fix.

https://community.spotfire.com/wiki/ironpython-scripting-tibco-spotfire

Thank you!

Link to comment
Share on other sites

I get a "You are not authorized to access this page" on TIBCO's website. And I am logged into the commuunity at the time. I have also checked different browsers just in case it is a Google/Bing issue.  The message is the same.  But the "You are not authorized to access this page" is different (an improvement) from yesterday. 
Link to comment
Share on other sites

Is this the same for every other article link on the Iron Python script page

Can you please provide the screenhot for more clarity.

In the meantimebelow the script that you may find of help:

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Application.Visuals.FittingModels import *

#get the data table

table=Document.Data.Tables["myDataTable"]

# define vis as script parameter referring to your visualization

lchart=vis.As[scatterPlot]()

# Add a ColumnValuesLine fitting model

fModel=lchart.FittingModels.AddNew(ColumnValuesLine)

#Define the model

fModel.DataTableReference=table

fModel.XColumnReference=table.Columns["columnA"]

fModel.YColumnReference=table.Columns["columnB"]

 

#get the ReferenceCurve

line=fModel.Line

#set a custom name to the line

line.CustomDisplayName="myLine"

line.IsBackground=True

line.LineStyle=LineStyle.Dot

Link to comment
Share on other sites

Below is the script I got to work. Copy lines 6-8 and alter to do multiple lines on 1 graph. Copy entire script and change vis to vis2 for multiple graphs on the same page. Thanks!

 

from Spotfire.Dxp.Application.Visuals import *

for fm in vis.As[scatterPlot]().FittingModels:

if vis.TypeId == VisualTypeIdentifiers.ScatterPlot:

lc = vis.As[scatterPlot]()

for fm in lc.FittingModels:

if fm.TypeId.DisplayName == "Line from Column Values" :

 

if fm.Line.DisplayName == "YourCurveName":

 

fm.Enabled=not(fm.Enabled)

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