How to show or hide regression lines with IronPython?

What is the IronPython code to toggle on and off a line or curve created in the Properties/Lines & Curves ?

Thank you

4 Comments

Hello Chutrau,

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.
Shandilya Peddi - Oct 31, 2017 - 10:53am ::

Hello Chutrau,

Below is a sample code on how to toggle the lines

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)
Shandilya Peddi - Sep 25, 2017 - 2:11pm ::

Hello Chutrau,

Below is a sample code on how to toggle the lines

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)
Shandilya Peddi - Sep 25, 2017 - 2:11pm ::

Hello Chutrau,

Below is a sample code on how to toggle the lines

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)
Shandilya Peddi - Sep 25, 2017 - 2:11pm ::
View More Comments + Add a Comment

(1) Answer

Login