plotly / plotly/plotly.R

config is not overwritting `ModeBarButtons` slot

Open
#2,210 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

I have noticed that after placing a ModeBarButtons configuration, it is not overwritten / updated downstream.

Reproducible example:

library(plotly)
#> Loading required package: ggplot2
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout
  # This plotly only has the `toImage` modeBarButton
  plot1 <- plot_ly() %>%
    config(displaylogo = FALSE) %>%
    config(modeBarButtons = list(list("toImage")))
  plot1$x$config$modeBarButtons
#> [[1]]
#> [[1]][[1]]
#> [1] "toImage"
  
  # This plotly also has the `toImage` modeBarButton only
  plot2 <- plot_ly() %>%
    config(displaylogo = FALSE) %>%
    config(modeBarButtons = list(list("toImage"))) %>% 
    config(modeBarButtons = list(list("zoom")))
  plot2$x$config$modeBarButtons
#> [[1]]
#> [[1]][[1]]
#> [1] "toImage"

Created on 2022-11-29 with reprex v2.0.2

This holds true for config(modeBarButtonsToAdd ...)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the config() entry point and reproduce the two examples from the issue, comparing plot1$x$config$modeBarButtons with plot2$x$config$modeBarButtons. The fix is complete when a later modeBarButtons configuration updates the earlier value, and the same behavior is verified for modeBarButtonsToAdd.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.