Overview
The ImageStorageMode property defines the type of storage that will be used when the chart is rendered as an image. By default, this property is set to Auto, meaning that the ChartHttpHandler will be used if it is present in the configuration file. This property is very important when using the image tag method since it can optionally be used to: control the maximum allowable number of image files that are generated, thereby taking into account deletion of these temporary files; and be used to name files with a UID extension.
There are a variety of methods used to render the chart. Each one has its own distinct advantages and disadvantages, so it is up to you to decide the method that works best within your application.
Chart HTTP Handler
The Chart HTTP handler assists in processing Chart requests, either in memory or as a file.
Advantages
- Reduces hard drive operations by storing temp files in memory.
- Provides options for specifying a timeout, after which temp files are overwritten.
- Reduces temp file collisions in web-farm environments.
Disadvantages
- Requires the Chart HTTP Handler to be present in the configuration file.
For more information on the Chart HTTP Handler, see the topic on Image File Management.
Image URL
If the Chart HTTP handler is not used, the URL where the image file is saved is determined by the ImageUrl property of the root chart class.
For more information, see the topic on Image File Management.
Advantages
-
The generated chart 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.
This method should be used only if the chart image rarely changes.
Binary Streaming Method (HTML Image Tag Method)
With this method, the chart image is sent directly to the client using the Binary.Write method. The chart is implemented as an attribute of an html image tag that displays an image (e.g. the src attribute of the image tag is set to an .aspx page, etc.). When the browser requests the chart, it does this in the same way as it normally would request any static image from the web server.
This method should be implemented if a web farm is being used, or if the chart image frequently changes.
When using Flash or SVG image file formats, it is also advisable to use an <Embed> tag to display your chart images. |
In order to use any of the interactive features of the chart, it must be rendered using the HTML image tag method. Using any other method of rendering will void the use of interactive features. The only rendering type that supports AJAX is the ImageTag rendering type, which is not to be confused with the method described above. |
Certain criteria must be met before this method can be used:
-
The .aspx page that is generating the chart must be used as the source for a tag attribute that specifies an 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 and there is no code used that is associated with the rendering of the chart.
<img src="ChartRenderingPage.aspx">
-
No html code can be in the .aspx page generating the image - only Web Server control code and Chart XML should be present. This page will only generate the chart image and stream it to the requesting browser.
HTML Copy Code <%@ Page language="c#" Codebehind="ChartRenderingPage.aspx.cs" AutoEventWireup="false"
Inherits="ProjectNameSpace.ChartRenderingPage" %>
<%@ Register TagPrefix="dcwc" Namespace="Dundas.Charting.WebControl" Assembly="DundasWebChart" %>
<DCWC:CHART id="Chart1" runat="server" RenderType="BinaryStreaming" ImageType="Png" >
<Series>
<dcwc:Series ChartType="SplineArea" Name="Series1">
<Points>
<dcwc:DataPoint YValues="6"></dcwc:DataPoint>
<dcwc:DataPoint YValues="9"></dcwc:DataPoint>
<dcwc:DataPoint YValues="3"></dcwc:DataPoint>
</Points>
</dcwc:Series>
</Series>
<ChartAreas>
<dcwc:ChartArea BorderColor="" Name="Default" BackColor="Transparent">
</dcwc:ChartArea>
</ChartAreas>
</DCWC:CHART>
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 chart caching occurs thus requiring the web server to regenerate the chart 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 chart, binary streaming becomes more complex. Please see the Binary Streaming and Image Maps topic for further details.
Input Tag Method
This method is similar to the HTML Image Tag Method shown above, but the difference is that the chart's server-side Click event is used to perform some action in response to the user clicking on a chart element. Although an <Input> tag is used instead of an <Image> tag, the information given in the Image Tag Method concerning the image file management, ImageType, and ImageUrl properties all still apply to the <Input> tag method.
The chart element that was clicked, can be determined using the ImageClickEventArgs object along with the Select method.
Note |
---|
If you want to implement drilldown, we recommend using client-side image maps instead of input tags. |
Advantages
-
The generated chart 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.
Image Map Method
This method is only used to create an image map for the chart when binary streaming is the rendering type (two instances of the chart must be created).
For more information, see the topic on Binary Streaming and Image Maps.