共用方式為


盒狀圖

盒狀圖類型是由一個或多個方塊符號所組成,摘要說明一個或多個資料集內的資料分佈。盒狀圖會顯示垂直矩形以及從兩端延伸的鬚線。

盒值通常是從另一個數列中的資料計算的值。一個方塊符號 (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 自訂屬性中指定的每個數列,計算及新增每個盒狀圖資料點值。

如果只在 DataPoint 物件中設定 BoxPlotSeries,只能指定一個數列。預設會使用數列的第一個 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