Graph outputs - not appearing

Everything related to the development of modules in jamovi
Post Reply
rjwatt42
Posts: 10
Joined: Sun Oct 08, 2023 10:22 am

Graph outputs - not appearing

Post by rjwatt42 »

Hello

I have a module under development that runs a set of simulations and produces a graph as output. So long as the number of simulations allows the process to finish in maybe 15sec, then all is well. If the number of simulations is too big, then the graph never appears, and Jamovi just gets stuck with the circling icon indicating it is waiting for output.

The structure of the graph itself is unaffected by the number of simulations: the points may be in slightly different places but the number of points, lines, polygons is not affected.

I've tried various things and can't be sure what's happening. For example, I placed a deliberate error after the simulations have finished but before the graph is sent to Jamovi:

Code: Select all

        y2<-y1
        self$results$graphPlot$setState(outputGraph)
This triggers an error (there is no variable y1) and so I know the simulations have ended. If I place the same line here:

Code: Select all

    .plotGraph=function(image, ...) {
      outputGraph <- image$state
      if (!is.null(outputGraph)) {
        y2<-y1
        print(outputGraph)
        TRUE
      } else {
        FALSE
      }
    },
then the error is not triggered, suggesting that the code is stuck at that point.

The code that generates the graph works fine as stand alone. Actually if I replace the
setState line with this (but leave the simulations happening) then I still get the problem:

Code: Select all

   
        self$results$graphPlot$setState(ggplot())
this suggests that the graph is not the problem.

So I'm wondering about two possibilities.
1. the amount of data generated is increased by increasing the number of simulations - so is there a storage issue of some sort? The bytes required are not great, however.
2. is there a time-out for the .plotGraph function.

Any thoughts/suggestions would be very welcome.
Roger
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: Graph outputs - not appearing

Post by jonathon »

hi roger,

the issue might be the size of the state object. see the warning here:

https://dev.jamovi.org/tuts0203-state.html#setstate()

see if you can shift the actual plotting into the plot function itself.

(did you want an invite to our slack group? you may find its easier to ask questions to do with module development through that)

jonathon
rjwatt42
Posts: 10
Joined: Sun Oct 08, 2023 10:22 am

Re: Graph outputs - not appearing

Post by rjwatt42 »

Many thanks Jonathon - and yes I would be very happy to get an invite.

I'll try that, So, instead of making the ggplot object inside .run() make just the data inside .run() and then pass those to .plotGraph() and build the ggplot() object there.

I'll email you separately about what I am doing - in case it is of some interest to you.
Post Reply