I'm trying to use the amXYChart() function for the first time and I would like to represent two lines on the same plot but I don't manage to.
For example with that dataset. I can represent one line with the code below.
x <- data.frame("value" = 1:5, "cats" = c(10,20,30,40,50), "dogs" = c(15,25,35,36,48))
amXYChart(x="value", y="dogs", dataProvider=x, keepNA = TRUE) %>%
addGraph(xField = "value", yField = "dogs")
However when I try to represent the two lines, my plot window is empty (Only the x axis is displayed).
x <- data.frame("value" = 1:5, "cats" = c(10,20,30,40,50), "dogs" = c(15,25,35,36,48))
amXYChart(x="value", y=c("cats","dogs"), dataProvider=x, keepNA = TRUE) %>%
addGraph(xField = "value", yField = c("cats","dogs"))
Also I'm trying to use this package because of interactivity but when I place my curser of the plot (the first one) nothing appears. With the example below it works perfectly.
library(lubridate)
data("data_stock_2")
amTimeSeries(data_stock_2, 'date', c('ts1', 'ts2'))
Is interactivity only for time series data ?
Thanks very much for helping !
I suggest to use amSerialChart
as follows:
amSerialChart(dataProvider=dts, keepNA = TRUE, categoryField="value") %>%
addGraph(valueField = "cats") %>%
addGraph(valueField = "dogs") %>%
setChartCursor()
or
vars <- c("cats", "dogs")
p <- amSerialChart(dataProvider=dts, keepNA = TRUE, categoryField="value")
for (vark in vars) {
p <- p %>% addGraph(valueField = vark)
}
p %>% setChartCursor()