Create a chart without rendering it within the calling page.

Expand / Collapse
 

Create a chart without rendering it within the calling page.


QUESTION

Can a chart image file be created without rendering the chart in the calling ASP.NET page?

ANSWER

Yes, you can even have .netCHARTING save and manage the removal of the files on your server. The easiest way to do this is shown below and works with all formats.

[C#]

Chart chart = new Chart();
[ .. set chart properties .. ]
chart.ImageFormat = dotnetCHARTING.ImageFormat.Jpg;

string fileName = chart.FileManager.SaveImage();
 

 
[Visual Basic]

Dim chart As New Chart()
[ .. set chart properties .. ]
chart.ImageFormat = dotnetCHARTING.ImageFormat.Jpg;

Dim fileName As New String
fileName = chart.FileManager.SaveImage()
 

Getting Image Objects

Alternatively, if access to a bitmap or metafile object is required the following methods can be used to achieve the same.

ONLY FORMATS: Jpg, Png, Bmp, Tif

 

[C#]

Chart chart = new Chart();
[ .. set chart properties .. ]
Bitmap bmp = chart.GetChartBitmap();

// Now the chart can be saved as a file on the server as well.
string fileName = chart.FileManager.SaveImage(bmp);
 

 
[Visual Basic]

Dim chart As New Chart()
[ .. set chart properties .. ]
Dim bmp As New Bitmap()
bmp = chart.GetChartBitmap()

// Now the chart can be saved as a file on the server as well.
Dim fileName As New String
fileName = chart.FileManager.SaveImage(bmp)
 

FORMATS: Emf, Swf, Pdf, Svg, Xaml

For these formats you can have .netCHARTING save and manage the files on your server.

[C#]

Chart chart = new Chart();
[ .. set chart properties .. ]
chart.ImageFormat = ImageFormat.Swf;
MemoryStream ms = chart.GetChartStream(); 

 

 
[Visual Basic]

Dim chart As New Chart()
[ .. set chart properties .. ]
chart.ImageFormat = ImageFormat.Swf;
Dim ms As New MemoryStream()
ms = chart.GetChartStream() 

 



Rate this Article:
     

Add Your Comments


Comment require login or registration.

Details
Last Modified:Friday, June 06, 2008
Last Modified By: Support
Type: HOWTO
Rated 3 stars based on 38 votes.
Article has been viewed 18,548 times.
Options