Skip to content

fix: implement automatic zorder assignment for proper trace layering #2445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Description: Create interactive web graphics from 'ggplot2' graphs and/or a cust
URL: https://plotly-r.com, https://github.com/plotly/plotly.R, https://plotly.com/r/
BugReports: https://github.com/plotly/plotly.R/issues
Depends:
R (>= 3.2.0),
R (>= 3.5),
ggplot2 (>= 3.0.0)
Imports:
tools,
Expand Down
8 changes: 8 additions & 0 deletions R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,14 @@ gg2list <- function(p, width = NULL, height = NULL,
l$cur_data <- ids[[layerData]]
l$visdat <- setNames(lapply(return_dat, function(x) function(y) x), ids)

# automatically assign zorder values based on trace positionAdd commentMore actions
# this ensures proper layering (later traces on top) for ggplot2 without manual intervention
for (i in seq_along(l$data)) {
if (is.null(l$data[[i]]$zorder)) {
l$data[[i]]$zorder <- i
}
}

l
}

Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/plotlyjs/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) 2021 Plotly, Inc
Copyright (c) 2016-2024 Plotly Technologies Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion inst/htmlwidgets/lib/plotlyjs/locales/cs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion inst/htmlwidgets/lib/plotlyjs/locales/es-pe.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion inst/htmlwidgets/lib/plotlyjs/locales/es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading