dreamRs / apexcharter

:bar_chart: R Htmlwidget for ApexCharts.js
https://dreamrs.github.io/apexcharter
Other
138 stars 15 forks source link

add_vline with dates on the x-axis not working #41

Closed meersel closed 3 years ago

meersel commented 3 years ago

Hi,

I want to a vertical line on my apexchart using the add_vline() function. My x-axis displays dates.

I have converted the date value for position of the vertical line into a numeric value (I think that this is required), however no vertical line is displayed on the chart.

See example code below:

apexcharter::add_vline(value = as.Date("2021-02-10") %>% as.numeric(), dash = 4, color = "red", label = "Hello")

Please advice how to solve this problem.

Looking forward to hear from you soon.

Met vriendelijke groet,

Miguel

pvictor commented 3 years ago

Hello,

If you use date on x-axis, you should use add_event to draw a vertical line:

library(apexcharter)
data("economics", package = "ggplot2")

apex(economics, aes(date, psavert), type = "line") %>% 
  add_event("2000-01-01", label = "Year 2000")

image

Victor

meersel commented 3 years ago

Hi Victor,

Many thanks for your quick response. Best regards,

Miguel Eersel e-mail: m.eersel@outlook.com

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: Victor Perriermailto:notifications@github.com Sent: Wednesday, February 10, 2021 8:21 AM To: dreamRs/apexchartermailto:apexcharter@noreply.github.com Cc: Miguel Eerselmailto:m.eersel@outlook.com; Authormailto:author@noreply.github.com Subject: Re: [dreamRs/apexcharter] add_vline with dates on the x-axis not working (#41)

Hello,

If you use date on x-axis, you should use add_event to draw a vertical line:

library(apexcharter)

data("economics", package = "ggplot2")

apex(economics, aes(date, psavert), type = "line") %>%

add_event("2000-01-01", label = "Year 2000")

[image]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F4415580%2F107503567-67783980-6b9a-11eb-946c-767a4e561e37.png&data=04%7C01%7C%7Cd252a504e3e647bec04f08d8cdb5fb60%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637485528813866796%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=nwkg1UP2vDRLcBb1ceQJOuxh0rjBZ5WWs50DUYWyxpM%3D&reserved=0

Victor

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FdreamRs%2Fapexcharter%2Fissues%2F41%23issuecomment-776639534&data=04%7C01%7C%7Cd252a504e3e647bec04f08d8cdb5fb60%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637485528813876797%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=GDOvuFqzlCRfXqSDRAHEDed05PJVDXWjKJXjgnLXC4A%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAHGET43EXGUHQTKVBCKUMNLS6JT2ZANCNFSM4XMFRVJA&data=04%7C01%7C%7Cd252a504e3e647bec04f08d8cdb5fb60%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637485528813876797%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=DWcKKChEOFe%2FoAdghnOTtgGr8Zf2wRRfYnudbrH1WAc%3D&reserved=0.