Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Chart.AddSeries Method

Provides data points and series attributes for the chart.

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

public Chart AddSeries(
	string name,
	string chartType,
	string chartArea,
	string axisLabel,
	string legend,
	int markerStep,
	IEnumerable xValue,
	string xField,
	IEnumerable yValues,
	string yFields
)

Parameters

name
Type: System.String
The unique name of the series.
chartType
Type: System.String
The chart type of a series.
chartArea
Type: System.String
The name of the chart area that is used to plot the data series.
axisLabel
Type: System.String
The axis label text for the series.
legend
Type: System.String
The name of the series that is associated with the legend.
markerStep
Type: System.Int32
The granularity of data point markers.
xValue
Type: System.Collections.IEnumerable
The values to plot along the x-axis.
xField
Type: System.String
The name of the field for x-values.
yValues
Type: System.Collections.IEnumerable
The values to plot along the y-axis.
yFields
Type: System.String
A comma-separated list of name or names of the field or fields for y-values.

Return Value

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

The following example shows how to use the AddSeries method to create a chart image based on an array of values.


@{ 
    var basicChart = new Chart(width: 600, height: 400) 
        .AddTitle("Chart Title") 
        .AddSeries( 
            name: "Employee", 
            xValue: new[] {  "Peter", "Andrew", "Julie", "Mary", "Dave" }, 
            yValues: new[] { "2", "6", "4", "5", "3" }) 
        .Write(); 
}


In this example, you use the name, xValue, and yValues parameters of the AddSeries method. The name parameter is displayed in the chart legend. The xValue parameter contains an array of data that is displayed along the horizontal axis of the chart. The yValues parameter contains an array of data this is used to plot the vertical points of the chart.

  • Medium trust for the immediate caller. This member can be used by partially trusted code.
Show:
© 2015 Microsoft