code: def test_pie(unittest):
      import dtale.views as views
  
      df = pd.DataFrame(
          dict(
              a=[1, 2, 3, 4, 5, 6],
              b=[7, 8, 9, 10, 11, 12],
              c=[13, 14, 15, 16, 17, 18],
          )
      )
      with app.test_client() as c:
          df, _ = views.format_data(df)
          build_data_inst({c.port: df})
          inputs = {
              "chart_type": "pie",
              "x": "a",
              "y": ["b"],
              "z": None,
              "group": ["c"],
              "agg": None,
              "window": None,
              "rolling_comp": None,
          }
          extended_aggregation = [
              dict(col="b", agg="sum"),
              dict(col="b", agg="mean"),
          ]
          chart_inputs = {
              "cpg": True,
              "barmode": "group",
              "barsort": "b",
          }
          params = build_chart_params(
              c.port,
              inputs,
              chart_inputs,
              extended_aggregation=extended_aggregation,
          )
          response = c.post(
              "/dtale/charts/_dash-update-component", json=params
          )
          resp_data = response.get_json()["response"]
          assert len(resp_data["chart-content"]["children"]) == 6
          chart = resp_data["chart-content"]["children"][0]
          chart = chart["props"]["children"][0]["props"]["children"][
              "props"
          ]["children"][1]
          unittest.assertEqual(
              chart["props"]["figure"]["layout"],
              {
                  "legend": {"orientation": "h", "y": -0.3},
                  "title": {"text": "(c: 13) - Sum of b by a"},
              },
          )
          unittest.assertEqual(
              list(
                  map(
                      lambda d: d["name"],
                      chart["props"]["figure"]["data"],
                  )
              ),
              ["Sum of b"],
          )
          chart = resp_data["chart-content"]["children"][0]
          chart = chart["props"]["children"][1]["props"]["children"][
              "props"
          ]["children"][1]
          unittest.assertEqual(
              chart["props"]["figure"]["layout"],
              {
                  "legend": {"orientation": "h", "y": -0.3},
                  "title": {"text": "(c: 13) - Mean of b by a"},
              },
          )
          unittest.assertEqual(
              list(
                  map(
                      lambda d: d["name"],
                      chart["props"]["figure"]["data"],
                  )
              ),
              ["Mean of b"],
          )
  
          inputs["group"] = None
          chart_inputs["cpg"] = False
          params = build_chart_params(
              c.port,
              inputs,
              chart_inputs,
              extended_aggregation=extended_aggregation,
          )
          response = c.post(
              "/dtale/charts/_dash-update-component", json=params
          )
          resp_data = response.get_json()["response"]
          assert (
              resp_data["chart-content"]["children"][0]["type"] == "Div"
          )
  
      df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, -6]))
      with app.test_client() as c:
          df, _ = views.format_data(df)
          build_data_inst({c.port: df})
          inputs = {
              "chart_type": "pie",
              "x": "a",
              "y": ["b"],
              "z": None,
              "group": None,
              "agg": None,
              "window": None,
              "rolling_comp": None,
          }
          chart_inputs = {
              "cpg": False,
              "cpy": False,
              "barmode": "group",
              "barsort": "b",
          }
          params = build_chart_params(
              c.port,
              inputs,
              chart_inputs,
              extended_aggregation=extended_aggregation,
          )
          response = c.post(
              "/dtale/charts/_dash-update-component", json=params
          )
          resp_data = response.get_json()["response"]
          [error, chart] = resp_data["chart-content"]["children"][0][
              "props"
          ]["children"][0]["props"]["children"]["props"]["children"]
          assert (
              error["props"]["children"]["props"]["children"][2][
                  "props"
              ]["children"]["props"]["children"]
              == "3 (-6)"
          )
          chart = chart["props"]["children"]["props"]["children"][1][
              "props"
          ]["figure"]
          unittest.assertEqual(
              chart["layout"],
              {
                  "legend": {"orientation": "h", "y": -0.3},
                  "title": {"text": "Sum of b by a"},
              },
          )
  
file_path: dtale/tests/dtale/dash/test_extended_aggregation_charts.py
imports: import pandas
  import pytest
  from pkg_resources import parse_version
  import dtale.global_state
  from dtale.app import build_app
  from tests.dtale import build_data_inst
  from tests.dtale.dash.test_dash import build_chart_params, get_url_parser
  from tests.dtale.test_charts import build_col_def
  from tests.dtale.test_views import URL
label_desc: Use image node_id 4 for calling a global function with example usage: test_pie(unittest) without return types