Search code examples
javascriptangularjsropencpu

Invalid graphics state opencpu


I'm currently using opencpu to host my R packages. But it is not displaying the graph. I get the pdf, svg and pdf links and the graph is displayed if I click on either one of them. However, within the console I have this error "invalid graphics state In call:replayPlot(x)".

The following is my R function.

plotGraph <- function(filename) {
  filepath<-system.file("extdata", filename, package="demp")
  sample<-read.csv(filepath,header=FALSE)
  ecg=sample[2]
  graph<-plot.ts(ecg)
}

And the following is my angularjs code.

$scope.getData= function(filename){
        filename=$scope.selectedFile+".csv";    
        var req=$("#output").rplot("plotGraph", {
            filename:filename
        });
}

And the div in the webpage:

<div id="output"></div>

Solution

  • I have managed to solve it by specifying the height and width of the div like this

    <div id="output" style="height: 900px; width:900px"></div>