Jump to content

Set Zoom Sliders in Scatter Plot for X-axis and Y-axis by specifying some input


Padmini
Go to solution Solved by Jose Leviaguirre,

Recommended Posts

  • Solution
Posted (edited)

Hello Padmini

You will  need to create an Action Control on a Text Area and associate an IronPython script to it. The script will be something like:
 

from Spotfire.Dxp.Application.Visuals import AxisRange, ScatterPlot

# vis is a script parameter 
scatter = vis.As[ScatterPlot]()

# update X zoom range
axisRangeX = AxisRange(2000,3000)
scatter.XAxis.ZoomRange = axisRangeX

# update Y zoom range
axisRangeY = AxisRange(400,500)
scatter.YAxis.ZoomRange = axisRangeY

 

Another option that requires no coding is to use bookmarks


Check out these articles on how you can use IronPython to programatically set the zoom sliders to a specific position.

Edited by Jose Leviaguirre
Link to comment
Share on other sites

Hello Jose,

I modified the script a bit. I am now taking the X-axis min and max values from a input fields and setting the zoom sliders. Similarly for Y-axis.

from Spotfire.Dxp.Application.Visuals import AxisRange
from Spotfire.Dxp.Application.Visuals import ScatterPlot
from Spotfire.Dxp.Application.Visuals import *

typedVisualisation = None
	
for vis in Application.Document.ActivePageReference.Visuals:

	# if it is a visualisation which cannot have a zoom slider, it is ignored
	if vis.TypeId.Name=="Spotfire.ScatterPlot":
		typedVisualisation = vis.As[ScatterPlot]()
	
	if typedVisualisation is not None:

		#if resetX: typedVisualisation.XAxis.ZoomRange = AxisRange.DefaultRange
		#if resetY: typedVisualisation.YAxis.ZoomRange = AxisRange.DefaultRange
	
		MyChart = typedVisualisation

		Xmin = Document.Properties["XaxisZoomMinValue"]
		Xmax = Document.Properties["XaxisZoomMaxValue"]
		
		MyChart.XAxis.ManualZoom = True
		MyChart.XAxis.ZoomRange = AxisRange(Xmin,Xmax);
		typedVisualisation = None

 

Thanks for your help.

  • Thanks 1
Link to comment
Share on other sites

Hi Jose,

I have a scenario where I want to set the zoom slider to latest year:

as of now this is the default view of the linechart.

image.png.aa21005b5ae561bdd211bc43c0c667bf.png

when someone opens the analysis they should be able to see below view by default:

image.png.7ddde0fae209995e065a1426105404f7.png

How can I tweak above scripts to achieve this?

Regards,
Prateek

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