code: def retrieve_chart_data(df, *args, **kwargs):
      """
      Retrieves data from a dataframe for x, y, z & group inputs complete with date frequency
      formatting (:meth:`dtale.charts.utils.date_freq_handler`) if specified
  
      :param df: dataframe that contains data for chart
      :type df: :class:`pandas:pandas.DataFrame`
      :param args: columns to use
      :type args: iterable of str
      :return: dataframe of data required for chart construction
      :rtype: :class:`pandas:pandas.DataFrame`
      """
      freq_handler = date_freq_handler(df)
      cols = flatten_lists([make_list(a) for a in args])
      all_code = []
      all_data = []
  
      if INDEX_COL in cols:
          cols = [col for col in cols if col != INDEX_COL]
          all_data.append(
              pd.Series(df.index, index=df.index, name="__index__")
          )
          all_code.append(
              "\tpd.Series(df.index, index=df.index, name='{}'),".format(
                  INDEX_COL
              )
          )
  
      for col in cols:
          if col is not None:
              s, code = freq_handler(col)
              all_data.append(s)
              if code is not None:
                  all_code.append(code)
      all_data = pd.concat(all_data, axis=1)
      all_code = (
          ["chart_data = pd.concat(["] + all_code + ["], axis=1)"]
      )
      if len(make_list(kwargs.get("group_val"))):
          filters, labels = build_group_inputs_filter(
              all_data, kwargs["group_val"]
          )
          all_data = run_query(all_data, filters)
          all_code.append(
              "chart_data = chart_data.query({})".format(
                  triple_quote(filters)
              )
          )
      return all_data, all_code
  
imports: import copy
  import numpy
  import pandas
  import dtale.global_state
  import dtale.pandas_util
  from dtale.column_analysis import handle_cleaners
  from dtale.constants import CHART_JOINER_CHAR
  from dtale.query import build_col_key, run_query
  from dtale.utils import ChartBuildingError, build_formatters, classify_type, find_dtype, find_dtype_formatter, flatten_lists, get_dtypes, json_int, make_list, triple_quote
label_desc: Use image node_id 8 for calling a global function with example usage: retrieve_chart_data(df) and returns: all_data,  all_code