Rendering graphs

Graphs can be displayed in a DataWindow in a standalone image file or in an image stream embedded into the Web page. You specify how you want the graph to be rendered by setting the RenderOption property in the GraphConfigurations section in the WebDataWindowControl’s Properties window or in code. You can use the graph presentation style to display a graph in a Web DataWindow, or a supported presentation style such as tablular or freeform. Graphs do not display in Web DataWindows with the grid presentation style.

Using an image file

If you set the RenderOption property to ImageFile, the rendering of the graph object is saved into a temporary file on the Web server and an image URL is generated to reference the temporary image file. The physical directory in which the temporary image file is stored and the URL path are specified in the GraphDynamicImageFileUrlPath property. This property must specify a URL path in your Web application virtual directory, and it must be a path that can be mapped to a writable physical directory in your Web application's physical directory.

Using an image stream

If you set the RenderOption property to ImageStream, the rendering of the graph object is saved into a memory stream in the session cache in a StreamImageContainer and the stream is output to a page whose content type is “image/imageformat”, where imageformat is gif, jpeg, or png. The URL reference to the image, set in the StreamImageContainerPage property, points to this page instead of to an image file.

Image file formats

You can choose to render the graph in GIF, JPEG, or PNG formats. You select the image format you want by setting the ImageFormat property of the GraphConfigurations class to a value of the GraphImageFormat enumerated variable. The default image format is PNG. which provides superior rendering and a smaller footprint than JPEG.. Choose GIF is you want to reduce the footprint to a minimum at the cost of some loss of rendering quality.

Write permission for directories for generated files

When you specify a path for dynamically generated files, make sure that the ASP.NET account (or, for Windows 2003 server, the IIS_WPG user group) has write permission to the directories. For more information, see the Microsoft documentation.

Example

This Visual Basic code sets the RenderOption and other properties based on a user’s choice in a radio button:

If rb_format.SelectedIndex = 0 Then
  dw1.GraphConfigurations.RenderOption =  _
   Sybase.DataWindow.Web.GraphRenderOption.ImageStream

  dw1.GraphConfigurations.StreamImageContainerPage = _
   "StreamImageContainerPage.aspx"
Else
  dw1.GraphConfigurations.RenderOption =  _
   Sybase.DataWindow.Web.GraphRenderOption.ImageFile
  dw1.GraphConfigurations.  _
   GraphDynamicImageFileUrlPath = "image/"
End If

dw1.Retrieve()