import arcpy import pythonaddins class Selection(object): """Implementation for SelectAllButton_addin.button (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): # Select all features (in Test there are no features with FID 0). arcpy.SelectLayerByAttribute_management ("XYMin_Max_Avg_Temp_with_Lat_Long","NEW_SELECTION","Station_Id"<>'0') pass
# your map obj, based on an input pathname: mxd = arcpy.mapping.MapDocument(r'your mxd pathname goes here') # fetching the row obj of your current DDP index page: currentRow = mxd.dataDrivenPages.pageRow
currentStation = currentRow.Station_ID
# 'TSR' is the fieldname the value is fetched from in this case fieldValue = mxd.dataDrivenPages.pageRow.TSR
# Modify bar chart his2000 = float(mxd.dataDrivenPages.pageRow.HisPer2000) bar1.elementHeight = (his2000 / 50)*2 bar1txt.text = "(" + str(round(his2000, 2)) + ")" bar1txt.elementPositionY = bar1.elementPositionY + bar1.elementHeight + 0.1 # comment I added: # 2nd bar element modified, same line formatting as above 4 lines his2010 = float(mxd.dataDrivenPages.pageRow.HisPer2010) bar2.elementHeight = (his2010 / 50)*2 bar2txt.text = "(" + str(round(his2010, 2)) + ")" bar2txt.elementPositionY = bar2.elementPositionY + bar2.elementHeight + 0.1
#Loop through each DDP page for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
.... So it seems you need something to 'reselect' the records based on the page definition; .... It seems the problem is the graph will update only based on a selection ....
import arcpy import pythonaddins class ExtensionClass1(object): """Implementation for testAddIn_addin.extension2 (Extension)""" def __init__(self): self.enabled = True def beforePageIndexExtentChange(self, old_id): if self.enabled == False: self.enabled = True pass def pageIndexExtentChanged(self, new_id): if self.enabled: mxd = arcpy.mapping.MapDocument("Current") df = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.ListLayers(mxd, 'tempsStation', df)[0] arcpy.SelectLayerByLocation_management(lyr, '', '', '', 'SWITCH_SELECTION') self.enabled = False pass
arcpy.SelectLayerByAttribute_management ("LayerWithGraphInfo","NEW_SELECTION","IndexID<>0")
arcpy.SelectLayerByLocation_management(lyr, '', '', '', 'SWITCH_SELECTION')
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.