I am creating graphs using arcpy and facing this error while I give the input layer from the mxd.
In case, if I give the input from direct shapefile, then graphs are generated. Kindness is required in this issue. The code I have written is given by:
import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument(relpath + r"\map.mxd")
index_layer1 = arcpy.mapping.ListLayers(mxd, "Index_Layer")[0]
input_data = "E:\Python\Utility\map data\Index_Layer.shp"
required_graphs = ['NCI_2011_', 'N_SI_2011_', 'N_IDDI_201', 'N_IDDI_202', 'N_CI_2014_', 'N_SI_2014_', 'N_IDDI_203']
input_template = "E:\Python\Utility\graphs\sample.grf"
#Getting required graphs
for x in required_graphs:
print "Creating graph of " + x
# Create the graph
graph = arcpy.Graph()
# Add a horizontal bar series to the graph
graph.addSeriesBarHorizontal(index_layer1, x)
# Specify the title of the left axis
out_graph_bmp = "E:/Python\Utility/graphs/_{}".format(x) +".jpg"
graph.graphAxis[0].title = ""
# Specify the title of the bottom axis
graph.graphAxis[2].title = ""
# Specify the title of the Graph
graph.graphPropsGeneral.title = x
# Output a graph, which is created in-memory
arcpy.MakeGraph_management(input_template, graph, "graph_{}".format(x))
# Save the graph as an image
arcpy.SaveGraph_management("graph_{}".format(x), out_graph_bmp, "IGNORE_ASPECT_RATIO", 592, 1388)