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

Add multiple x axis #421

Open
XR97 opened this issue Apr 20, 2022 · 1 comment
Open

Add multiple x axis #421

XR97 opened this issue Apr 20, 2022 · 1 comment

Comments

@XR97
Copy link

XR97 commented Apr 20, 2022

I want to add the custom second xAxis and the code as follows, but the generated JS seems to be wrong.
The mechanism of add xAxis is different between yAxis? Or it is a bug?

library(echarts4r)
library(magrittr)
library(data.table)

dt <- data.table(
  x_label = c('A', 'B', 'C', 'D', 'D', 'D', 'D'),
  x_value = c('a', 'b', 'c', 'd', 'e', 'f', 'g'),
  y = 8:14
)
p <- e_charts(dt)
p <- e_x_axis(p, index = 0, data = purrr::map(seq_len(nrow(dt)), ~{list(value = dt[.x, x_label])}))
p <- e_x_axis(p, index = 1, data = purrr::map(seq_len(nrow(dt)), ~{list(value = dt[.x, x_value])}))

json <- p %>%
  e_inspect(
    json = TRUE,
    pretty = TRUE
  )


> json
{
  "yAxis": [
    {
      "show": true
    }
  ],
  "xAxis": {
    "data": {
      "1": {
        "value": "A"
      },
      "2": {
        "value": "B"
      },
      "3": {
        "value": "C"
      },
      "4": {
        "value": "D"
      },
      "5": {
        "value": "D"
      },
      "6": {
        "value": "D"
      },
      "7": {
        "value": "D"
      },
      "data": [
        {
          "value": "a"
        },
        {
          "value": "b"
        },
        {
          "value": "c"
        },
        {
          "value": "d"
        },
        {
          "value": "e"
        },
        {
          "value": "f"
        },
        {
          "value": "g"
        }
      ]
    }
  }
} 

@rdatasculptor
Copy link
Contributor

@XR97 On my machine your code simply doesn't work. I am not sure how your chart needs to be look like. You say there is no problem if you treat the yAxis this way. Can you give an example?

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

2 participants