Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Waterfall missing #1518

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 2 commits into
base: master
Choose a base branch
Loading
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
4 changes: 3 additions & 1 deletion 4 R/plotly_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ plotly_build.plotly <- function(p, registerFrames = TRUE) {
# 3. The grouping from (2) and any groups detected via dplyr::groups()
# are combined into a single grouping variable, .plotlyGroupIndex
builtData <- arrange_safe(builtData, ".plotlyTraceIndex")
isComplete <- complete.cases(builtData[names(builtData) %in% c("x", "y", "z")])
# Missing values have special meaning for waterfall
vars <- if (trace$type != "waterfall") c("x", "y", "z")
isComplete <- complete.cases(builtData[names(builtData) %in% vars])
# warn about missing values if groups aren't relevant for this trace type
if (any(!isComplete) && !has_group(trace)) {
warning("Ignoring ", sum(!isComplete), " observations", call. = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion 2 tests/figs/subplot/plotly-subplot-geo-cartesian.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions 1 tests/figs/waterfall/waterfall-missing-values.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions 16 tests/testthat/test-plotly-waterfall.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,20 @@ test_that("Simple waterfall works", {
expect_doppelganger_built(p, "waterfall-simple")
})

test_that("Waterfall missing values are retained", {
y <- c("Sales", "Consulting", "Maintenance", "Other revenue", "Net revenue", "Purchases", "Material expenses", "Personnel expenses", "Other expenses", "Operating profit", "Investment income", "Financial income", "Profit before tax", "Income tax (15%)", "Profit after tax")

d <- data.frame(
measure = c("relative", "relative", "relative", "relative", "total", "relative", "relative", "relative", "relative", "total", "relative", "relative", "total", "relative", "total"),
y = factor(y, levels = y),
x = c(375, 128, 78, 27, NA, -327, -12, -78, -12, NA, 32, 89, NA, -45, NA)
)

p <- plot_ly(d, measure = ~measure, y = ~y, x = ~x) %>%
add_trace(type = "waterfall", orientation = "h") %>%
layout(yaxis = list(autorange = "reversed"))

expect_doppelganger_built(p, "waterfall-missing-values")
})


Morty Proxy This is a proxified and sanitized view of the page, visit original site.