Nivedan Nasina Posted December 15, 2020 Share Posted December 15, 2020 Can the experts please help with the following request: Please refer to the attached image as to how my final settings need to look like 1) set the color by a column 2) set the color mode to segments 3)set default color for all to black including empty values 4) add rule#1 a)Rule type: less than or equal to b)Value: Min c) Color: Red I primarily need help with #4, #3, #1 above in that order I found the following script as a starting point: https://community.spotfire.com/wiki/how-set-color-mode-gradient-and-specify... from Spotfire.Dxp.Data import * from System.Collections.Generic import List from Spotfire.Dxp.Application.Visuals import * from System.Drawing import Color from Spotfire.Dxp.Application.Visuals.ConditionalColoring import Coloring, ContinuousColorRule ,ConditionValue,IntervalMode vc = vis.As[barChart]() colorRule = vc.ColorAxis.Coloring.Clear() cr = vc.ColorAxis.Coloring.AddContinuousColorRule() cr.IntervalMode = IntervalMode.Gradient cv1 = ConditionValue.CreateLiteral('-18724.86') cv2 = ConditionValue.CreateLiteral('-30099.13') cr.Breakpoints.Add(cv1,Color.Blue) cr.Breakpoints.Add(cv2,Color.Yellow) https://docs.tibco.com/pub/doc_remote/sfire-analyst/11.0.0/doc/api/TIB_s... Thanks a lot in advance to anyone spending time on this. Link to comment Share on other sites More sharing options...
Nivedan Nasina Posted December 15, 2020 Author Share Posted December 15, 2020 I got #1 & #2 done: from Spotfire.Dxp.Application.Visuals import * from Spotfire.Dxp.Application.Visuals.FittingModels import * from Spotfire.Dxp.Application.Extension import * from System.Drawing import * from Spotfire.Dxp.Data import * from System.Collections.Generic import List from Spotfire.Dxp.Application.Visuals import * from System.Drawing import Color from Spotfire.Dxp.Application.Visuals.ConditionalColoring import Coloring, ContinuousColorRule ,ConditionValue,IntervalMode #Get a reference to the current visualization sp1 = Viz.As[scatterPlot]() colorRule = sp1.ColorAxis.Coloring.Clear() sp1.ColorAxis.Expression = "[col_name]" cr = sp1.ColorAxis.Coloring.AddContinuousColorRule() cr.IntervalMode = cr.IntervalMode.Segments Link to comment Share on other sites More sharing options...
Nivedan Nasina Posted December 15, 2020 Author Share Posted December 15, 2020 I have the following script (for #1,#2,#4)and it is seems to be setting it "properly" (refer to screenshot)but the colors arenot showing up.(still all gray) if i add the rules manually then it works(like before) but not with this code - not sure what the issue seems to be. NEED HELP definitely from Spotfire.Dxp.Application.Visuals import * from Spotfire.Dxp.Application.Visuals.FittingModels import * from Spotfire.Dxp.Application.Extension import * from System.Drawing import * from Spotfire.Dxp.Data import * from System.Collections.Generic import List from Spotfire.Dxp.Application.Visuals import * from System.Drawing import Color from Spotfire.Dxp.Application.Visuals.ConditionalColoring import * #Get a reference to the current visualization sp1 = Viz.As[scatterPlot]() colorRule = sp1.ColorAxis.Coloring.Clear() sp1.ColorAxis.Expression = "[col_name]" cr = sp1.ColorAxis.Coloring.AddContinuousColorRule() cr.IntervalMode = cr.IntervalMode.Segments sp1.ColorAxis.Coloring.AddThresholdColorRule(RuleComparisonOperator.LessOrEqual,ConditionValue.MinValue,Color.FromName("Red")) sp1.ColorAxis.Coloring.AddThresholdColorRule(RuleComparisonOperator.GreaterOrEqual,ConditionValue.MaxValue,Color.FromName("Green")) Link to comment Share on other sites More sharing options...
Nivedan Nasina Posted December 16, 2020 Author Share Posted December 16, 2020 I tried a lot of things and finally looks like the following script works: If anyone finds any issues with this script or knows of a better approach please let me know. ################################################ from Spotfire.Dxp.Application.Visuals import * from Spotfire.Dxp.Application.Visuals.FittingModels import * from Spotfire.Dxp.Application.Extension import * from System.Drawing import * from Spotfire.Dxp.Data import * from System.Collections.Generic import List from Spotfire.Dxp.Application.Visuals import * from System.Drawing import * #Color from Spotfire.Dxp.Application.Visuals.ConditionalColoring import * #Coloring, ContinuousColorRule ,ConditionValue,IntervalMode #Get a reference to the current visualization sp1 = Viz.As[scatterPlot]() colorRule = sp1.ColorAxis.Coloring.Clear() sp1.ColorAxis.Expression = "[col_name]" sp1.ColorAxis.Coloring.AddThresholdColorRule(RuleComparisonOperator.LessOrEqual,ConditionValue.MinValue,Color.FromName("Red")) sp1.ColorAxis.Coloring.AddThresholdColorRule(RuleComparisonOperator.GreaterOrEqual,ConditionValue.MaxValue,Color.FromName("Green")) sp1.ColorAxis.Coloring.EmptyColor = Color.Black sp1.ColorAxis.Coloring.DefaultColor = Color.Black ################################################ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now