简体   繁体   中英

Spotfire How To Change Calculate Totals Using Iron Python

I have a Cross Table in my Spotfire Dashboard and am trying to change the "Calculate Totals" option using an Iron Python script.

在此处输入图片说明

I've found this link on Spotfire API. So, from what I understood, this information is stored in myVis.Totals. But, for whatever the reason, this seems to be a read-only property as can be seen here .

Have any of you ever had this problem and would know how to fix it?

This is my code:

from Spotfire.Dxp.Application.Visuals import *

# myVis is a script parameter of the type "Visualisation"
myVis = myVis.As[Visualization]()
myVis.Totals = CrossTableTotals.CalculationMode.SumOfCellValues

This is the error I'm getting:

Traceback (most recent call last):
  File "<string>", line 5, in <module>
AttributeError: can't assign to read-only property Totals of type 'CrossTablePlot'


System.MissingMemberException: can't assign to read-only property Totals of type 'CrossTablePlot'
   at CallSite.Target(Closure , CallSite , Object , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
   at Spotfire.Dxp.Application.IronPython27.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)

Try this

myVis.Totals.DefaultCalculationMode=CrossTableTotals.CalculationMode.SumOfCellValues

Gaia

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM