@@ -1686,6 +1686,22 @@ def process_dataframe_timeline(args):
16861686 return args
16871687
16881688
1689+ def process_dataframe_pie (args , trace_patch ):
1690+ names = args .get ("names" )
1691+ if names is None :
1692+ return args , trace_patch
1693+ order_in = args ["category_orders" ].get (names , {}).copy ()
1694+ if not order_in :
1695+ return args , trace_patch
1696+ df = args ["data_frame" ]
1697+ trace_patch ["sort" ] = False
1698+ trace_patch ["direction" ] = "clockwise"
1699+ uniques = list (df [names ].unique ())
1700+ order = [x for x in OrderedDict .fromkeys (list (order_in ) + uniques ) if x in uniques ]
1701+ args ["data_frame" ] = df .set_index (names ).loc [order ].reset_index ()
1702+ return args , trace_patch
1703+
1704+
16891705def infer_config (args , constructor , trace_patch , layout_patch ):
16901706 attrs = [k for k in direct_attrables + array_attrables if k in args ]
16911707 grouped_attrs = []
@@ -1948,6 +1964,8 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
19481964 args = build_dataframe (args , constructor )
19491965 if constructor in [go .Treemap , go .Sunburst , go .Icicle ] and args ["path" ] is not None :
19501966 args = process_dataframe_hierarchy (args )
1967+ if constructor in [go .Pie ]:
1968+ args , trace_patch = process_dataframe_pie (args , trace_patch )
19511969 if constructor == "timeline" :
19521970 constructor = go .Bar
19531971 args = process_dataframe_timeline (args )
0 commit comments