dreamRs / apexcharter

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

Candlestick data example #20

Closed Alik-V closed 4 years ago

Alik-V commented 4 years ago

Hi Victor,

I hope you have been well. Thank you for the recent update to the package! The candlestick functionality comes at a perfect timing of needing to integrate a waterfall chart in my shiny app. And since I am using apexcharter exclusively for my plots, it would be great for me to try to make it by adjusting the candlestick plot you recently added.

My question is the following: having never dealt with candlestick plots before, I understand that the data structure needs to be slightly different. Could you please give a basic example of how the data and the chart code supposed to look like?

Best, Alik

pvictor commented 4 years ago

Hi Alik,

Everything's fine here, hope you too. Thanks for your kind words.

Here's an example for the candlestick chart :

library(apexcharter)
data("candles")
apex(
  candles,
  aes(x = datetime, open = open, close = close, low = low, high = high),
  type = "candlestick"
)

candles is a data.frame with five columns. If you use the full API you can use a structure like :

list(
  list(
    x = "2020-07-02",
    y = list(1, 2, 3, 4)
  ),
  list(
    x = "2020-07-03",
    y = list(1, 2, 3, 4)
  )
)

But maybe for something that look like waterfall you can do something like this : https://apexcharts.com/javascript-chart-demos/column-charts/range-column-chart/ ? It's not implemented yet with apex() but doable with the full API.

Have a nice day,

Victor

Alik-V commented 4 years ago

Thank you!