Script to set a predefined Document Color Scheme to a map chart layer

I have set a few marker layers on my map to change the "color by" according to a property that is connected to a listbox.  The listbox contains different column names I'd like to color by.  However, each time I choose a different column, the Document Color Scheme that I had originally designated changes to a default color scheme.

I am using the following script to run each time I select a new column in the listbox in order to set the "color by" back to my predefined Document Color Scheme.

Note: My predefined color scheme is called "Operator".  "vis" is a script parameter refering to my map visualization.  Layers 5 and 6 are both marker layers and need the color scheme applied to them.  Layers 0 through 4 are WMS layers.  If there is an easy way to loop through each layer instead of specifically referring to 5 and 6, that would also be appreciated.

 

from Spotfire.Dxp.Application.Visuals.Maps import *
from System.Drawing import Color
ChartVis = vis.As[MapChart]()
ChartVis.Layers[6].As[FeatureLayerVisualization]().ColorAxis.Coloring[6].Apply(Document.ColoringTemplates["Operator"])

Error: Traceback (most recent call last):
  File "Spotfire.Dxp.Application.ScriptSupport", line unknown, in ExecuteForDebugging
  File "<string>", line 4, in <module>
AttributeError: 'NoneType' object has no attribute 'ColorAxis'

 

I also tried substituting the 4th line with the following:

MapVis.Layers[6].ColorAxis.Coloring[6].Apply(Document.ColoringTemplates["Operator"])

Error: Traceback (most recent call last):
  File "Spotfire.Dxp.Application.ScriptSupport", line unknown, in ExecuteForDebugging
  File "<string>", line 4, in <module>
AttributeError: 'MapChartDataLayer' object has no attribute 'ColorAxis'

 

Any ideas?

Thanks

(2) Answers

Login