Skip to content

Fix the definition of has_fill() #1388

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

Merged
merged 1 commit into from
Nov 13, 2018
Merged

Fix the definition of has_fill() #1388

merged 1 commit into from
Nov 13, 2018

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Nov 1, 2018

Background

After the stroke argument was recently introduced (v4.8.0 I believe), the color argument was refined to control the "fill color" properties (previously, it would control both "stroke color" and "fill color").

That logic relies on has_fill() to determine whether "fill color" is relevant for the trace (if it isn't, then both color and stroke will control the "stroke color")

This PR broadens the definition of what it means for a plotly trace to have a "fill color" to include traces that have a fillcolor attribute but no fill attribute (e.g., box traces).

Testing notes

Please ensure both of the examples below produce the following image:

screen shot 2018-11-05 at 3 38 20 pm

# devtools::install_github("ropensci/plotly#1388")
library(plotly)

set.seed(1)
data <- data.frame(x = rep(c("A", "B"), each = 5), y = rnorm(10))
cols <- c('A' = "blue", 'B' = "red")

plot_ly(data) %>% 
  add_boxplot(x = ~x, y = ~y, color = ~x, colors = cols, line = list(color = "black"))
plot_ly(data) %>% 
  add_boxplot(x = ~x, y = ~y, color = ~x, colors = cols, stroke = I("black"))

@jcheng5
Copy link
Contributor

jcheng5 commented Nov 8, 2018

I've looked at this a couple of times and can't understand what's happening. If you're comfortable merging it, that's fine with me, but if you feel like you need useful feedback from me it's going to require a top-down tour first.

My only tactical question is that I would've expected a unit test for has_fill specifically, given how many conditionals and defaults are present.

@cpsievert cpsievert merged commit 2bf0cbc into master Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants