class_docstr: The query context contains the query object and additional fields necessary
  to retrieve the data payload for a given viz.
class_docstr_tok: ["The","query","context","contains","the","query","object","and","additional","fields","necessary","to","retrieve","the","data","payload","for","a","given","viz","."]
code: def get_viz_annotation_data(
      annotation_layer: dict[str, Any], force: bool
  ) -> dict[str, Any]:
      # pylint: disable=import-outside-toplevel
      from superset.commands.chart.data.get_data_command import (
          ChartDataCommand,
      )
  
      if not (chart := ChartDAO.find_by_id(annotation_layer["value"])):
          raise QueryObjectValidationError(
              _("The chart does not exist")
          )
  
      try:
          if chart.viz_type in viz_types:
              if not chart.datasource:
                  raise QueryObjectValidationError(
                      _("The chart datasource does not exist"),
                  )
  
              form_data = chart.form_data.copy()
              form_data.update(annotation_layer.get("overrides", {}))
  
              payload = get_viz(
                  datasource_type=chart.datasource.type,
                  datasource_id=chart.datasource.id,
                  form_data=form_data,
                  force=force,
              ).get_payload()
  
              return payload["data"]
  
          if not (query_context := chart.get_query_context()):
              raise QueryObjectValidationError(
                  _("The chart query context does not exist"),
              )
  
          if overrides := annotation_layer.get("overrides"):
              if time_grain_sqla := overrides.get("time_grain_sqla"):
                  for query_object in query_context.queries:
                      query_object.extras[
                          "time_grain_sqla"
                      ] = time_grain_sqla
  
              if time_range := overrides.get("time_range"):
                  from_dttm, to_dttm = get_since_until_from_time_range(
                      time_range
                  )
  
                  for query_object in query_context.queries:
                      query_object.from_dttm = from_dttm
                      query_object.to_dttm = to_dttm
  
          query_context.force = force
          command = ChartDataCommand(query_context)
          command.validate()
          payload = command.run()
          return {"records": payload["queries"][0]["data"]}
      except SupersetException as ex:
          raise QueryObjectValidationError(
              error_msg_from_exception(ex)
          ) from ex
  
imports: from __future__ import annotations
  import copy
  import logging
  import re
  from typing import Any, ClassVar, TYPE_CHECKING, TypedDict
  import numpy
  import pandas
  from flask_babel import gettext
  from pandas import DateOffset
  from superset import app
  from superset.common.chart_data import ChartDataResultFormat
  from superset.common.db_query_status import QueryStatus
  from superset.common.query_actions import get_query_results
  from superset.common.utils import dataframe_utils
  from superset.common.utils.query_cache_manager import QueryCacheManager
  from superset.common.utils.time_range_utils import get_since_until_from_query_object, get_since_until_from_time_range
  from superset.connectors.sqla.models import BaseDatasource
  from superset.constants import CacheRegion, TimeGrain
  from superset.daos.annotation_layer import AnnotationLayerDAO
  from superset.daos.chart import ChartDAO
  from superset.exceptions import InvalidPostProcessingError, QueryObjectValidationError, SupersetException
  from superset.extensions import cache_manager, security_manager
  from superset.models.helpers import QueryResult
  from superset.models.sql_lab import Query
  from superset.utils import csv, excel
  from superset.utils.cache import generate_cache_key, set_and_log_cache
  from superset.utils.core import DatasourceType, DateColumn, DTTM_ALIAS, error_msg_from_exception, get_base_axis_labels, get_column_names_from_columns, get_column_names_from_metrics, get_metric_names, get_xaxis_label, normalize_dttm_col, TIME_COMPARISON
  from superset.utils.date_parser import get_past_or_future, normalize_time_delta
  from superset.utils.pandas_postprocessing.utils import unescape_separator
  from superset.views.utils import get_viz
  from superset.viz import viz_types
label_desc: Use image node_id 16 for calling the QueryContextProcessor obj's underlying member method code with example usage: obj.get_viz_annotation_data(annotation_layer, force) and returns: dict, payload