Plot and ggplot

I have a weird error: the following plot works fine with a high range of DateTime (x) and with the last month (Ene - January). (The error didn't derive from any shiny function).

image

But, when I try to make a graph by mean of shiny app, with a lower range (A week Feb. 01 - Feb. 07), it doesn't show anything. There is not an error:

This is the code:

ui = fluidPage(navbarPage(
                   'TF Analytics',
                   tabPanel('Overview',
                            sidebarPanel(
                                textInput("text", label = h3("Text input"), value = "Enter text..."),
                                dateRangeInput("dates", label = h3("Date range")),
                                actionButton("action", label = "+")
                            ), mainPanel(
                                plotOutput(outputId = "plot")
                            )))
               ))

server = function(input, output) {
    
    newsData = function() {code to return a tibble}    
    
    observeEvent(input$action,{
        p = plot(as.POSIXct(newsData()$time,format="%Y/%m/%d %H:%M:%S", tz="UTC"), 
                          newsData()$difprev, type = "h")
        output$plot = renderPlot({
            p
        })
    })
}

shinyApp(ui = ui, server = server)

I used lubridate::as_datetime(), but it is the same.

What can I do? :smiley:

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

Hi. Thanks for the reccomendation . This is the tibble:

data = tibble::tribble(
  ~currency,                 ~time, ~difprev, ~difcst, ~n, ~init,
  "AUD", "2021/02/01 00:00:00",      0.6,       0, 1L,     0,
  "AUD", "2021/02/01 00:30:00",    0.442,       0, 2L,     0,
  "AUD", "2021/02/01 05:30:00",   -0.551,       0, 1L,     0,
  "AUD", "2021/02/01 06:30:00",     0.03,       0, 1L,     0,
  "AUD", "2021/02/02 01:30:00",        0,       0, 1L,     0,
  "AUD", "2021/02/02 03:30:00",        0,       0, 2L,     0,
  "AUD", "2021/02/02 21:30:00",   -0.042,       0, 1L,     0,
  "AUD", "2021/02/02 22:00:00",    0.025,       0, 1L,     0,
  "AUD", "2021/02/03 00:30:00",   -3.893,       0, 3L,     0,
  "AUD", "2021/02/03 01:30:00",        0,       0, 1L,     0,
  "AUD", "2021/02/04 00:30:00",    3.599,       0, 4L,     0,
  "AUD", "2021/02/04 21:30:00",   -0.026,       0, 1L,     0,
  "AUD", "2021/02/04 22:30:00",        0,       0, 1L,     0,
  "AUD", "2021/02/05 00:30:00",    0.639,  -0.583, 3L,     0,
  "AUD", "2021/02/05 20:30:00",    2.875,       0, 1L,     0,
  "CAD", "2021/02/01 06:30:00",    0.042,       0, 1L,     0,
  "CAD", "2021/02/01 14:30:00",     0.06,       0, 1L,     0,
  "CAD", "2021/02/05 13:30:00", -127.898,   0.053, 8L,     0,
  "CAD", "2021/02/05 15:00:00",    -0.07,       0, 2L,     0,
  "CAD", "2021/02/05 20:30:00",   -0.167,       0, 1L,     0
)
head(data)
plot(anytime::utctime(data$time, tz="UTC"), data$difprev, type = "h")

But in Shiny the result didn't show me anything:

What do input$text and input$dates do?

They don't appear in your code.

Hi! These parameters make me rescue the table that I want to plot according to the name of the table (input$text) and the range of DateTime (input$dates). The table is on my database (MySql) and the function newsData() just returns the table required. The same table that I named as "data". I think I don't have any problem with these inputs. In my first post, I wrote the code related to my shiny app.

pd: data = newsData() in my Shiny app

The error seems to be a bug because the code of the plot is perfect.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.