Jump to content

How to program Spotfire to generate plots based on a standard excel data sheet every time


S Na

Recommended Posts

Hello Friends:

I run some simulations and get an output excel/csv file with a whole bunch of data in tables.

I was wondering if it takes a lot of programing to be able to copy the file path location and have spotfire generate some plots based on that common excel file

I run hundreds of these simulations and I'd like to be able to simply copy paste the folder location/file name of this excel file and have spotfire generate plots.

I tried searching this forum for something similar but I couldnt.

I'd really appreciate your input and any resource on how to code this into spotfire

Thank you and Cheers!

Link to comment
Share on other sites

You can do the following,

1. Create a text area with Input Property control to enter the excel file path

2. Use the DataManager.CreateFileDataSource() to load the data into Spotfire

https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-a...

3. Use the VisualCollection.AddVisual() to add your visuals

https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-a...

For example configure barchart as needed using the api methods/properties available.

https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-a...

Sample code would be as below

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Application.Visuals import *

 

filePath=Document.Properties["FilePath"]

 

#build the data flow

dataSource= Document.Data.CreateFileDataSource(filePath)

Document.Data.Tables.Add("newTableName",dataSource)

 

#get the current page to add visuals

page=Document.ActivePageReference

 

barChart=page.Visuals.AddNew[barChart]()

# autoconfigure the barchart

#barChart.AutoConfigure()

 

# Or configure as needed

#barChart.XAxis.Expression=""

#barChart.YAxis.Expression=""

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