bugfix: group order

This commit is contained in:
pvictor 2020-01-14 11:09:24 +01:00
parent 38b648ed6d
commit 34eeddfa06
2 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,5 @@
Package: apexcharter
Version: 0.1.3
Version: 0.1.3.900
Title: Create Interactive Chart with the JavaScript 'ApexCharts' Library
Description: Provides an 'htmlwidgets' interface to 'apexcharts.js'.
'Apexcharts' is a modern JavaScript charting library to build interactive charts and visualizations with simple API.
@ -29,7 +29,7 @@ Suggests:
shiny,
gapminder,
highcharter
RoxygenNote: 7.0.1
RoxygenNote: 7.0.2
URL: https://github.com/dreamRs/apexcharter, https://dreamrs.github.io/apexcharter
BugReports: https://github.com/dreamRs/apexcharter/issues
VignetteBuilder: knitr

View File

@ -53,6 +53,7 @@ apex <- function(data, mapping, type = "column", ..., auto_update = TRUE, width
make_series <- function(mapdata, mapping, type) {
mapdata <- as.data.frame(mapdata)
series_names <- "Series"
x_order <- unique(mapdata$x)
if (is_x_datetime(mapdata)) {
add_names <- FALSE
} else {
@ -66,11 +67,16 @@ make_series <- function(mapdata, mapping, type) {
))
if (is_grouped(names(mapping))) {
mapdata <- rename_aes(mapdata)
len_grp <- tapply(mapdata$group, mapdata$group, length)
if (length(unique(len_grp)) > 1) {
warning("apex: all groups must have same length! Use can use `tidyr::complete` for this.")
}
series <- lapply(
X = unique(mapdata$group),
FUN = function(x) {
data <- mapdata[mapdata$group %in% x, ]
data <- data[, setdiff(names(data), "group"), drop = FALSE]
data <- data[match(x = x_order, table = data$x, nomatch = 0L), , drop = FALSE]
list(
name = x,
data = parse_df(