箱ひげ図 (グラフ コントロール)
箱ひげ図は、1 つまたは複数のデータセット内のデータの分散をまとめた 1 つまたは複数の箱形のシンボルで構成されます。箱ひげ図には、垂直方向の四角形とその上下から伸びるひげ状の線が表示されます。
通常、箱の値は、他の系列に存在するデータから計算されます。1 つのボックスのシンボル (DataPoint オブジェクト) は 1 つのデータ系列に関連付けられます。箱ひげ図の系列のデータは、データ バインディングを使用して、または Series.Points メンバー (DataPointCollection オブジェクト) を採用して設定できます。
グラフの特性
SeriesChartType 値 |
SeriesChartType.BoxPlot |
ポイントあたりの Y 値の数 |
6 個以上 (下の表を参照してください)。 |
系列の数 |
1 |
マーカーのサポート |
無効 |
組み合わせて使用できないグラフ |
|
カスタム属性 |
BoxPlotPercentile、BoxPlotSeries、BoxPlotShowAverage、BoxPlotShowMedian、BoxPlotShowUnusualValues、BoxPlotWhiskerPercentile、DrawSideBySide、MaxPixelPointWidth、MinPixelPointWidth、PixelPointDepth、PixelPointGapDepth、PixelPointWidth、PointWidth |
箱ひげ図の系列には 6 個以上の Y 値を使用します。ただし、Y 値を追加して、マーカーとして描画することができます (外れ値と呼ばれます)。個々の Y 値はグラフ上のポイントを示すため、Y 値の順序は重要です。
Y 値のインデックス |
Y 値 |
---|---|
0 |
下限のひげ |
1 |
上限のひげ |
2 |
下限の箱 |
3 |
上限の箱 |
4 |
平均 |
5 |
中央 |
>=6 |
他の外れ値。マーカーの Y 値を double.NaN に設定すると、平均または中央のマーカーは非表示になることがあります。 |
説明
既定で中央および平均の箱の線は描画されますが、BoxPlotShowMedian および BoxPlotShowAverage のカスタム属性を使用して非表示にできます。次のコードでは、中央および平均の箱の線を削除します。
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 カスタム属性は、計算に使用する 1 つまたは複数の既存の系列に (名前で)、箱ひげ図をアタッチするために使用されます。このカスタム属性は、系列全体、または箱ひげ図の各データ ポイントに設定できます。系列に設定すると、BoxPlotSeries には、1 つの系列名またはセミコロンで区切られた複数の系列名が含まれます。結果として、各 Box Plot ポイント値が計算され、BoxPlotSeries カスタム属性に指定されている各系列に追加されます。
BoxPlotSeries を DataPoint オブジェクトにのみ設定すると、1 つの系列のみを指定できます。既定では系列の最初の Y 値が使用されます。オプションで、系列の名前を使用して、使用する値を指定できます。
Chart1.Series("Series1")("BoxPlotSeries")="Price:Y2;Volume"
Chart1.Series["Series1"]["BoxPlotSeries"]="Price:Y2;Volume";
既定で、上限および下限の箱の値は、25/75 パーセンタイルを使用して計算されます。ひげの値は、10/90 パーセンタイルを使用して計算されます。この動作は、BoxPlotPercentile および BoxPlotWhiskerPercentile のカスタム属性を使用して変更できます。次のコードは、上限および下限の箱の値を 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";
関連項目
参照
System.Windows.Forms.DataVisualization.Charting
System.Web.UI.DataVisualization.Charting