Overview
This topic discusses the ways in which the Gauge control can be rendered.
Rendering Methods
The Gauge control can be rendered in one of several ways:
- As an image tag with an associated temporary image saved to disk (default).
- Using binary streaming.
- As an input tag with an associated image saved to disk.
- As an image map (used for binary streaming and image maps only).
- As a Macromedia Flash file.
The RenderType property of the root GaugeContainer class determines the rendering method when the gauge is displayed as an image, and the default method is image tag rendering.
For information on how to stream real-time data back to client see the topic titled Real Time Data.
Each of the above mentioned methods for rendering a gauge control are discussed below.
Image Tag Method
With this method a gauge image is generated and then saved to disk at the server, in a format that is determined by the ImageType property of the root GaugeContainer class. The gauge image can be displayed as a BMP, JPEG, or PNG file, and is rendered via an <IMG> tag with its SRC attribute set to the image file saved to disk.
The URL where the image file is saved is determined by the ImageUrl property of the root GaugeContainer class. This property is very important when using the image tag method since this property can be used to:
- Control the maximum allowable number of image files that are generated, which allows you to take into account the deletion of these temporary files.
- Insert a warning into the Event Log if these temporary image files are being overwritten within a specified amount of time.
- Name files with a UID extension.
For more information see the topic on Managing Image Files.
Advantages
- The generated gauge image is cached by browsers when it has been displayed once.
- Simple to use since only one page is required.
Disadvantages
- Involves file operations, which are relatively slow.
It may be wise to employ this method if the gauge image rarely changes. For example, a temperature gauge that displays room temperature is not likely to fluctuate greatly under normal circumstances.
Binary Streaming Method
With this method the gauge image is sent directly to the client using the Binary.Write method. The gauge is implemented as an attribute of an html tag that displays an image (e.g., the Src attribute of an Image tag set to another .aspx page that generates the image, etc.). When the browser requests the gauge, it does this in the same manner as when it requests a static image from a web server.
This method should be employed if a web farm is being used, or if the gauge image is subject to frequent changes.
Note |
|---|
| When using Flash or SVG image types an <Embed> tag should be used to display the image. |
To use this method certain criteria must first be met:
- The .aspx page that is generating the gauge must be used as the source for a tag attribute in the page that displays the image (e.g., the Src
attribute of an Image tag, the imageUrl attribute of an ImageButton tag, etc.). This tag can be used within any web page (such as
Default.aspx) and there is no code used that is associated with the rendering of the gauge.
Example
ASPX (Default.aspx) <head> <body> <img src="gaugeRenderingPage.aspx"> </body> </head> - No html code can be put into the .aspx page that generates the image. Only Web Server control code and gauge XML code should be present. This page will only generate
the gauge image, and stream it to the requesting browser. The RenderType property of the
page that is generating the image must be set to BinaryStreaming.
Example
Code that resides in the gaugeRendering.aspx page.
ASPX (gaugeRenderingPage.aspx) <%@ Page Language="vb" AutoEventWireup="False" codebehind="WebForm1.aspx.vb" Inherits="VBGaugeWeb.WebForm1"%> <%@ Register TagPrefix="dgwc" Namespace="Dundas.Gauges.WebControl" Assembly="DundasWebGauges" %> <DGWC:GaugeContainer id="GaugeContainer1" style="Z-INDEX: 101; LEFT: 112px; POSITION: absolute; TOP: 58px" runat="server" Width="532px" Height="317px" RenderType="BinaryStreaming"> <Frame FrameStyle="None"></Frame> <CircularGauges> <DGWC:CircularGauge Name="Default"> <Ranges> <DGWC:CircularRange Name="Default"></DGWC:CircularRange> </Ranges> <Pointers> <DGWC:CircularPointer Name="Default"></DGWC:CircularPointer> </Pointers> <Frame FrameStyle="Edged"></Frame> <Scales> <DGWC:CircularScale Name="Default"> <MinorTickMark Shape="Rectangle" Length="3" Width="1"></MinorTickMark> </DGWC:CircularScale> </Scales> </DGWC:CircularGauge> </CircularGauges> <Values><DGWC:InputValue Name="Default"> </DGWC:InputValue> </Values> </DGWC:GaugeContainer>
Advantages
- No file I/O, thereby enhancing the control's performance.
- Works extremely well in a web-farm environment, since it does not matter which server actually processes the request.
Disadvantages
- No gauge caching occurs, thereby requiring the web server to regenerate the gauge each time it is requested.
- The page that generates the image cannot have any other html code in it (control code only).
- Two pages are required to be maintained.
If tooltips and hrefs are required with a binary streamed gauge, binary streaming becomes more complex.
For more information see the topic titled Client-Side Maps and Binary Streaming.
Input Tag Method
This method is similar to the "Image Tag Method", the difference being that the gauge's server-side Click event can be used to perform some action in response to the end-user clicking on a gauge element. Although an <Input> tag is used instead of an <Image> tag, the information given in the Image Tag Method concerning image file management, such as the ImageType and ImageUrl properties, still apply to the <Input> tag method.
The gauge element the end-user clicked on can be determined by using the HitTestResult object that is returned by the GaugeContainer.HitTest method.
Note |
|---|
| If you want to implement drill-down functionality we highly recommend using client-side image maps instead. |
Advantages
- The generated gauge image is cached by browsers when it has been displayed once.
- Simple to use since only one page is required.
Disadvantages
- This method involves using file operations, which are relatively slow.
Image Map Method
This method is only used to create an image map for the gauge when binary streaming is the rendering type (two instances of the gauge must be created). See the Client-Side Maps and Binary Streaming topic for further details.
Flash Rendering Method
Flash is a vector graphics-based image animation program owned by Macromedia Corporation. The viewer required to view Flash animated images is made available to the public, free of charge, by Macromedia. Flash files are often used in web pages to display animated graphics, and can also be played using a standalone Flash player.
Advantages
- Flash allows for the display of animated gauges, even if this capability has been disabled in the browser.
- Flash is both scalable and interactive.
- Flash gives the designer a large degree of control over how the animated graphics looks.
- Even if large amounts of data are being displayed on the gauge, the file size remains constant.
Disadvantages
- A Flash player may not be installed on the end-end-user's computer.
- In ASP.NET it is possible to specify a color of an image that will be painted as transparent. When using Flash this feature is not available.
Setting a gauge to render its images using a Flash format can be done by simply setting the ImageType property to Flash.
Web Rendering
Managing Image Files
Client-Side Image Maps
Real-Time Data
Real-Time Data An Overview
Note