#NEWLINE# def label_from_index_dict( chart_index , include_cols = False ) : #NEWLINE# #INDENT# '\n\n    Args:\n        chart_index (dict(str, any) or str or None): identifier for the data group,\n            representing either the value of a column (str), no grouping (None), or a dict\n            where each key represents a column, and the value is the unique value.\n\n    Returns:\n        str: a derived label representing the chart index value\n\n    ' #NEWLINE# if isinstance ( chart_index , str ) : #NEWLINE# #INDENT# return chart_index #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( chart_index is None ) : #NEWLINE# #INDENT# return 'None' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( chart_index , dict ) : #NEWLINE# #INDENT# if include_cols : #NEWLINE# #INDENT# label = ', ' . join ( [ ( '%s=%s' % ( col , val ) ) for ( col , val ) in iteritems ( chart_index ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# label = tuple ( chart_index . values ( ) ) #NEWLINE# if ( len ( label ) == 1 ) : #NEWLINE# #INDENT# label = label [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# return label #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'chart_index type is not recognized,                           received %s' % type ( chart_index ) ) )