def EncodeData(chart, series, y_min, y_max, encoder):
  """Format the given data series in plain or extended format.

  Use the chart's encoder to determine the format. The formatted data will
  be scaled to fit within the range of values supported by the chosen
  encoding.

  Args:
    chart: The chart.
    series: A list of the the data series to format; each list element is
           a list of data points.
    y_min: Minimum data value. May be None if y_max is also None
    y_max: Maximum data value. May be None if y_min is also None
  Returns:
    A dictionary with one key, 'data', whose value is the fully encoded series.
  """
  assert (y_min is None) == (y_max is None)
  if y_min is not None:
    def _ScaleAndEncode(series):
      series = ScaleData(series, y_min, y_max, encoder.min, encoder.max)
      return encoder.Encode(series)
    encoded_series = [_ScaleAndEncode(s) for s in series]
  else:
    encoded_series = [encoder.Encode(s) for s in series]
  result = JoinLists(**{'data': encoded_series})
  result['data'] = encoder.prefix + result['data']
  return result
Format the given data series in plain or extended format.

  Use the chart's encoder to determine the format. The formatted data will
  be scaled to fit within the range of values supported by the chosen
  encoding.

  Args:
    chart: The chart.
    series: A list of the the data series to format; each list element is
           a list of data points.
    y_min: Minimum data value. May be None if y_max is also None
    y_max: Maximum data value. May be None if y_min is also None
  Returns:
    A dictionary with one key, 'data', whose value is the fully encoded series.
  
mapreduce/lib/graphy/backends/google_chart_api/util.py