jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
719 stars 148 forks source link

weird behavior of xAxis category #135

Closed zhenyiy closed 8 years ago

zhenyiy commented 8 years ago

Here's the code:

library(highcharter)

hc <- highchart() %>%
  hc_chart(type="scatter", zoomType="xy") %>%
  hc_xAxis(type="category", categories=list("a","b","c","d")) %>%
  hc_plotOptions(
    scatter=list(marker=list(radius=3))
  ) %>% 
  hc_add_series_scatter(x=1:4, y =1:4) 

hc

The xAxis of the graph creates starts from b instead of a. Is it a bug or is there something wrong with my code? Thanks. image

jbkunst commented 8 years ago

Hi @zhenyiy

Is not a bug, there's nothing wrong with your code, the problem is javascript XD, nah. Javascript count start at 0, so you need to change:

hc_add_series_scatter(x=1:4, y =1:4) 

by

hc_add_series_scatter(x=1:4-1, y =1:4)