Jun 3, 2016

hide Spotfire data table column using python script

from Spotfire.Dxp.Application.Visuals import CrossTablePlot
crossTable = ct.As[CrossTablePlot]()
#toggle height between 100 and 300
crossTable.RowHeaderWidths[0]=0
crossTable.RowHeaderWidths[1]=0

Spotfire BarChart color setting change with python script

from Spotfire.Dxp.Data import DataPropertyClass
from Spotfire.Dxp.Application.Visuals import BarChart
from Spotfire.Dxp.Application.Visuals.ConditionalColoring import Coloring
vc=vis.As[BarChart]()
if Document.Properties["SelectType"]=="All":
   if Document.Properties["AccountName"] == "Exclude Zeros":
        vc.Data.WhereClauseExpression="case when '${SelectType}'='Taxable Income' then ([Total Taxable Income])<>0 when '${SelectType}'='Component Income' and [Group]='O' then ([Value]) <>0 when '${SelectType}'='All' then ([Value]) <>0 end and ([Category] in ($map(\"\'${Components}\'\", \",\")) or  [Category] in (\"Taxable Income\"))"
        vc.YAxis.Expression="sum(Value)"
        vc.ColorAxis.Expression="<[CategoryTest] as []>"
        vc.ColorAxis.Coloring.Apply("Color Scheme")
   else:
       vc.YAxis.Expression="sum(Value)"
       vc.ColorAxis.Expression="<[CategoryTest] as []>"
       vc.Data.WhereClauseExpression="[Category] in ($map(\"\'${Components}\'\", \",\")) or  [Category] in (\"Taxable Income\")"
       vc.ColorAxis.Coloring.Apply("Color Scheme")

elif Document.Properties["SelectType"]=="Taxable Income":
   vc.YAxis.Expression="sum([Total Taxable Income]) as [Taxable Income]"
   vc.ColorAxis.Expression="<[Axis.Default.Names] as []>"
   vc.ColorAxis.Coloring.Apply("Color Scheme")
   #vc.Data.WhereClauseExpression=""
elif Document.Properties["SelectType"]=="Component Income":
   vc.YAxis.Expression="${SelectComponents}"
   vc.ColorAxis.Expression="<[Axis.Default.Names] as []>"
   vc.ColorAxis.Coloring.Apply("Color Scheme")
   #vc.Data.WhereClauseExpression=""

#Cross Table
from Spotfire.Dxp.Application.Visuals import VisualContent
vc1 = viz.As[VisualContent]()
if Document.Properties["SelectType"]=="All":
   vc1.MeasureAxis.Expression="${SelectComponents},Sum([Taxable Income]) as [Taxable Income] "
   if Document.Properties["AccountName"] == "Exclude Zeros":
       vc1.Data.WhereClauseExpression='case when "${SelectType}"="All" then ([Taxable Income]) <>0  OR ($map("([${Components}])", "<>0 Or")<>0 ) end'
   else:
       vc1.Data.WhereClauseExpression=''

elif Document.Properties["SelectType"]=="Taxable Income":
   vc1.MeasureAxis.Expression="Sum([Taxable Income]) as [Taxable Income]"
   if Document.Properties["AccountName"] == "Exclude Zeros":
       vc1.Data.WhereClauseExpression='case when "${SelectType}"="Taxable Income" then ([Taxable Income]) <>0 when "${SelectType}"="Component Income" then ($map("([${Components}])", "<>0 Or")<>0 ) end'
   else:
       vc1.Data.WhereClauseExpression=""
elif Document.Properties["SelectType"]=="Component Income":
   vc1.MeasureAxis.Expression="${SelectComponents}"
   
   if Document.Properties["AccountName"] == "Exclude Zeros":
       vc1.Data.WhereClauseExpression='case when "${SelectType}"="Taxable Income" then ([Taxable Income]) <>0 when "${SelectType}"="Component Income" then ($map("([${Components}])", "<>0 Or")<>0 ) end'
   else:
       vc1.Data.WhereClauseExpression=''
   

Reset Spotfire BarChart Data limit and Axis Value Reset

from Spotfire.Dxp.Application.Visuals import AxisRange
from Spotfire.Dxp.Application.Visuals import VisualContent
vc=vis.As[VisualContent]()
vc.Data.WhereClauseExpression="[Amounts]<>0  and ([Days]< Max([Days]))"
vc.XAxis.ZoomRange = AxisRange.DefaultRange;
vc.YAxis.ZoomRange = AxisRange.(0,200);