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

Comments

@nschwamm
Copy link

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

This comment has been minimized.

Copy link
Owner

commented Aug 13, 2019

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

This comment has been minimized.

Copy link
Author

commented Aug 13, 2019

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

This comment has been minimized.

Copy link
Owner

commented Aug 14, 2019

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

@nschwamm

This comment has been minimized.

Copy link
Author

commented Aug 14, 2019

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

@JohnCoene

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Owner

commented Aug 14, 2019

Should be fixed.

remotes::install_github("JohnCoene/echarts4r")
@nschwamm

This comment has been minimized.

Copy link
Author

commented Aug 14, 2019

No luck here. Same error persists.

@shrektan

This comment has been minimized.

Copy link
Contributor

commented Aug 15, 2019

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

This comment has been minimized.

Copy link
Author

commented Aug 15, 2019

@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

This comment has been minimized.

Copy link
Owner

commented Aug 16, 2019

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 JohnCoene closed this in 646d129 Aug 16, 2019

@JohnCoene

This comment has been minimized.

Copy link
Owner

commented Aug 16, 2019

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
Projects
None yet
3 participants
You can’t perform that action at this time.