How to switch a color scheme grouping to a CrossTable using IronPython

Hi,

I have a cross table and depending on the parameter passed to the script, my crossd table will plot a % value, or a Sum value.

I am passing in a parameter, to drive the Cross Table values axis:

crossTable.MeasureAxis.Expression = ColorExpression

 

Parameters wil be either:

Sum([On Time]) / Sum([Total Reports]) as [% on Time]

or

Sum([Total Reports]) as [Total Reports]

 

The coloring need to be different dependent on the value axis, and while I can make the [% on Time] code work as it needs to:

 

from Spotfire.Dxp.Application import Filters as filters
from Spotfire.Dxp.Application.Filters import FilterPanel
from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Application.Visuals.Maps import *
from Spotfire.Dxp.Data import *
from System.Drawing import Color
from System.Collections import IEnumerable
from Spotfire.Dxp.Data import DataType
from Spotfire.Dxp.Application.Visuals.ConditionalColoring import *
from Spotfire.Dxp.Data.Formatters import NumberFormatter, NumberFormatCategory

crossTable.MeasureAxis.Expression = ColorExpression
 
coloringCollection = crossTablePlot.Colorings

categoryKey = coloringCollection.GetCategories()
currentColoring = coloringCollection.GetColoringForCategory(categoryKey[0])

Document.Properties['PivotReportName']=ReportName
Document.Properties['PivotColorScheme']=ColoringScheme
Document.Properties['PivotComplianceTarget']=ComplianceTarget

Document.Properties['PivotDrillDownReportName']=ReportName
Document.Properties['PivotTableDrillDownWarning']=""

print(ComplianceTarget)

if ColoringScheme == "1_AllMonths" or ColoringScheme == "4_AllMonths" or ColoringScheme == "7_AllMonths":
 currentColoring.AddThresholdColorRule(RuleComparisonOperator.GreaterOrEqual, ConditionValue.CreateExpression("${PivotComplianceTarget}"),Color.FromName("Green"))
 currentColoring.AddThresholdColorRule(RuleComparisonOperator.Less, ConditionValue.CreateExpression("${PivotComplianceTarget}") ,Color.FromName("Red"))
 

 

 

I have no idea how to actually swap out the grouping entirely to use this:

Sum([Total Reports]) as [Total Reports]

vs

Sum([On Time]) / Sum([Total Reports]) as [% on Time]

 

I guess I need to either delete and replace the Coloring Group somehow?

Any advice appreciated

 

 

(1) Answer

Login