Product: TIBCO Spotfire®
How to use a Python Script to toggle (Show/Hide) curves created in a visualization via Lines and Curves?
Ability to toggle (Show/Hide) curves created via Lines and Curves in a visualization using a Python Script.
The following is a script which toggles (Show/Hide) curves created via Lines and Curves in a visualization, a Line Chart in this case.
########################################################
from Spotfire.Dxp.Application.Visuals import *
for visual in Document.ActivePageReference.Visuals:
if visual.TypeId == VisualTypeIdentifiers.LineChart:
lc = visual.As[LineChart]()
for fm in lc.FittingModels:
if fm.TypeId.DisplayName == "Straight Line Fit":
if fm.Line.DisplayName == "Straight line":
fm.Enabled=not(fm.Enabled)
elif fm.TypeId.DisplayName == "Exponential Curve Fit":
print fm.Curve.DisplayName
if fm.Curve.DisplayName == "Exponential curve":
fm.Enabled=not(fm.Enabled)
########################################################
The other line types would include: Polynomial Curve, Logarithmic Curve, Gaussian curve, etc.
Disclaimer:
The script code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the script in accordance with your implementation specifications that best suit your business requirements. Refer to the API reference(s) cited in this article for usage of the classes and methods used in the script.
https://docs.tibco.com/pub/doc_remote/spotfire/6.5.0/api/?topic=html/N_Spotfire_Dxp_Application_Visuals_FittingModels.htm
https://docs.tibco.com/pub/doc_remote/spotfire/6.5.0/api/?topic=html/P_Spotfire_Dxp_Application_Visuals_FittingModels_FittingModel_Enabled.htm
https://docs.tibco.com/pub/doc_remote/spotfire/6.5.0/api/?topic=html/P_Spotfire_Dxp_Application_Visuals_FittingModels_ReferenceCurve_DisplayName.htm
Toggle, Show/Hide, Lines and Curves, Lines & Curves, python, IronPython, script, Straight Line Fit, Polynomial Curve, Logarithmic Curve, Gaussian curve, ActivePageReference, Visuals, VisualTypeIdentifiers, FittingModels, DisplayName, Enabled
Comments
0 comments
Article is closed for comments.