AnsweredAssumed Answered

Seeking Assistance with Class Labels for My Portal - NaturalBreaks

Question asked by QuestDiagnostics on Jun 2, 2020
Latest reply on Jun 22, 2020 by QuestDiagnostics

Hello,

 

I am trying to publish a few layers from an .aprx to My Portal.  I have a graduated color renderer classified by Natural Breaks.  I'd like the symbology for lyr3 listed below to display on My Portal as currency format, and I am unsure of how to change the format from the integer value here to currency.  I'd like to have it published as currency as an automated task and not have to reset values in the Portal web map each time the .aprx is shared to Portal.  Please see my sample code here.  Any assistance would be greatly appreciated!

 

Here is how the layer appears in my Web Map in Portal, and I'd like this format to change to currency with no decminals:

 

import arcpy
import os
import locale
from arcpy import env
import xml.dom.minidom as DOM
arcpy.env.overwriteOutput = True

p = arcpy.mp.ArcGISProject(r"C:\Data\test_pro_projects\Commercial_Analytics_0527\Commercial_Analytics_0527.aprx")

m = p.listMaps ("Map") [0]
##lyt = p.listLayouts("Layout")[0]
lyr = m.listLayers("Pct_Req_Change")[0]
sym = lyr.symbology
sym.updateRenderer('GraduatedColorsRenderer')
sym.renderer.classificationField = 'Pct_Req_Change'
sym.renderer.breakCount = 5
sym.renderer.classificationMethod = "NaturalBreaks"
sym.renderer.colorRamp = p.listColorRamps('Aspect')[0]
lyr.symbology = sym
for lyr in m.listLayers("Pct_Req_Change"):
lyr.visible = True
lyr1 = m.listLayers("Delta_Req_Change")[0]
sym1 = lyr1.symbology
sym1.updateRenderer('GraduatedColorsRenderer')
sym1.renderer.classificationField = 'Delta_Req_Change'
sym.renderer.classificationMethod = "NaturalBreaks"
sym1.renderer.breakCount = 5
sym1.renderer.colorRamp = p.listColorRamps('Aspect')[0]
lyr1.symbology = sym1
for lyr1 in m.listLayers("Delta_Req_Change"):
lyr1.visible = True
lyr2 = m.listLayers("Rev_Pct_Change")[0]
sym2 = lyr2.symbology
sym2.updateRenderer('GraduatedColorsRenderer')
sym2.renderer.classificationField = 'Rev_Pct_Change'
sym.renderer.classificationMethod = "NaturalBreaks"
sym2.renderer.breakCount = 5
sym2.renderer.colorRamp = p.listColorRamps('Aspect')[0]
lyr2.symbology = sym2
for lyr2 in m.listLayers("Rev_Pct_Change"):
lyr2.visible = True
lyr3 = m.listLayers("Revenue_Change")[0]
sym3 = lyr3.symbology
sym3.updateRenderer('GraduatedColorsRenderer')
sym3.renderer.classificationField = 'Revenue_Change'
sym.renderer.classificationMethod = "NaturalBreaks"
sym3.renderer.breakCount = 5
sym3.renderer.colorRamp = p.listColorRamps('Aspect')[0]
lyr3.symbology = sym3
for lyr3 in m.listLayers("Revenue_Change"):
lyr3.visible = True
p.save()

# Set output file names
outdir = r"C:\Data\test_pro_projects\Commercial_Analytics_0527"
service = "CommPerf_0527_MIL1"
sddraft_filename = service + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)

# Reference map to publish
m = p.listMaps("Map")[0]
lyrs = []
lyrs.append(m.listLayers('Pct_Req_Change')[0])
lyrs.append(m.listLayers('Delta_Req_Change')[0])
lyrs.append(m.listLayers('Rev_Pct_Change')[0])
lyrs.append(m.listLayers('Revenue_Change')[0])
# Create TileSharingDraft and set service properties
sharing_draft = m.getWebLayerSharingDraft("FEDERATED_SERVER", "MAP_IMAGE", service, lyrs)
sharing_draft.federatedServerUrl = "https://esri.foo.com/arcgis"
sharing_draft.summary = "My Summary"
sharing_draft.tags = "My Tags"
sharing_draft.description = "My Description"

# Create Service Definition Draft file
sharing_draft.exportToSDDraft(sddraft_output_filename)


# set service type to esriServiceDefinitionType_Replacement
newType = 'esriServiceDefinitionType_Replacement'
xml = r"C:\Data\test_pro_projects\Commercial_Analytics_0527\CommPerf_0527_MIL1.sddraft"
doc = DOM.parse(xml)
descriptions = doc.getElementsByTagName('Type')
for desc in descriptions:
if desc.parentNode.tagName == 'SVCManifest':
if desc.hasChildNodes():
desc.firstChild.data = newType
outXml = xml
f = open(outXml, 'w')
doc.writexml( f )
f.close()

# Stage Service
arcpy.server.StageService(r"C:\Data\test_pro_projects\Commercial_Analytics_0527\CommPerf_0527_MIL1.sddraft", r"C:\Data\test_pro_projects\Commercial_Analytics_0527\CommPerf_0527_MIL1.sd", None)

# Share to portal
print("Uploading Service Definition...")
arcpy.UploadServiceDefinition_server(r"C:\Data\test_pro_projects\Commercial_Analytics_0527\CommPerf_0527_MIL1.sd", "arcgis on esri.foo.com.ags")

print("Successfully Uploaded service.")

del p, lyr

Outcomes