Skip to content

Crosstalk + Plotly bar-chart “gaps” for unselected entries #1709

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

Closed
dgdi opened this issue Feb 25, 2020 · 3 comments
Closed

Crosstalk + Plotly bar-chart “gaps” for unselected entries #1709

dgdi opened this issue Feb 25, 2020 · 3 comments

Comments

@dgdi
Copy link

dgdi commented Feb 25, 2020

First, many thanks for your work. It is amazing how simple it is to do amazing visualizations using it and as a non-CS guy I am really grateful for that. Keep up with the great work!

I have also posted on SO about the issue.

I am tring to use Crosstalk and Plotly to create a dashboard and I have come across an unexpected behaviour. When selecting through the Crosstalk fiter, the Plotly bargraph leaves "gaps" for the unselected entries.

As a reproducible example, let's say I want compare cities populations, what I am getting is this (code at the bottom)

SO_crosstalk_plotly

It might very well be that I am missing something, is there a way to get rid of the gap? any advice on viable ways to do a similar comparison avoiding the issue?

I am using R 3.6.1, crosstalk 1.1.1.9000, plotly 4.9.2

Thanks in advance.

Code

---
title: "Crosstalk+Plotly bargraph selection"
---

```{r setup, include=FALSE}
options(stringsAsFactors = FALSE)
library(crosstalk) 
library(dplyr)
library(plotly)  

#data on cities' population
city_pop <- data.frame("City" = c("Florence",  "Milan", "Venice"),
                    "Population" = c(382258, 1352000, 261905))

#setting up Crosstalk shared data
sd <- SharedData$new(city_pop, key = city_pop$city)

#filter for the cities
filt <- filter_select(
  id = "select_name",
  label = "Selected City",
  sharedData = sd,
  group = ~City,
  selected = "")

#barplot of cities' population
bars_pop <- plot_ly(sd, x = ~City, y = ~Population) %>% 
add_bars(width=0.2,
           x =  ~City,
       y =  ~Population,
       color = I("#89CFF0"),
       name = "",
       opacity=.9,
       hoverinfo = 'y',
       hovertemplate = paste('%{x} <br> number of Residents: %{y}<extra></extra>')
       ) 



filt

bars_pop
@rainer-rq-koelle
Copy link

Hi @dgdi, I ran into the very same issue about the same time, my friend :)
It will not help, but the issue seems to be known for quite a while now without any real solution/change, c.f. #689. I keep my fingers crossed.

@dgdi
Copy link
Author

dgdi commented Mar 5, 2020

Hi @rainer-rq-koelle, thanks for your feedback. Nice to know I am not the only one who thougt to use the packages that way!
This issue is definetly a Duplicate of #689 .
I have updated the SO question with the link to your SO question and to issue #689 .

@rainer-rq-koelle
Copy link

rainer-rq-koelle commented Mar 5, 2020 via email

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

No branches or pull requests

2 participants