def GetChartsFromBenchmarkResultJson(benchmark_result_json):
  """Returns the 'charts' element from a given Chart JSON.

  Excludes entries that are not list_of_scalar_values and empty entries. Also
  raises errors for an invalid JSON format or empty 'charts' element.

  Raises:
    ValueError: Provided chart JSON is either not valid or 'charts' is empty.
  """
  try:
    charts = benchmark_result_json['charts']
  except KeyError:
    raise ValueError('Invalid benchmark result format. Make sure input is a '
                     'Chart-JSON.\nProvided JSON:\n',
                     repr(benchmark_result_json))
  if not charts:
    raise ValueError("Invalid benchmark result format. Dict entry 'charts' is "
                     "empty.")

  def IsValidPageContent(page_content):
    return (page_content['type'] == 'list_of_scalar_values' and
            'values' in page_content)

  def CreatePageDict(metric_content):
    return {page_name: page_content
            for page_name, page_content in metric_content.iteritems()
            if IsValidPageContent(page_content)}

  charts_valid_entries_only = {}
  for metric_name, metric_content in charts.iteritems():
    inner_page_dict = CreatePageDict(metric_content)
    if not inner_page_dict:
      continue
    charts_valid_entries_only[metric_name] = inner_page_dict

  return charts_valid_entries_only