Skip to content
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

e_axis_formatter does not appear to work #100

Closed
nschwamm opened this issue Aug 2, 2019 · 12 comments
Closed

e_axis_formatter does not appear to work #100

nschwamm opened this issue Aug 2, 2019 · 12 comments

Comments

@nschwamm
Copy link

nschwamm commented Aug 2, 2019

The e_axis_formatter does not appear to work such that taking the examples from the reference guide (https://echarts4r.john-coene.com/reference/axis.html) do not even work.

For example:

 # use formatter
cars %>%
  dplyr::mutate(
    speed = speed / 25
  ) %>%
  e_charts(speed) %>%
  e_scatter(dist) %>%
  e_y_axis(
    formatter = e_axis_formatter("currency")
  ) %>%
  e_x_axis(
    formatter = e_axis_formatter("percent", digits = 0)
  )

This just shows an empty output for me.

In fact, any example with e_axis_formatter applied to the y axis appear to fail.

# y-axis example
cars %>%
  e_charts(speed) %>%
  e_line(dist) %>%
  e_y_axis(dist,formatter = e_axis_formatter("decimal")) %>%
  e_x_axis(speed)

If I try using it with the x axis, all the data disappears.

# x-axis example
cars %>%
  e_charts(speed) %>%
  e_line(dist) %>%
  e_x_axis(speed,formatter = e_axis_formatter("decimal")) %>%
  e_y_axis(dist)
@JohnCoene
Copy link
Owner

Sorry for the late response, took a bit of break in the summer. It does indeed not work, it's been a while since I worked on the axis formatter helpers, a lot of them are contributions from @artemklevtsov (thanks again!).

My understanding is that the underlying JavaScript function would have to dramatically change in order to apply to both axis but I may be wrong. I'll look into it.

@nschwamm
Copy link
Author

Appreciate the response. Just for reference, the examples hold even if you are doing one at time.

For example, neither of these work:

# y-axis
cars %>%
  e_charts(speed) %>%
  e_line(dist) %>%
  e_y_axis(dist,formatter = e_axis_formatter("decimal"))
# x-axis
cars %>%
  e_charts(speed) %>%
  e_line(dist) %>%
  e_x_axis(speed,formatter = e_axis_formatter("decimal"))

Any work around to format an axis without using the e_axis_formatter function for now?

@JohnCoene
Copy link
Owner

I think I have narrowed down the issue; would you happen to be on Linux?

@nschwamm
Copy link
Author

These errors were caused on a Windows computer, however, the ultimate deployment will be to a linux server.

@JohnCoene
Copy link
Owner

JohnCoene commented Aug 14, 2019

What's the output of stringi::stri_locale_info()$Language on your machine?

Try

cars %>%
  e_charts(speed) %>%
  e_line(dist) %>%
  e_x_axis(speed,formatter = e_axis_formatter("decimal", locale = "en"))

@nschwamm
Copy link
Author

nschwamm commented Aug 14, 2019

stringi::stri_locale_info()$Language prints "en"

That code produces the same error as the earlier example. It also does not change if I include locale = "en" in the y_axis_formatter.

@JohnCoene
Copy link
Owner

Should be fixed.

remotes::install_github("JohnCoene/echarts4r")

@nschwamm
Copy link
Author

No luck here. Same error persists.

@shrektan
Copy link
Contributor

I haven't tested it but in case you are using RStudio to view the chart, I suggest you view the chart in the browser. I remember when there's certain javascript included in the chart, some of them can't be displayed well in RStudio's viewer but it's ok to use in the browser.

@nschwamm
Copy link
Author

@shrektan that worked! Interesting that the javascript crashes in different ways for the x/y axis. But yes, that works!

@JohnCoene maybe we can add this to the reference guide?

@JohnCoene
Copy link
Owner

Ah! Thank you @shrektan! I was totally out of ideas. I indeed don’t use RStudio but it’s to the best of my knowledge a browser (the whole of RStudio) you can right click inspect anything. I’ve encountered such issues in the past for the {signals} package: it had not occurred to me that this could be the issue here too.

I’ll add a note in the documentation. Thanks again @shrektan for isolating the issue and thank you @nschwamm for the bug report.

@JohnCoene
Copy link
Owner

It's now mentioned in documentation + if using RStudio the function e_axis_formatter emits a warning. Thanks both!

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

3 participants