共用方式為


Box Plot Chart (Chart Controls)

The Box Plot chart type consists of one or more box symbols that summarize the distribution of the data within one or more data sets. A Box Plot chart displays a vertical rectangle with whisker lines extending from both ends.

The values for a box are typically calculated values from data that is present in another series. One box symbol (DataPoint object) is associated with one data series. The data for a Box Plot series may still be populated using data binding, or by employing the Series.Points member (a DataPointCollection object).

Picture of the Box Plot chart type

Chart Characteristics

SeriesChartType value

SeriesChartType.BoxPlot

Number of Y values per point

Six or more (see table below).

Number of series

1

Supports markers

No

Cannot be combined with:

Doughnut, Pie, or Bar charts.

Custom attributes

BoxPlotPercentile, BoxPlotSeries, BoxPlotShowAverage, BoxPlotShowMedian, BoxPlotShowUnusualValues, BoxPlotWhiskerPercentile, DrawSideBySide, MaxPixelPointWidth, MinPixelPointWidth, PixelPointDepth, PixelPointGapDepth, PixelPointWidth, PointWidth

A Box Plot series uses at least six Y values. However, additional Y values may be added and plotted as markers (known as unusual points). The ordering of the values is important because each value represents a point on the chart.

Y Values Index Y Value

0

Lower whisker

1

Upper whisker

2

Lower box

3

Upper box

4

Average and mean

5

Median

>=6

Other unusual points, as the average or median marker can be hidden if the marker's Y value is set to double.NaN.

Remarks

Median and average box lines are drawn by default, but can be hidden using the BoxPlotShowMedian and BoxPlotShowAverage custom attributes. The following code removes the median and average box lines.

Chart1.Series("Series1")("BoxPlotShowMedian")="false"
Chart1.Series("Series1")("BoxPlotShowAverage")="false"
Chart1.Series["Series1"]["BoxPlotShowMedian"]="false";
Chart1.Series["Series1"]["BoxPlotShowAverage"]="false";

Optionally, values from original data series that are outside of the whisker values can be displayed as individual values to the box plot. To enable this feature, use the BoxPlotShowUnusualValues custom attribute. The following code demonstrates this.

Chart1.Series("Series1")("BoxPlotShowUnusualValues")="true"
Chart1.Series[Series1"]["BoxPlotShowUnusualValues"]="true"

Calculated Box Plot Values

The custom attribute , BoxPlotSeries is used to attach the box chart type to one or more existing series (by name) to be used for calculations. This custom attribute can be set for the entire series or for each individual data points of the box chart. When set to the series, the BoxPlotSeries contains one or more semi-colon separated series names. As a result each Box Plot point values will be calculated and added for each series specified in the , BoxPlotSeries custom attribute.

If BoxPlotSeries is set in a DataPoint object only, then only one series can be specified. The first Y value of the series will be used by default. Optionally, with the name of the series, the user can specify which value to use.

Chart1.Series("Series1")("BoxPlotSeries")="Price:Y2;Volume"
Chart1.Series["Series1"]["BoxPlotSeries"]="Price:Y2;Volume";

By default, the upper and lower box values are calculated using the 25th/75th percentile. The whisker values are calculated using the 10th/90th percentile. This behavior can be changed using the BoxPlotPercentile and BoxPlotWhiskerPercentile custom attributes. The following code demonstrates how to change the upper and lower box values to the 30th/70th percentile and the whisker values to the 5th/95th percentile.

Chart1.Series("Series1")("BoxPlotPercentile")="30"
Chart1.Series("Series1")("BoxPlotWhiskerPercentile")="5"
Chart1.Series["Series1"]["BoxPlotPercentile"]="30";
Chart1.Series["Series1"]["BoxPlotWhiskerPercentile"]="5";

Example

The following example demonstrates how to make a 15th percentile Box Plot chart.

' Add data to Box Plot Source series.
Dim yValues As Double() = {55.62, 45.54, 73.45, 9.73, 88.42, 45.9, 63.6, 85.1,67.2, 23.6}
Chart1.Series("DataSeries").Points.DataBindY(yValues)

' Specify data series name for the Box Plot.
Chart1.Series("BoxPlotSeries")("BoxPlotSeries") = "DataSeries"

' Set other custom attributes
Chart1.Series("BoxPlotSeries")("BoxPlotWhiskerPercentile") = "15"
Chart1.Series("BoxPlotSeries")("BoxPlotShowAverage") = "true"
Chart1.Series("BoxPlotSeries")("BoxPlotShowMedian") = "true"
Chart1.Series("BoxPlotSeries")("BoxPlotShowUnusualValues") = "true"
// Add data to Box Plot Source series.
yValues = {55.62, 45.54, 73.45, 9.73, 88.42, 45.9, 63.6, 85.1, 67.2, 23.6};
Chart1.Series["DataSeries"].Points.DataBindY(yValues);

// Specify data series name for the Box Plot.
Chart1.Series["BoxPlotSeries"]["BoxPlotSeries"] = "DataSeries";

// Set other custom attributes
Chart1.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "15";
Chart1.Series["BoxPlotSeries"]["BoxPlotShowAverage"] = "true";
Chart1.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";
Chart1.Series["BoxPlotSeries"]["BoxPlotShowUnusualValues"] = "true";

See Also

Reference

Chart Types
Candlestick Chart
System.Windows.Forms.DataVisualization.Charting
System.Web.UI.DataVisualization.Charting