none
Specifying graphics device svg in the API does not work properly RRS feed

  • Question

  • I am building a web application in ASP.Net MVC, which will use deployR for calculations. I am using the client library for .Net, using the client library for .Net tutorial, version 8.0.0.

    I would like to have my plots generated as svg. According to the client library tutorial, this should be possible, using the graphicsDevice property of the ProjectExecutionOptions. However, this doesn't work for me. (The tutorial uses the property 'graphics', but no such property exist.)

    If I set the property to "svg", I still get a png image.

    This is my client code:

    String deployrEndpoint = "http://localhost:8000/deployr";
    RClient rClient = RClientFactory.createClient(deployrEndpoint);
    
    RAuthentication authToken = new RBasicAuthentication("testuser", "************");
    RUser rUser = rClient.login(authToken);
    
    ProjectExecutionOptions options = new ProjectExecutionOptions();
    options.graphicsDevice = "svg";
    
    RProject rProject = rUser.createProject();
    RProjectExecution exec = rProject.executeScript("plot", "testuser", null, options);
    
    List<RProjectResult> results = exec.about().results;
    string imageUrl = results[0].about().url;

    And this is the script plot.R:

    series <- c(1, 3, 2, 5, 2)
    plot(series)

    The imageUrl will just be http://<ip>:8000/deployr/r/project/execute/result/download/PROJECT-<guid>/EXEC-<guid>/unnamedplot001.png, and when I get the image, this is indeed a png image.

    What must I do to get svg images?

    • Edited by rs23771 Friday, June 17, 2016 9:22 AM added deployR version
    Friday, June 17, 2016 8:49 AM

All replies

  • As a work-around, I tried the following.

    In the script I inserted the following line above the call to plot:

    svg(filename="plot.svg", width=5, height=4, pointsize=12)
    

    Running the script in the Repository Manager gave me a nice svg plot.

    Then I needed to change my client code, because the plot is now returned as an artifact rather than as a result:

    List<RProjectFile> artifacts = exec.about().artifacts;
    string imageUrl = artifacts[0].about().url;
    

    However, I am not really pleased with this work-around, as now the imageUrl is something like: http://<ip>:8000/deployr/r/project/directory/download/PROJECT-<guid>/plot.svg, so without an execution-specific part in the url. The real application has user-defined input, so each execution may give a different result and I don't want results from different execution being messed up, neither by page reloads, nor by http-caching.

    So, I am still looking for a way to use graphicsDevice.

    Friday, June 17, 2016 9:22 AM