Hi,

 

I don't use a custom graphics device. What I do is create a normal
graphics in R that is save to a file and stream this to the browser as
an image. See the code below.

 

Regards,

Henk  Jan

  protected override void Render(HtmlTextWriter writer)

  {

    //base.Render(writer);

    string plotfilename;

    bool doDelete = false;

    if (Config.Name != null)

    {

      plotfilename = physicalPath(Config.TempPlotFilePath);

      if (File.Exists(plotfilename))

      {

        File.Delete(plotfilename);

      }

      try

      {

        string plottype = varValue("plottype");

        string legendlocation = varValue("legend");

 

// This is my method that creates the image file

        Cox.plot(plotfilename, DrawData, plottype,legendlocation, 600,
500, false);

        doDelete = true;

      }

      catch {

        plotfilename = Server.MapPath("~/images/error.gif");

      }

    }

    else

    {

      plotfilename = Server.MapPath("emptyCox.png");

    }

    System.Drawing.Image i =
System.Drawing.Image.FromFile(plotfilename);

    MemoryStream tempStream = new MemoryStream();

    i.Save(tempStream, ImageFormat.Png);

    Response.ClearContent();

    Response.Cache.SetCacheability(HttpCacheability.NoCache);

    Response.ContentType = "image/png";

    Response.BinaryWrite(tempStream.ToArray());

    tempStream.Close();

    i.Dispose();

    if (doDelete && File.Exists(plotfilename))

    {

      File.Delete(plotfilename);

    }

    Response.End();

  }

 

 

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Irvine,
Lynne
Sent: Monday, October 06, 2008 6:49 PM
To: R (D)COM and RExcel server related issues
Subject: Help for a Beginner please

 

I think R is great and I would really like to use it generate graphics
from my VB.NET application, but I am having a really hard time trying to
get it work. It appears to run ok, but I can't generate any plots at
all, either directly to the web page or to a plot file.  Looking through
the list it appears that others have trodden this path before me, so I
am hoping that someone can help me get on the right track. 

 

I am using Microsoft Visual Studio .NET 2003,  R V 2.6.1 and R(D)COM
Server V1.35.

 

The test code I am using is:

 Dim xconnector As STATCONNECTORSRVLib.StatConnector
        xconnector = New STATCONNECTORSRVLib.StatConnector

        xconnector.Init("R")

        Dim StatConnectorGraphicsDevice1 As New
StatConnectorGraphicsDevice
  Dim mygfx As StatConnectorGraphicsDevice
        mygfx = StatConnectorGraphicsDevice1

        xconnector.AddGraphicsDevice("mygfx",
StatConnectorGraphicsDevice1.GetGFX())

        xconnector.EvaluateNoReturn("plot(sin(1:100))")
        xconnector.RemoveGraphicsDevice("gfx")
        xconnector.EvaluateNoReturn("Finish")
        xconnector.Close()


With initial Imports statements:

 

Imports STATCONNECTORCLNTLib
Imports STATCONNECTORSRVLib
Imports StatConnControls.GraphicsDeviceClass

 

The Build is ok and everything appears to execute ok, but no plot. Any
ideas please?

 

_______________________________________________
Rcom-l mailing list
Rcom-l@mailman.csd.univie.ac.at
http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l
More information (including a Wiki) at http://rcom.univie.ac.at

Reply via email to