Closed meersel closed 3 years ago
Hello,
Currently apex()
does not reorder the data, they are represented as they are.
To order the chart, you can add an arrange
in your pipeline :
library(apexcharter)
library(dplyr)
library(forcats)
data("mpg", package = "ggplot2")
n_manufac <- count(mpg, manufacturer) %>%
mutate(manufacturer = fct_reorder(manufacturer, n)) %>%
arrange(desc(manufacturer)) # <--- sort your data
apex(
data = n_manufac,
type = "bar",
mapping = aes(x = manufacturer, y = n)
)
Which gives
Victor
Hi Victor,
Thanks for your quick reply.
A simple and workable solution.
Kind regards,
Miguel Eersel e-mail: m.eersel@outlook.commailto:m.eersel@outlook.com mobile(WhatsApp) + 597-864 2328
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: Victor Perriermailto:notifications@github.com Sent: Monday, July 20, 2020 7:22 AM To: dreamRs/apexchartermailto:apexcharter@noreply.github.com Cc: meerselmailto:m.eersel@outlook.com; Authormailto:author@noreply.github.com Subject: Re: [dreamRs/apexcharter] Order bar chart from large to small (#24)
Hello,
Currently apex() does not reorder the data, they are represented as they are. To order the chart, you can add an arrange in your pipeline :
library(apexcharter)
library(dplyr)
library(forcats)
data("mpg", package = "ggplot2")
n_manufac <- count(mpg, manufacturer) %>%
mutate(manufacturer = fct_reorder(manufacturer, n)) %>%
arrange(desc(manufacturer)) # <--- sort your data
apex(
data = n_manufac,
type = "bar",
mapping = aes(x = manufacturer, y = n)
)
Which gives
Victor
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FdreamRs%2Fapexcharter%2Fissues%2F24%23issuecomment-660941821&data=02%7C01%7C%7C83090fa0feec4c5f1da908d82c96d306%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637308373573603172&sdata=e7Ymgc4VKRucdmWUJggCcQkP%2B1rY79k%2BgRk6s4pwa%2Bs%3D&reserved=0, or unsubscribehttps://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAHGET43WYIZJZMDHJAJZETTR4QLGXANCNFSM4PBYVMIA&data=02%7C01%7C%7C83090fa0feec4c5f1da908d82c96d306%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637308373573603172&sdata=MkEYsO6EeHr%2F72DIrzkGy3sJIVcuTYRSC1URk3Ql1uM%3D&reserved=0.
HI Victor,
Is the Dynamic Series Update functionality available (see below) in the R Apexcharter package ?
[cid:image003.png@01D6A802.2441A090]
If so, would you be so kind to provide me with an R code example how to use this ?
Thanks in advance.
Kind regards/Met vriendelijke groet,
Miguel (a fan of the apexcharter R package) e-mail: m.eersel@outllook.com
Hi ApexCharter Developer's team.
Can you please advice me how to order a bar chart output such that the bars are shown from large to small..
I have tried the following standard ggplot2 way of doing this (see below) but this does not work for apexcharter.
data("mpg") n_manufac <- count(mpg, manufacturer) %>% mutate(manufacturer = fct_reorder(manufacturer,n))
apex(data = n_manufac, type = "bar", mapping = aes(x = manufacturer, y = n))
Kind regards,
Miguel