-
Notifications
You must be signed in to change notification settings - Fork 15
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
Wrong x-axis labels and ticks with type="numeric"
#48
Comments
Seems like a bug with float, it doesn't occur if we use Victor |
Great, thanks. Here is a minimal reproducible example to reproduce the bug with df <- data.frame(x=c(1, 2, 3), y=c(0, 1, 0))
apex(data=df, mapping=aes(x=x, y=y), type="line") %>%
ax_xaxis(type="numeric") |
Thanks, Here you used "data": [
{
"x": 1,
"y": 0
},
{
"x": 2,
"y": 1
},
{
"x": 3,
"y": 0
}
] The bug here seems to appear if option |
Sorry if this is not the right lead (I understand very little about these things), but when you change to version 3.4.1 in your codepen (at least this is what I think I'm doing in settings), the graph does render correctly, i.e., the bug goes away. I don't know how easy it is to update to this version. |
3.4.1 is actually an old version (17 Feb 2019) Last version released is 3.23.1, and is the one used in {apexcharter} GitHub (CRAN use 3.22.2) |
I believe the issue was fixed on Apex's gihub a few weeks ago. Any chance this will be rolled over soon, so that code like this gives correct results: df <- data.frame(x=c(1, 2, 3), y=c(0, 1, 0))
apex(data=df, mapping=aes(x=x, y=y), type="line") %>%
ax_xaxis(type="numeric") Many thanks! |
Yes I openned an issue (apexcharts/apexcharts.js#2249) ;) I was waiting for an official release, however I build manually the JS bundle from Apexcharts repo so you can try. Victor |
Thanks, seems to work just fine for the toy example: And if you want to have "nice" ticks, using df <- data.frame(x=c(1, 2, 3), y=c(0, 1, 0))
apex(data=df, mapping=aes(x=x, y=y), type="line") %>%
ax_xaxis(type="numeric", tickAmount=2) Only |
There is still a small issue, though, if one wants to set a custom x-axis range: It has to do with the precision of the tick labels. Out of the box, the plot is pretty confusing: x <- seq(-4, 4, 0.01)
df <- data.frame(x=x, y=dnorm(x))
apex(data=df, aes(x,y), type='line') %>%
ax_xaxis(type='numeric',
max=5,
range=10,
tickAmount=8
#labels=list(formatter=format_num(".2f"))
) One needs to specify the formatting of the tick labels to get a meaningful x-axis: x <- seq(-4, 4, 0.01)
df <- data.frame(x=x, y=dnorm(x))
apex(data=df, aes(x,y), type='line') %>%
ax_xaxis(type='numeric',
max=5,
range=10,
tickAmount=8,
labels=list(formatter=format_num(".2f"))
) I.e., the -1.25 is rounded and displayed as -1, and the -2.50 is rounded and displayed as -3 in the first chart. However, if you set |
Thanks for the tests! |
The placement (and/or labels) of the x-axis ticks are somewhat off in this plot of a normal distribution with mean 0 and standard deviation 0.1:
I can't quite figure out what's wrong in the code. I expect the upper bound to be 0.3, and ticks at (-0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3), with the plot centered over 0.0. The funny thing is that the x-value in the hover information is correct.
The text was updated successfully, but these errors were encountered: