Jump to content
  • How to switch Bar chart into Line chart visualization and vice versa using IronPython script in Spotfire®


    This page shows how to switch a Bar Chart into a Line Chart and vice versa by making use of IronPython scripts.

    Introduction

    This page shows how to switch a Bar Chart into a Line Chart and vice versa by making use of IronPython scripts.

    Code samples

    Converting a Bar Chart into a Line Chart

    # Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    # converting a Bar chart into a Line Chart:
    
    from Spotfire.Dxp.Application.Visuals import VisualTypeIdentifiers,BarChart,VisualContent
    
    for vis in Document.ActivePageReference.Visuals: 
    	if vis.TypeId == VisualTypeIdentifiers.BarChart:	
    			vc = vis.As[VisualContent]()  
    			yexp = vc.YAxis.Expression
    			xexp = vc.XAxis.Expression
    			cexp = vc.ColorAxis.Expression
    			vis.TypeId = VisualTypeIdentifiers.LineChart
    			vis.ApplyUserPreferences()
                    	vc = vis.As[VisualContent]() 
                    	vc.YAxis.Expression = yexp
    			vc.XAxis.Expression = xexp
    			#vc.YAxis.ManualZoom = bool
    			vc.XAxis.ManualZoom = bool
    			vc.ShowMarkers = bool
    			vc.ColorAxis.Expression = cexp
     

     

    Converting a Line Chart into a Bar Chart

    # Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    # Converting a Line Chart into a Bar Chart:
    
    from Spotfire.Dxp.Application.Visuals import VisualTypeIdentifiers,BarChart,VisualContent,ScaleAxis
    for vis in Document.ActivePageReference.Visuals:  
    	if vis.TypeId == VisualTypeIdentifiers.LineChart:	
    			vc = vis.As[VisualContent]()  
    			yexp = vc.YAxis.Expression
    			xexp = vc.XAxis.Expression
    			cexp = vc.ColorAxis.Expression
    			vis.TypeId = VisualTypeIdentifiers.BarChart
                    	vis.ApplyUserPreferences()
                    	vc = vis.As[VisualContent]() 
                    	vc.YAxis.Expression = yexp
    			vc.XAxis.Expression = xexp
    			#vc.YAxis.ManualZoom = bool
    			vc.XAxis.ManualZoom = bool
    			vc.ColorAxis.Expression = cexp
    			vc.LabelSegments = False
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...