parameters: (revision_map, tests)
return_statement: return json.dumps(
        {
            'data': cols,
            'annotations': flot_annotations,
            'error_bars': error_bars,
        },
        allow_nan=False)
docstring: Constructs JSON in the format expected by Flot.
  
    Args:
      revision_map: A dict which maps revision numbers to data point info.
      tests: A list of TestMetadata entities.
  
    Returns:
      JSON serialization of a dict with line data, annotations, error range data,
      (This data may not be passed exactly as-is to the Flot plot function, but
      it will all be used when plotting.)
docstring_summary: Constructs JSON in the format expected by Flot.
docstring_tokens: Constructs JSON in the format expected by Flot .
function: def _GetFlotJson(revision_map, tests):
    """Constructs JSON in the format expected by Flot.
  
    Args:
      revision_map: A dict which maps revision numbers to data point info.
      tests: A list of TestMetadata entities.
  
    Returns:
      JSON serialization of a dict with line data, annotations, error range data,
      (This data may not be passed exactly as-is to the Flot plot function, but
      it will all be used when plotting.)
    """
    # TODO(qyearsley): Break this function into smaller functions.
  
    # Each entry in the following dict is one Flot series object. The actual
    # x-y values will be put into the 'data' properties for each object.
    cols = {i: _FlotSeries(i) for i in range(len(tests))}
  
    flot_annotations = {}
    flot_annotations['series'] = _GetSeriesAnnotations(tests)
  
    # For each TestMetadata (which corresponds to a trace line), the shaded error
    # region is specified by two series objects. For a demo, see:
    # http://www.flotcharts.org/flot/examples/percentiles/index.html
    error_bars = {x: [
        {
            'id': 'bottom_%d' % x,
            'data': [],
            'color': x,
            'clickable': False,
            'hoverable': False,
            'lines': {
                'show': True,
                'lineWidth': 0,
                'fill': 0.2,
            },
            'fillBetween': 'line_%d' % x,
        },
        {
            'id': 'top_%d' % x,
            'data': [],
            'color': x,
            'clickable': False,
            'hoverable': False,
            'lines': {
                'show': True,
                'lineWidth': 0,
                'fill': 0.2,
            },
            'fillBetween': 'line_%d' % x,
        }
    ] for x, _ in enumerate(tests)}
  
    test_keys = [t.key.urlsafe() for t in tests]
    for revision in sorted(revision_map.keys()):
      for series_index, key in enumerate(test_keys):
        point_info = revision_map[revision].get(key, None)
        if not point_info:
          continue
  
        timestamp = point_info.get('timestamp')
        if timestamp and type(timestamp) is datetime.datetime:
          point_info['timestamp'] = utils.TimestampMilliseconds(timestamp)
  
        point_list = [revision, point_info['value']]
        if 'error' in point_info:
          error = point_info['error']
          error_bars[series_index][0]['data'].append(
              [revision, point_info['value'] - error])
          error_bars[series_index][1]['data'].append(
              [revision, point_info['value'] + error])
        cols[series_index]['data'].append(point_list)
        data_index = len(cols[series_index]['data']) - 1
        series_dict = flot_annotations.setdefault(series_index, {})
        data_dict = copy.deepcopy(point_info)
        del data_dict['value']
        series_dict.setdefault(data_index, data_dict)
  
    return json.dumps(
        {
            'data': cols,
            'annotations': flot_annotations,
            'error_bars': error_bars,
        },
        allow_nan=False)
function_tokens: def _GetFlotJson ( revision_map , tests ) : # TODO(qyearsley): Break this function into smaller functions. # Each entry in the following dict is one Flot series object. The actual # x-y values will be put into the 'data' properties for each object. cols = { i : _FlotSeries ( i ) for i in range ( len ( tests ) ) } flot_annotations = { } flot_annotations [ 'series' ] = _GetSeriesAnnotations ( tests ) # For each TestMetadata (which corresponds to a trace line), the shaded error # region is specified by two series objects. For a demo, see: # http://www.flotcharts.org/flot/examples/percentiles/index.html error_bars = { x : [ { 'id' : 'bottom_%d' % x , 'data' : [ ] , 'color' : x , 'clickable' : False , 'hoverable' : False , 'lines' : { 'show' : True , 'lineWidth' : 0 , 'fill' : 0.2 , } , 'fillBetween' : 'line_%d' % x , } , { 'id' : 'top_%d' % x , 'data' : [ ] , 'color' : x , 'clickable' : False , 'hoverable' : False , 'lines' : { 'show' : True , 'lineWidth' : 0 , 'fill' : 0.2 , } , 'fillBetween' : 'line_%d' % x , } ] for x , _ in enumerate ( tests ) } test_keys = [ t . key . urlsafe ( ) for t in tests ] for revision in sorted ( revision_map . keys ( ) ) : for series_index , key in enumerate ( test_keys ) : point_info = revision_map [ revision ] . get ( key , None ) if not point_info : continue timestamp = point_info . get ( 'timestamp' ) if timestamp and type ( timestamp ) is datetime . datetime : point_info [ 'timestamp' ] = utils . TimestampMilliseconds ( timestamp ) point_list = [ revision , point_info [ 'value' ] ] if 'error' in point_info : error = point_info [ 'error' ] error_bars [ series_index ] [ 0 ] [ 'data' ] . append ( [ revision , point_info [ 'value' ] - error ] ) error_bars [ series_index ] [ 1 ] [ 'data' ] . append ( [ revision , point_info [ 'value' ] + error ] ) cols [ series_index ] [ 'data' ] . append ( point_list ) data_index = len ( cols [ series_index ] [ 'data' ] ) - 1 series_dict = flot_annotations . setdefault ( series_index , { } ) data_dict = copy . deepcopy ( point_info ) del data_dict [ 'value' ] series_dict . setdefault ( data_index , data_dict ) return json . dumps ( { 'data' : cols , 'annotations' : flot_annotations , 'error_bars' : error_bars , } , allow_nan = False )