盒须图

盒须图类型由一个或多个框符号组成,这些符号大致表示一个或多个数据集中的数据的分布。盒须图显示一个垂直矩形,从矩形两端延伸出须线。

框的值通常是根据其他序列中的数据计算得出的值。一个框符号(DataPoint 对象)与一个数据序列关联。盒须图序列的数据仍可以通过数据绑定进行填充,也可以使用 Series.Points 成员(DataPointCollection 对象)进行填充。

SeriesChartTypeBoxPlot

图表特征

SeriesChartType 值

SeriesChartType.BoxPlot

每个点的 Y 值数目

六个或更多(请参见下表)。

序列数目

1

支持标记

不能与之一起使用的图表类型:

圆环图饼图条形图

自定义特性

BoxPlotPercentileBoxPlotSeriesBoxPlotShowAverageBoxPlotShowMedianBoxPlotShowUnusualValuesBoxPlotWhiskerPercentileDrawSideBySideMaxPixelPointWidthMinPixelPointWidthPixelPointDepthPixelPointGapDepthPixelPointWidthPointWidth

盒须图序列至少使用六个 Y 值。不过,可以添加更多 Y 值,并绘制为标记(称为特殊点)。值的顺序十分重要,因为每个值都表示图上的一个点。

Y 值索引

Y 值

0

下部须线

1

上部须线

2

下部框

3

上部框

4

平均值和中间值

5

中线

>=6

其他特殊点,如果平均值或中值标记的 Y 值设置为 double.NaN,则标记可以隐藏。

备注

默认情况下,会绘制中值和平均值框线,但使用 BoxPlotShowMedianBoxPlotShowAverage 自定义特性可以将它们隐藏起来。下面的代码移除中值和平均值框线。

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

此外,也可以将原始数据序列中须线值之外的值在盒须图中显示为单个值。若要启用此功能,请使用 BoxPlotShowUnusualValues 自定义特性。下面的代码对此进行了演示。

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

计算得到的盒须图值

自定义特性 BoxPlotSeries 用于将盒须图类型附加到一个或多个现有序列(按名称),以进行计算。可以为整个序列或盒须图的每个单独的数据点设置此自定义特性。对序列进行设置时,BoxPlotSeries 包含一个或多个分号分隔的序列名称。因此,将为 BoxPlotSeries 自定义特性中指定的每个序列计算和添加每个盒须图点值。

如果 BoxPlotSeries 仅在一个 DataPoint 对象中进行了设置,则只能指定一个序列。默认情况下,使用该序列的第一个 Y 值。此外,用户也可以使用序列的名称指定要使用的值。

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

默认情况下,上部框和下部框值使用 25/75 的百分比进行计算。须线值使用 10/90 的百分比进行计算。使用 BoxPlotPercentileBoxPlotWhiskerPercentile 自定义特性可以更改此行为。下面的代码演示如何将上部框和下部框值更改为 30/70 的百分比,并将须线值更改为 5/95 的百分比。

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

示例

下面的示例演示如何生成 15% 的盒须图。

' 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";

请参见

参考

图表类型

K 线图

System.Windows.Forms.DataVisualization.Charting

System.Web.UI.DataVisualization.Charting