Skip to content

Commit e5b9679

Browse files
move gl switch
1 parent 6f3b5c4 commit e5b9679

File tree

1 file changed

+16
-17
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+16
-17
lines changed

packages/python/plotly/plotly/express/_core.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,21 @@ def frame_args(duration):
708708

709709

710710
def make_trace_spec(args, constructor, attrs, trace_patch):
711+
if constructor in [go.Scatter, go.Scatterpolar]:
712+
if "render_mode" in args and (
713+
args["render_mode"] == "webgl"
714+
or (
715+
args["render_mode"] == "auto"
716+
and len(args["data_frame"]) > 1000
717+
and args["animation_frame"] is None
718+
)
719+
):
720+
if constructor == go.Scatter:
721+
constructor = go.Scattergl
722+
if "orientation" in trace_patch:
723+
del trace_patch["orientation"]
724+
else:
725+
constructor = go.Scatterpolargl
711726
# Create base trace specification
712727
result = [TraceSpec(constructor, attrs, trace_patch, None)]
713728

@@ -1555,24 +1570,8 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
15551570
trace_names = trace_names_by_frame[frame_name]
15561571

15571572
for trace_spec in trace_specs:
1558-
constructor_to_use = trace_spec.constructor
1559-
if constructor_to_use in [go.Scatter, go.Scatterpolar]:
1560-
if "render_mode" in args and (
1561-
args["render_mode"] == "webgl"
1562-
or (
1563-
args["render_mode"] == "auto"
1564-
and len(args["data_frame"]) > 1000
1565-
and args["animation_frame"] is None
1566-
)
1567-
):
1568-
if constructor_to_use == go.Scatter:
1569-
constructor_to_use = go.Scattergl
1570-
if "orientation" in trace_patch:
1571-
del trace_patch["orientation"]
1572-
else:
1573-
constructor_to_use = go.Scatterpolargl
15741573
# Create the trace
1575-
trace = constructor_to_use(name=trace_name)
1574+
trace = trace_spec.constructor(name=trace_name)
15761575
if trace_spec.constructor not in [
15771576
go.Parcats,
15781577
go.Parcoords,

0 commit comments

Comments
 (0)