график highcharter неправильно сложен - PullRequest
0 голосов
/ 13 июля 2020
• 1000 :
x = structure(list(stat_motif = c("controle_cadastre", "controle_cadastre", 
                              "controle_cadastre", "controle_cadastre", "doc_apres_travaux", 
                              "doc_apres_travaux"), nb_motif_mois = c(2L, 1L, 1L, 1L, 1L, 1L
                              ), mois_modif_stat = structure(c(18078, 18383, 18293, 18201, 
                                                               18383, 18048), class = "Date"), 
               col_motif = c("#FAA43A", "#FAA43A", "#FAA43A", "#FAA43A", "#264D00", "#264D00")), 
          row.names = c(NA, -6L), class = "data.frame", .Names = c("stat_motif", "nb_motif_mois", "mois_modif_stat", "col_motif"))

dput(as.data.frame(y))


y = structure(list(stat_motif = c("autre", "controle_cadastre", "controle_cadastre", 
                              "controle_cadastre", "controle_cadastre", "controle_cadastre", 
                              "doc_apres_travaux", "doc_apres_travaux", "doc_apres_travaux"), 
               nb_motif_mois = c(1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L), 
               mois_modif_stat = structure(c(18293, 18293, 18201, 18078, 18322, 18383, 18048, 18353, 18383), class = "Date"), 
               col_motif = c("#7CFC00", "#FAA43A", "#FAA43A", "#FAA43A", "#FAA43A", "#FAA43A", "#264D00", "#264D00", "#264D00")),
          row.names = c(NA, -9L), class = "data.frame", .Names = c("stat_motif", "nb_motif_mois", "mois_modif_stat", "col_motif"))

Данные y работают правильно, но не данные x

hchart(
  # as.data.frame(y)
  as.data.frame(x),
  "column", 
  hcaes(x = mois_modif_stat, y = nb_motif_mois, group = stat_motif, label = stat_motif)
) %>%
  hc_plotOptions(column = list(stacking = "normal"), type = "datetime") %>% 
  hc_xAxis(
    title = list(text = 'Date'),
    type = 'datetime', 
    dateTimeLabelFormats = list(month = "%b-%y")
  ) %>% 
  hc_yAxis(
    title = list(text = "N"),
    allowDecimals=FALSE
  ) %>% 
  hc_add_theme(hc_theme_gridlight()) 
...