code: def charts_layout(df, settings, **inputs):
      """
      Builds main dash inputs with dropdown options populated with the columns of the dataframe associated with the
      page. Inputs included are: chart tabs, query, x, y, z, group, aggregation, rolling window/computation,
      chart per group toggle, bar sort, bar mode, y-axis range editors
  
      :param df: dataframe to drive the charts built on page
      :type df: :class:`pandas:pandas.DataFrame`
      :param settings: global settings associated with this dataframe (contains properties like "query")
      :type param: dict
      :return: dash markup
      """
      (
          chart_type,
          x,
          y,
          z,
          group,
          dropna,
          agg,
          load,
          load_type,
          stratified_group,
      ) = (
          inputs.get(p)
          for p in [
              "chart_type",
              "x",
              "y",
              "z",
              "group",
              "dropna",
              "agg",
              "load",
              "load_type",
              "stratified_group",
          ]
      )
      loc_modes = loc_mode_info()
      y = y or []
      show_input = show_input_handler(chart_type)
      show_cpg = show_chart_per_group(**inputs)
      show_cpy = show_chart_per_y(**inputs)
      show_yaxis = show_yaxis_ranges(**inputs)
      scatter_input = dict(
          display="block" if chart_type == "scatter" else "none"
      )
      bar_style, barsort_input_style = bar_input_style(**inputs)
      animate_style, animate_by_style, animate_opts = animate_styles(
          df, **inputs
      )
  
      options = build_input_options(df, **inputs)
      (
          x_options,
          y_multi_options,
          y_single_options,
          z_options,
          group_options,
          barsort_options,
          yaxis_options,
          stratified_groups,
      ) = options
      query_placeholder = "{} (ex: col1 == 1)".format(
          text("Enter pandas query")
      )
      query_value = inputs.get("query") or inner_build_query(
          settings, settings.get("query")
      )
  
      query_label = html.Div(
          [
              html.Span(text("Query")),
              html.A(
                  html.I(className="fa fa-info-circle ml-4"),
                  href="https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#indexing-query",
                  target="_blank",
                  style={"color": "white"},
              ),
          ],
          className="input-group-addon",
          style={"minWidth": "7em"},
      )
      yaxis_type = (inputs.get("yaxis") or {}).get("type") or "default"
      yaxis_type_style = (
          {"borderRadius": "0 0.25rem 0.25rem 0"}
          if yaxis_type == "default"
          else None
      )
      show_map = chart_type == "maps"
      map_props = [
          "map_type",
          "loc_mode",
          "loc",
          "lat",
          "lon",
          "map_val",
      ]
      map_type, loc_mode, loc, lat, lon, map_val = (
          inputs.get(p) for p in map_props
      )
      map_scope, proj, mapbox_style = (
          inputs.get(p) for p in ["scope", "proj", "mapbox_style"]
      )
      (
          loc_options,
          lat_options,
          lon_options,
          map_val_options,
      ) = build_map_options(
          df, type=map_type, loc=loc, lat=lat, lon=lon, map_val=map_val
      )
      show_candlestick = chart_type == "candlestick"
      cs_props = [
          "cs_x",
          "cs_open",
          "cs_close",
          "cs_high",
          "cs_low",
          "cs_group",
          "cs_dropna",
      ]
      cs_x, cs_open, cs_close, cs_high, cs_low, cs_group, cs_dropna = (
          inputs.get(p) for p in cs_props
      )
      (
          cs_x_options,
          open_options,
          close_options,
          high_options,
          low_options,
      ) = build_candlestick_options(
          df,
          cs_x=cs_x,
          cs_open=cs_open,
          cs_close=cs_close,
          cs_high=cs_high,
          cs_low=cs_low,
      )
      cscale_style = colorscale_input_style(**inputs)
      default_cscale = DEFAULT_CSALES.get(chart_type, REDS)
  
      (
          group_type_style,
          group_val_style,
          bins_style,
          main_input_class,
          show_groups,
      ) = main_inputs_and_group_val_display(inputs)
      group_val = [
          json.dumps(gv) for gv in inputs.get("group_val") or []
      ]
  
      def show_map_style(show):
          return {} if show else {"display": "none"}
  
      body_items = [
          dcc.Store(id="query-data", data=query_value),
          dcc.Store(
              id="input-data",
              data={
                  k: v
                  for k, v in inputs.items()
                  if k not in ["cpg", "cpy", "barmode", "barsort"]
              },
          ),
          dcc.Store(
              id="chart-input-data",
              data={
                  k: v
                  for k, v in inputs.items()
                  if k in ["cpg", "cpy", "barmode", "barsort"]
              },
          ),
          dcc.Store(
              id="map-input-data",
              data={
                  k: v
                  for k, v in inputs.items()
                  if k
                  in [
                      "map_type",
                      "map_code",
                      "loc_mode",
                      "lat",
                      "lon",
                      "map_val",
                      "scope",
                      "proj",
                  ]
              },
          ),
          dcc.Store(
              id="candlestick-input-data",
              data={
                  k: v
                  for k, v in inputs.items()
                  if k
                  in [
                      "cs_x",
                      "cs_open",
                      "cs_close",
                      "cs_high",
                      "cs_low",
                      "cs_group",
                  ]
              },
          ),
          build_label_value_store("treemap", inputs),
          build_label_value_store("funnel", inputs),
          build_label_value_store("clustergram", inputs),
          dcc.Store(
              id="pareto-input-data",
              data={
                  k: v
                  for k, v in inputs.items()
                  if k
                  in [
                      "pareto_x",
                      "pareto_bars",
                      "pareto_line",
                      "pareto_sort",
                      "pareto_dir",
                      "pareto_group",
                  ]
              },
          ),
          dcc.Store(
              id="histogram-input-data",
              data={
                  k: v
                  for k, v in inputs.items()
                  if k
                  in [
                      "histogram_col",
                      "histogram_type",
                      "histogram_bins",
                      "histogram_group",
                  ]
              },
          ),
          dcc.Store(id="range-data"),
          dcc.Store(id="yaxis-data", data=inputs.get("yaxis")),
          dcc.Store(id="last-chart-input-data", data=inputs),
          dcc.Store(id="load-clicks", data=0),
          dcc.Store(id="save-clicks", data=0),
          dcc.Input(id="chart-code", type="hidden"),
          html.Div(
              [
                  html.Div(
                      dbc.Button(
                          collapse_btn_text(
                              False, text("Data Selection")
                          ),
                          id="collapse-data-btn",
                      ),
                      className="col-auto pr-0",
                  ),
                  html.Div(
                      dbc.Collapse(
                          dbc.Card(
                              dbc.CardBody(
                                  [
                                      dcc.Tabs(
                                          id="data-tabs",
                                          value=inputs["data_id"],
                                          children=[
                                              build_tab(
                                                  global_state.get_name(
                                                      k
                                                  )
                                                  or k,
                                                  str(k),
                                                  id="data-tab-{}".format(
                                                      k
                                                  ),
                                              )
                                              for k in global_state.keys()
                                          ],
                                          style=dict(height="36px"),
                                      )
                                  ]
                                  + [
                                      dbc.Tooltip(
                                          global_state.get_name(k) or k,
                                          target="data-tab-{}".format(
                                              k
                                          ),
                                      )
                                      for k in global_state.keys()
                                  ]
                              )
                          ),
                          id="collapse-data",
                      ),
                      className="col",
                  ),
              ],
              className="row pb-3 charts-filters",
              style=dict(
                  display="none"
                  if len(global_state.keys()) < 2
                  else "block"
              ),
          ),
          html.Div(
              html.Div(
                  [
                      dcc.Tabs(
                          id="chart-tabs",
                          value=chart_type or "line",
                          children=[
                              build_tab(
                                  text(
                                      t.get(
                                          "label",
                                          t["value"].capitalize(),
                                      )
                                  ),
                                  t["value"],
                                  id="chart-type-tab-{}".format(i),
                              )
                              for i, t in enumerate(CHARTS)
                          ],
                          style=dict(height="36px"),
                      )
                  ]
                  + [
                      dbc.Tooltip(
                          text(t.get("label", t["value"].capitalize())),
                          target="chart-type-tab-{}".format(i),
                      )
                      for i, t in enumerate(CHARTS)
                  ],
                  className="col-md-12",
              ),
              className="row pt-3 pb-3 charts-filters",
          ),
          html.Div(
              html.Div(
                  [
                      html.Div(
                          [
                              query_label,
                              dcc.Input(
                                  id="query-input",
                                  type="text",
                                  placeholder=query_placeholder,
                                  className="form-control",
                                  value=query_value,
                                  style={"lineHeight": "inherit"},
                              ),
                          ],
                          className="input-group mr-3",
                      )
                  ],
                  className="col",
              ),
              className="row pt-3 pb-3 charts-filters",
          ),
          html.Div(
              html.Div(
                  [
                      html.Div(
                          [
                              build_hoverable(
                                  html.Span(text("Load")),
                                  load_type_msg(),
                                  additional_classes="load-types-tooltip mb-auto mt-auto",
                                  top="100%",
                              ),
                              dcc.Dropdown(
                                  id="load-type-dropdown",
                                  options=[
                                      build_option(v, v.capitalize())
                                      for v in LOAD_TYPES
                                  ],
                                  className="pl-5",
                                  value=load_type or "random",
                                  clearable=False,
                              ),
                              dcc.Dropdown(
                                  id="stratified-group-dropdown",
                                  options=stratified_groups,
                                  value=stratified_group,
                                  clearable=False,
                                  style={}
                                  if load_type == "stratified"
                                  else {"display": "none"},
                              ),
                              dcc.Slider(
                                  id="load-input",
                                  min=10,
                                  max=100,
                                  step=10,
                                  value=100 if load is None else load,
                                  className="w-100",
                                  marks=build_slider_counts(
                                      df, inputs["data_id"], query_value
                                  ),
                                  tooltip={
                                      "always_visible": False,
                                      "placement": "left",
                                  },
                              ),
                          ],
                          className="input-group mr-3",
                      )
                  ],
                  className="col",
              ),
              className="row pt-3 pb-0 charts-filters",
          ),
          html.Div(
              [
                  html.Div(
                      [
                          dbc.Button(
                              collapse_btn_text(
                                  False, text("Cleaners")
                              ),
                              id="collapse-cleaners-btn",
                          ),
                          html.Span(
                              "",
                              id="selected-cleaners",
                              className="pl-3",
                              style=dict(fontSize="85%"),
                          ),
                      ],
                      className="col-auto pr-0",
                  ),
                  html.Div(
                      dbc.Collapse(
                          dbc.Card(
                              dbc.CardBody(
                                  dcc.Dropdown(
                                      id="cleaners-dropdown",
                                      options=[
                                          build_option(
                                              c["value"], c["label"]
                                          )
                                          for c in get_cleaner_configs()
                                      ],
                                      multi=True,
                                      placeholder=text(
                                          "Select Cleaner(s)"
                                      ),
                                      value=group,
                                      style=dict(width="inherit"),
                                  )
                              )
                          ),
                          id="collapse-cleaners",
                      ),
                      className="col",
                  ),
              ],
              className="row pb-3 charts-filters",
              style=dict(display="block"),
          ),
          html.Div(
              [
                  html.Div(
                      [
                          html.Div(
                              [
                                  build_input(
                                      [
                                          html.Div(text("X")),
                                          html.Small(
                                              "({})".format(
                                                  text("Agg By")
                                              )
                                          ),
                                      ],
                                      dcc.Dropdown(
                                          id="x-dropdown",
                                          options=x_options,
                                          placeholder="{} (1, 2, ..., N)".format(
                                              text("Default Index")
                                          ),
                                          value=x,
                                          style=dict(width="inherit"),
                                      ),
                                      label_class="input-group-addon d-block pt-1 pb-0",
                                      style=show_style(show_input("x")),
                                  ),
                                  build_input(
                                      text("Y"),
                                      dcc.Dropdown(
                                          id="y-multi-dropdown",
                                          options=y_multi_options,
                                          multi=True,
                                          placeholder=text(
                                              "Select Column(s)"
                                          ),
                                          style=dict(width="inherit"),
                                          value=y
                                          if show_input("y", "multi")
                                          else None,
                                      ),
                                      className="col",
                                      id="y-multi-input",
                                      style=show_style(
                                          show_input("y", "multi")
                                      ),
                                  ),
                                  build_input(
                                      [
                                          html.Div(text("Y")),
                                          html.Small(
                                              "({})".format(
                                                  text("Agg By")
                                              )
                                          ),
                                      ],
                                      dcc.Dropdown(
                                          id="y-single-dropdown",
                                          options=y_single_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          style=dict(width="inherit"),
                                          value=y[0]
                                          if show_input("y") and len(y)
                                          else None,
                                      ),
                                      className="col",
                                      label_class="input-group-addon d-block pt-1 pb-0",
                                      id="y-single-input",
                                      style=show_style(show_input("y")),
                                  ),
                                  build_input(
                                      text("Z"),
                                      dcc.Dropdown(
                                          id="z-dropdown",
                                          options=z_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          style=dict(width="inherit"),
                                          value=z,
                                      ),
                                      className="col",
                                      id="z-input",
                                      style=show_style(show_input("z")),
                                  ),
                                  build_input(
                                      text("Group"),
                                      dcc.Dropdown(
                                          id="group-dropdown",
                                          options=group_options,
                                          multi=True,
                                          placeholder=text(
                                              "Select Group(s)"
                                          ),
                                          value=group,
                                          style=dict(width="inherit"),
                                      ),
                                      className="col",
                                      id="group-input",
                                      style=show_style(
                                          show_input("group")
                                      ),
                                  ),
                                  build_dropna(dropna),
                              ],
                              id="standard-inputs",
                              style={}
                              if not show_map
                              and not show_candlestick
                              and chart_type
                              not in [
                                  "treemap",
                                  "funnel",
                                  "clustergram",
                              ]
                              else {"display": "none"},
                              className="row p-0 charts-filters",
                          ),
                          html.Div(
                              [
                                  build_map_type_tabs(map_type),
                                  html.Div(
                                      [
                                          html.Div(
                                              [
                                                  build_loc_mode_hover(
                                                      loc_mode
                                                  ),
                                                  dcc.Dropdown(
                                                      id="map-loc-mode-dropdown",
                                                      options=[
                                                          build_option(
                                                              v,
                                                              loc_modes[
                                                                  v
                                                              ].get(
                                                                  "label"
                                                              ),
                                                          )
                                                          for v in [
                                                              "ISO-3",
                                                              "USA-states",
                                                              "country names",
                                                              "geojson-id",
                                                          ]
                                                      ],
                                                      style=dict(
                                                          width="inherit"
                                                      ),
                                                      value=loc_mode,
                                                  ),
                                              ],
                                              className="input-group mr-3",
                                          )
                                      ],
                                      id="map-loc-mode-input",
                                      style=show_map_style(
                                          map_type == "choropleth"
                                      ),
                                      className="col-auto",
                                  ),
                                  custom_geojson.build_modal(
                                      map_type, loc_mode
                                  ),
                                  build_input(
                                      [
                                          html.Div(text("Locations")),
                                          html.Small(
                                              "({})".format(
                                                  text("Agg By")
                                              )
                                          ),
                                      ],
                                      dcc.Dropdown(
                                          id="map-loc-dropdown",
                                          options=loc_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          value=loc,
                                          style=dict(width="inherit"),
                                      ),
                                      id="map-loc-input",
                                      label_class="input-group-addon d-block pt-1 pb-0",
                                      style=show_map_style(
                                          map_type == "choropleth"
                                      ),
                                  ),
                                  build_input(
                                      [
                                          html.Div(text("Lat")),
                                          html.Small(
                                              "({})".format(
                                                  text("Agg By")
                                              )
                                          ),
                                      ],
                                      dcc.Dropdown(
                                          id="map-lat-dropdown",
                                          options=lat_options,
                                          placeholder="Select a column",
                                          value=lat,
                                          style=dict(width="inherit"),
                                      ),
                                      id="map-lat-input",
                                      label_class="input-group-addon d-block pt-1 pb-0",
                                      style=show_map_style(
                                          map_type
                                          in ["scattergeo", "mapbox"]
                                      ),
                                  ),
                                  build_input(
                                      [
                                          html.Div(text("Lon")),
                                          html.Small(
                                              "({})".format(
                                                  text("Agg By")
                                              )
                                          ),
                                      ],
                                      dcc.Dropdown(
                                          id="map-lon-dropdown",
                                          options=lon_options,
                                          placeholder="Select a column",
                                          style=dict(width="inherit"),
                                          value=lon,
                                      ),
                                      id="map-lon-input",
                                      label_class="input-group-addon d-block pt-1 pb-0",
                                      style=show_map_style(
                                          map_type
                                          in ["scattergeo", "mapbox"]
                                      ),
                                  ),
                                  build_input(
                                      text("Scope"),
                                      dcc.Dropdown(
                                          id="map-scope-dropdown",
                                          options=[
                                              build_option(v)
                                              for v in SCOPES
                                          ],
                                          style=dict(width="inherit"),
                                          value=map_scope or "world",
                                      ),
                                      id="map-scope-input",
                                      style=show_map_style(
                                          map_type == "scattergeo"
                                      ),
                                  ),
                                  html.Div(
                                      [
                                          html.Div(
                                              [
                                                  build_mapbox_token_hover(),
                                                  dcc.Dropdown(
                                                      id="map-mapbox-style-dropdown",
                                                      options=build_mapbox_style_options(),
                                                      style=dict(
                                                          width="inherit"
                                                      ),
                                                      value=mapbox_style
                                                      or "open-street-map",
                                                  ),
                                              ],
                                              className="input-group mr-3",
                                          )
                                      ],
                                      id="map-mapbox-style-input",
                                      className="col-auto",
                                      style=show_map_style(
                                          map_type == "mapbox"
                                      ),
                                  ),
                                  html.Div(
                                      [
                                          html.Div(
                                              [
                                                  build_proj_hover(
                                                      proj
                                                  ),
                                                  dcc.Dropdown(
                                                      id="map-proj-dropdown",
                                                      options=[
                                                          build_option(
                                                              v
                                                          )
                                                          for v in PROJECTIONS
                                                      ],
                                                      style=dict(
                                                          width="inherit"
                                                      ),
                                                      value=proj,
                                                  ),
                                              ],
                                              className="input-group mr-3",
                                          )
                                      ],
                                      id="map-proj-input",
                                      style=show_map_style(
                                          map_type == "scattergeo"
                                      ),
                                      className="col-auto",
                                  ),
                                  build_input(
                                      text("Value"),
                                      dcc.Dropdown(
                                          id="map-val-dropdown",
                                          options=map_val_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          style=dict(width="inherit"),
                                          value=map_val,
                                      ),
                                  ),
                                  build_input(
                                      text("Group"),
                                      dcc.Dropdown(
                                          id="map-group-dropdown",
                                          options=group_options,
                                          multi=True,
                                          placeholder=text(
                                              "Select Group(s)"
                                          ),
                                          value=inputs.get("map_group"),
                                          style=dict(width="inherit"),
                                      ),
                                      className="col",
                                      id="map-group-input",
                                  ),
                                  build_dropna(
                                      inputs.get("map_dropna", True),
                                      "map",
                                  ),
                              ],
                              id="map-inputs",
                              className="row charts-filters",
                              style={}
                              if show_map
                              else {"display": "none"},
                          ),
                          html.Div(
                              [
                                  build_input(
                                      text("X"),
                                      dcc.Dropdown(
                                          id="candlestick-x-dropdown",
                                          options=cs_x_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          style=dict(width="inherit"),
                                          value=cs_x,
                                      ),
                                  ),
                                  build_input(
                                      text("Open"),
                                      dcc.Dropdown(
                                          id="candlestick-open-dropdown",
                                          options=open_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          style=dict(width="inherit"),
                                          value=cs_open,
                                      ),
                                  ),
                                  build_input(
                                      text("High"),
                                      dcc.Dropdown(
                                          id="candlestick-high-dropdown",
                                          options=high_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          style=dict(width="inherit"),
                                          value=cs_high,
                                      ),
                                  ),
                                  build_input(
                                      text("Low"),
                                      dcc.Dropdown(
                                          id="candlestick-low-dropdown",
                                          options=low_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          style=dict(width="inherit"),
                                          value=cs_low,
                                      ),
                                  ),
                                  build_input(
                                      text("Close"),
                                      dcc.Dropdown(
                                          id="candlestick-close-dropdown",
                                          options=close_options,
                                          placeholder=text(
                                              "Select Column"
                                          ),
                                          style=dict(width="inherit"),
                                          value=cs_close,
                                      ),
                                  ),
                                  build_input(
                                      text("Group"),
                                      dcc.Dropdown(
                                          id="candlestick-group-dropdown",
                                          options=group_options,
                                          multi=True,
                                          placeholder=text(
                                              "Select Group(s)"
                                          ),
                                          value=inputs.get("cs_group"),
                                          style=dict(width="inherit"),
                                      ),
                                      className="col",
                                      id="candlestick-group-input",
                                  ),
                                  build_dropna(
                                      inputs.get("cs_dropna", True),
                                      "candlestick",
                                  ),
                              ],
                              id="candlestick-inputs",
                              className="row charts-filters",
                              style={}
                              if show_candlestick
                              else {"display": "none"},
                          ),
                          build_label_value_inputs(
                              "treemap", inputs, df, group_options
                          ),
                          build_funnel_inputs(
                              inputs, df, group_options
                          ),
                          build_label_value_inputs(
                              "clustergram",
                              inputs,
                              df,
                              group_options,
                              multi_value=True,
                              all_option=True,
                          ),
                          build_pareto_inputs(
                              inputs, df, group_options
                          ),
                          build_histogram_inputs(
                              inputs, df, group_options
                          ),
                          html.Div(
                              [
                                  html.Div(
                                      [
                                          build_input(
                                              text("Aggregation"),
                                              dcc.Dropdown(
                                                  id="agg-dropdown",
                                                  options=[
                                                      build_option(
                                                          v,
                                                          text(AGGS[v]),
                                                      )
                                                      for v in [
                                                          "count",
                                                          "pctct",
                                                          "nunique",
                                                          "sum",
                                                          "mean",
                                                          "rolling",
                                                          "corr",
                                                          "first",
                                                          "last",
                                                          "drop_duplicates",
                                                          "median",
                                                          "min",
                                                          "max",
                                                          "std",
                                                          "var",
                                                          "mad",
                                                          "prod",
                                                          "pctsum",
                                                      ]
                                                  ],
                                                  placeholder=text(
                                                      "No Aggregation"
                                                  ),
                                                  style=dict(
                                                      width="inherit"
                                                  ),
                                                  value=agg or "raw",
                                                  disabled=len(
                                                      inputs.get(
                                                          "extended_aggregation",
                                                          [],
                                                      )
                                                  )
                                                  > 0,
                                              ),
                                          ),
                                          html.Span(
                                              "* {}".format(
                                                  text(
                                                      "Extended Aggregation is currently populated."
                                                  )
                                              ),
                                              id="ext-agg-warning",
                                              style=show_style(
                                                  len(
                                                      inputs.get(
                                                          "extended_aggreation",
                                                          [],
                                                      )
                                                  )
                                                  > 0
                                              ),
                                              className="ext-agg-warning",
                                          ),
                                      ]
                                  )
                              ]
                              + extended_aggregations.build_modal(
                                  inputs.get(
                                      "extended_aggregation", []
                                  ),
                                  chart_type,
                                  y,
                              )
                              + [
                                  html.Div(
                                      [
                                          build_input(
                                              text("Window"),
                                              dcc.Input(
                                                  id="window-input",
                                                  type="number",
                                                  placeholder=text(
                                                      "Enter Days"
                                                  ),
                                                  className="form-control text-center",
                                                  style={
                                                      "lineHeight": "inherit"
                                                  },
                                                  value=inputs.get(
                                                      "window"
                                                  ),
                                              ),
                                          ),
                                          build_input(
                                              text("Computation"),
                                              dcc.Dropdown(
                                                  id="rolling-comp-dropdown",
                                                  options=[
                                                      build_option(
                                                          "corr",
                                                          text(
                                                              "Correlation"
                                                          ),
                                                      ),
                                                      build_option(
                                                          "count",
                                                          text("Count"),
                                                      ),
                                                      build_option(
                                                          "cov",
                                                          text(
                                                              "Covariance"
                                                          ),
                                                      ),
                                                      build_option(
                                                          "kurt",
                                                          text(
                                                              "Kurtosis"
                                                          ),
                                                      ),
                                                      build_option(
                                                          "max",
                                                          text(
                                                              "Maximum"
                                                          ),
                                                      ),
                                                      build_option(
                                                          "mean",
                                                          text("Mean"),
                                                      ),
                                                      build_option(
                                                          "median",
                                                          text(
                                                              "Median"
                                                          ),
                                                      ),
                                                      build_option(
                                                          "min",
                                                          text(
                                                              "Minimum"
                                                          ),
                                                      ),
                                                      build_option(
                                                          "skew",
                                                          text("Skew"),
                                                      ),
                                                      build_option(
                                                          "std",
                                                          text(
                                                              "Standard Deviation"
                                                          ),
                                                      ),
                                                      build_option(
                                                          "sum",
                                                          text("Sum"),
                                                      ),
                                                      build_option(
                                                          "var",
                                                          text(
                                                              "Variance"
                                                          ),
                                                      ),
                                                  ],
                                                  placeholder=text(
                                                      "Select Computation"
                                                  ),
                                                  style=dict(
                                                      width="inherit"
                                                  ),
                                                  value=inputs.get(
                                                      "rolling_comp"
                                                  ),
                                              ),
                                          ),
                                      ],
                                      id="rolling-inputs",
                                      style=show_style(
                                          agg == "rolling"
                                      ),
                                  ),
                                  build_input(
                                      text("Drilldowns"),
                                      html.Div(
                                          daq.BooleanSwitch(
                                              id="drilldown-toggle",
                                              on=False,
                                          ),
                                          className="toggle-wrapper",
                                      ),
                                      id="drilldown-input",
                                      style=show_style(
                                          (agg or "raw") != "raw"
                                      ),
                                      className="col-auto",
                                  ),
                              ],
                              className="row pt-3 pb-3 charts-filters",
                              id="charts-filters-div",
                              style={"display": "none"}
                              if chart_type == "histogram"
                              else {},
                          ),
                      ],
                      id="main-inputs",
                      className=main_input_class,
                  ),
                  html.Div(
                      [
                          html.Div(
                              html.Div(
                                  html.Div(
                                      [
                                          html.Span(
                                              text("Group Type"),
                                              className="input-group-addon",
                                          ),
                                          html.Div(
                                              dcc.Tabs(
                                                  id="group-type",
                                                  value=inputs.get(
                                                      "group_type"
                                                  )
                                                  or "groups",
                                                  children=[
                                                      build_tab(
                                                          text(
                                                              "Values"
                                                          ),
                                                          "groups",
                                                          {
                                                              "padding": "2px",
                                                              "minWidth": "4em",
                                                          },
                                                      ),
                                                      build_tab(
                                                          text("Bins"),
                                                          "bins",
                                                          {
                                                              "padding": "2px",
                                                              "minWidth": "4em",
                                                          },
                                                      ),
                                                  ],
                                              ),
                                              id="group-type-div",
                                              className="form-control col-auto pt-3",
                                          ),
                                      ],
                                      className="input-group",
                                  ),
                                  className="addon-min-width",
                              ),
                              className="col-md-12 p-0 pb-5",
                              id="group-type-input",
                              style=group_type_style,
                          ),
                          build_input(
                              text("Group(s)"),
                              dcc.Dropdown(
                                  id="group-val-dropdown",
                                  multi=True,
                                  placeholder=text(
                                      "Select Group Value(s)"
                                  ),
                                  value=group_val,
                                  style=dict(width="inherit"),
                              ),
                              className="col-md-12 p-0 pb-5",
                              id="group-val-input",
                              style=group_val_style,
                          ),
                          build_input(
                              text("Bins"),
                              [
                                  daq.NumericInput(
                                      id="bins-val-input",
                                      min=1,
                                      max=30,
                                      value=inputs.get("bins_val") or 5,
                                  ),
                                  html.Div(
                                      html.Div(
                                          [
                                              html.Span(
                                                  text("Binning"),
                                                  className="input-group-addon",
                                              ),
                                              html.Div(
                                                  build_hoverable(
                                                      dcc.Tabs(
                                                          id="bin-type",
                                                          value=inputs.get(
                                                              "bin_type"
                                                          )
                                                          or "width",
                                                          children=[
                                                              build_tab(
                                                                  text(
                                                                      "Width"
                                                                  ),
                                                                  "width",
                                                                  {
                                                                      "padding": "2px",
                                                                      "minWidth": "4em",
                                                                  },
                                                              ),
                                                              build_tab(
                                                                  text(
                                                                      "Freq"
                                                                  ),
                                                                  "freq",
                                                                  {
                                                                      "padding": "2px",
                                                                      "minWidth": "4em",
                                                                  },
                                                              ),
                                                          ],
                                                      ),
                                                      bin_type_msg(),
                                                      "",
                                                      top="120%",
                                                  ),
                                                  id="bin-type-div",
                                                  className="form-control col-auto pt-3",
                                              ),
                                          ],
                                          className="input-group",
                                      ),
                                      className="col-auto addon-min-width",
                                      id="bin-type-input",
                                  ),
                              ],
                              className="col-md-12 p-0",
                              id="bins-input",
                              style=bins_style,
                          ),
                      ],
                      id="group-inputs-row",
                      className="col-md-4 row pt-3 pb-5",
                      style=show_groups,
                  ),
              ],
              className="row",
          ),
          html.Div(
              [
                  build_input(
                      text("Chart Per\nGroup"),
                      html.Div(
                          daq.BooleanSwitch(
                              id="cpg-toggle",
                              on=inputs.get("cpg") or False,
                          ),
                          className="toggle-wrapper",
                      ),
                      id="cpg-input",
                      style=show_style(show_cpg),
                      className="col-auto",
                  ),
                  build_input(
                      text("Chart Per\nY"),
                      html.Div(
                          daq.BooleanSwitch(
                              id="cpy-toggle",
                              on=inputs.get("cpy") or False,
                          ),
                          className="toggle-wrapper",
                      ),
                      id="cpy-input",
                      style=show_style(show_cpy),
                      className="col-auto",
                  ),
                  build_input(
                      text("Trendline"),
                      dcc.Dropdown(
                          id="trendline-dropdown",
                          options=[
                              build_option("ols"),
                              build_option("lowess"),
                          ],
                          value=inputs.get("trendline"),
                      ),
                      className="col-auto addon-min-width",
                      style=scatter_input,
                      id="trendline-input",
                  ),
                  build_input(
                      text("Barmode"),
                      dcc.Dropdown(
                          id="barmode-dropdown",
                          options=[
                              build_option("group", text("Group")),
                              build_option("stack", text("Stack")),
                              build_option(
                                  "relative", text("Relative")
                              ),
                          ],
                          value=inputs.get("barmode") or "group",
                          placeholder=text("Select Mode"),
                      ),
                      className="col-auto addon-min-width",
                      style=bar_style,
                      id="barmode-input",
                  ),
                  build_input(
                      text("Barsort"),
                      dcc.Dropdown(
                          id="barsort-dropdown",
                          options=barsort_options,
                          value=inputs.get("barsort"),
                      ),
                      className="col-auto addon-min-width",
                      style=barsort_input_style,
                      id="barsort-input",
                  ),
                  build_input(
                      text("Top"),
                      dcc.Dropdown(
                          id="top-bars",
                          options=[
                              build_option(v) for v in [5, 10, 20, 50]
                          ],
                          value=inputs.get("top_bars"),
                          placeholder=None,
                      ),
                      className="col-auto",
                      style=barsort_input_style,
                      id="top-bars-input",
                  ),
                  html.Div(
                      html.Div(
                          [
                              html.Span(
                                  text("Y-Axis"),
                                  className="input-group-addon",
                              ),
                              html.Div(
                                  [
                                      dcc.Tabs(
                                          id="yaxis-scale",
                                          value=inputs.get("scale")
                                          or "linear",
                                          children=get_yaxis_scale_tabs(),
                                          className="pr-5",
                                      ),
                                      dcc.Tabs(
                                          id="yaxis-type",
                                          value=yaxis_type,
                                          children=get_yaxis_type_tabs(
                                              y
                                          ),
                                      ),
                                  ],
                                  id="yaxis-type-div",
                                  className="form-control col-auto pt-3",
                                  style=yaxis_type_style,
                              ),
                              dcc.Dropdown(
                                  id="yaxis-dropdown",
                                  options=yaxis_options,
                              ),
                              html.Span(
                                  "{}:".format(text("Min")),
                                  className="input-group-addon col-auto",
                                  id="yaxis-min-label",
                              ),
                              dcc.Input(
                                  id="yaxis-min-input",
                                  type="number",
                                  className="form-control col-auto",
                                  style={"lineHeight": "inherit"},
                              ),
                              html.Span(
                                  "{}:".format(text("Max")),
                                  className="input-group-addon col-auto",
                                  id="yaxis-max-label",
                              ),
                              dcc.Input(
                                  id="yaxis-max-input",
                                  type="number",
                                  className="form-control col-auto",
                                  style={"lineHeight": "inherit"},
                              ),
                          ],
                          className="input-group",
                          id="yaxis-min-max-options",
                      ),
                      className="col-auto addon-min-width",
                      id="yaxis-input",
                      style=show_style(show_yaxis),
                  ),
                  build_input(
                      text("Colorscale"),
                      dcs.DashColorscales(
                          id="colorscale-picker",
                          colorscale=inputs.get("colorscale")
                          or default_cscale,
                      ),
                      className="col-auto addon-min-width pr-0",
                      style=cscale_style,
                      id="colorscale-input",
                  ),
                  build_input(
                      text("Animate"),
                      html.Div(
                          daq.BooleanSwitch(
                              id="animate-toggle",
                              on=inputs.get("animate") or False,
                          ),
                          className="toggle-wrapper",
                      ),
                      id="animate-input",
                      style=animate_style,
                      className="col-auto",
                  ),
                  build_input(
                      text("Animate By"),
                      dcc.Dropdown(
                          id="animate-by-dropdown",
                          options=animate_opts,
                          value=inputs.get("animate_by"),
                      ),
                      className="col-auto addon-min-width",
                      style=animate_by_style,
                      id="animate-by-input",
                  ),
                  dbc.Button(
                      text("Lock Zoom"),
                      id="lock-zoom-btn",
                      className="ml-auto",
                      style=lock_zoom_style(chart_type),
                  ),
                  build_input(
                      build_hoverable(
                          html.Div(
                              text("Auto-Load"),
                              style=dict(color="white"),
                          ),
                          auto_load_msg(),
                          "",
                          top="120%",
                      ),
                      html.Div(
                          daq.BooleanSwitch(
                              id="auto-load-toggle",
                              on=True,
                              color="green",
                          ),
                          className="toggle-wrapper",
                      ),
                      id="auto-load-input",
                      className="ml-auto col-auto",
                  ),
                  dbc.Button(
                      text("Load"),
                      id="load-btn",
                      color="primary",
                      style=dict(display="none"),
                  ),
                  build_hoverable(
                      dbc.Button(
                          text("Save"),
                          id="save-btn",
                          color="primary",
                          style=dict(display="none"),
                      ),
                      text("save_msg"),
                      "",
                      top="120%",
                  ),
                  build_hoverable(
                      html.A(
                          html.I(className="fas fa-file-code fa-xl"),
                          id="export-all-chart-btn",
                          href="",
                          className="export-chart-btn",
                          style=dict(display="none"),
                      ),
                      "Export Charts",
                      additional_classes="mt-auto mb-auto",
                      hover_class="export-charts",
                  ),
              ],
              className="row pt-3 pb-5 charts-filters",
              id="chart-inputs",
          ),
          dcc.Loading(
              html.Div(
                  id="chart-content",
                  style={"height": "calc(100vh - 380px"},
              ),
              type="circle",
          ),
          dcc.Textarea(
              id="copy-text",
              style=dict(position="absolute", left="-110%"),
          ),
      ]
      if settings.get("github_fork", False):
          body_items.append(
              html.Span(
                  html.A(
                      text("Fork me on Github"),
                      href="https://github.com/man-group/dtale",
                  ),
                  id="forkongithub",
              )
          )
      return body_items
  
imports: import json
  import dash_bootstrap_components
  import dash_colorscales
  import dash_daq
  import os
  import plotly
  from pkg_resources import parse_version
  from six import PY3
  from dtale.dash_application import dcc, html
  import dtale.dash_application.custom_geojson
  import dtale.dash_application.extended_aggregations
  import dtale.global_state
  from dtale.charts.utils import AGGS, ANIMATION_CHARTS, ANIMATE_BY_CHARTS, YAXIS_CHARTS, ZAXIS_CHARTS, NON_EXT_AGGREGATION, build_final_cols, find_group_vals
  from dtale.column_builders import get_cleaner_configs
  from dtale.constants import CHART_JOINER_CHAR
  from dtale.dash_application.layout.utils import build_input, build_option, build_tab, build_cols, build_hoverable, build_selections, show_style, FREQS, FREQ_LABELS
  from dtale.translations import text
  from dtale.query import build_query, handle_predefined, inner_build_query, run_query
  from dtale.utils import ChartBuildingError, classify_type, coord_type, get_dtypes, is_app_root_defined, make_list
label_desc: Use image node_id 48 for calling a global function with example usage: charts_layout(df, settings) and returns: body_items, unknown