AnsweredAssumed Answered

How to add charts via arcpy in Pro

Question asked by twhiteaker on May 11, 2020

I made a Python toolbox with a simple tool for testing arcpy's charting functionality in Pro.  I'm trying to plot a line chart from these data, which I imported into a geodatabase as a table:




I have a map named "Map" with the above table as the first table in the map.  Here's the tool class's execute method:


def execute(self, parameters, messages):
    aprx ="current")
    map = aprx.listMaps("Map")[0]
    table = map.listTables()[0]

    c = arcpy.Chart('MyChart')
    c.type = 'line'
    c.xAxis.field = 'x'
    c.yAxis.field = 'y'




When I run the tool, a chart is added as shown below the table in the Table of Contents, but when I open the chart, instead of a chart I see "Select Variable(s) in the Chart Properties pane to begin".  But the chart properties pane does show the variables selected.



If I uncheck and then re-check "y" in the numeric fields list and click Apply, nothing happens.  If I right-click the table to manually create a new chart, the chart previously created by my GP tool disappears.