Chart.Save Method

Saves a chart image to the specified file.

Namespace:  System.Web.Helpers
Assembly:  System.Web.Helpers (in System.Web.Helpers.dll)

public Chart Save(
	string path,
	string format


Type: System.String
The location and name of the image file.
Type: System.String
The image file format, such as "png" or "jpeg".

Return Value

Type: System.Web.Helpers.Chart
The chart.

The following example shows how to render the chart image using the Save method.

    var filePathName = "_ChartFiles/chart01.jpg"; 
    if (!File.Exists(Server.MapPath(filePathName))) { 
        var chartImage = new Chart(600, 400); 
        chartImage.AddTitle("Chart Title"); 
                name: "Employee", 
                axisLabel: "Name", 
                xValue: new[] {  "Peter", "Andrew", "Julie", "Mary", "Dave" }, 
                yValues: new[] { "2", "6", "4", "5", "3" }); 
        chartImage.Save(path: filePathName); 
<!DOCTYPE html> 
        <title>Chart Example</title> 
        <img src="@filePathName" />  

  • Medium trust for the immediate caller. This member can be used by partially trusted code.