Skip to content

X-axis max doubled when adding stacked e_bars? #357

Description

@sharlagelfand

Hi! Thanks for this great package :)

I'm running into a strange issue where the x-axis max is doubled (?) when I'm adding two e_bar()s that are stacked. I want to create a bar chart where one bar is "highlighted", so I'm accomplishing that with two series.

The x limits in the data are the same, and they each appear separately just fine:

library(echarts4r)
library(dplyr)

df_1 <- data.frame(
  x = 1:5, 
  y_1 = c(1, 2, 3, NA, 5)
)

df_1 %>%
  e_chart(x) %>%
  e_bar(y_1)

Screen Shot 2021-08-05 at 2 17 32 PM

df_2 <- data.frame(
  x = 1:5, 
  y_2 = c(NA, NA, NA, 4, NA)
)

df_2 %>%
  e_chart(x) %>%
  e_bar(y_2)

Screen Shot 2021-08-05 at 2 17 51 PM

When I combine, the styling looks as desired - I'm "fake" stacking them I guess, because I don't want the dodged behaviour, and that looks fine - but the x-axis max is doubled, going all the way to 10 instead of 5:

df_combined <- df_1 %>%
  left_join(df_2, by = "x")

df_combined %>%
  e_chart(x) %>%
  e_bar(y_1, stack = "group") %>%
  e_bar(y_2, stack = "group")

Screen Shot 2021-08-05 at 2 18 46 PM

Any ideas why this might be? I'm using the latest version from github. I know you can manually set the limits, but it's hard to do that on a dynamic / not-manual basis. Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions