MESCIUS SPREAD for Windows Forms 15.0J サンプルコード集
箱ひげ図を追加する

BoxWhiskerSeriesクラスを使用して箱ひげ図を作成できます。複数の箱ひげ図の系列をClusteredBoxWhiskerSeriesクラスのSeriesコレクションに追加し、集合箱ひげ図を作成することもできます。

【実行例】

チャート

 private void Form1_Load(object sender, System.EventArgs e)
 {
    // シートにデータを設定           
    fpSpread1.ActiveSheet.SetClip(0, 0, 1, 4, "売上\t店舗A\t店舗B");
    fpSpread1.ActiveSheet.SetClip(1, 0, 1, 4, "商品XYZ\t20\t15");
    fpSpread1.ActiveSheet.SetClip(2, 0, 1, 4, "商品ABC\t25\t18");
    fpSpread1.ActiveSheet.SetClip(3, 0, 1, 4, "商品XYZ\t21\t19");
    fpSpread1.ActiveSheet.SetClip(4, 0, 1, 4, "商品ABC\t30\t22");
    fpSpread1.ActiveSheet.SetClip(5, 0, 1, 4, "商品XYZ\t8\t30");
    fpSpread1.ActiveSheet.SetClip(6, 0, 1, 4, "商品ABC\t40\t8");
    fpSpread1.ActiveSheet.SetClip(7, 0, 1, 4, "商品XYZ\t30\t9");
    fpSpread1.ActiveSheet.SetClip(8, 0, 1, 4, "商品ABC\t12\t20");
    // セル範囲を設定して集合箱ひげ図を作成します
    fpSpread1.ActiveSheet.AddChart(new FarPoint.Win.Spread.Model.CellRange(0, 0, 9, 3), typeof(FarPoint.Win.Chart.ClusteredBoxWhiskerSeries), 250, 200, 250, 30);
    FarPoint.Win.Chart.ClusteredBoxWhiskerSeries cboxseries = (FarPoint.Win.Chart.ClusteredBoxWhiskerSeries)fpSpread1.ActiveSheet.Charts[0].Model.PlotAreas[0].Series[0];
    // データ系列の表示(ポイント、線、マーカー)を設定します
    foreach (FarPoint.Win.Chart.BoxWhiskerSeries boxseries in cboxseries.Series)
    {
        boxseries.ShowInnerPoints = true;
        boxseries.ShowMeanLine = true;
        boxseries.ShowMeanMarkers = true;
        boxseries.ShowOutlierPoints = true;
    }
 }
 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' シートにデータを設定
    FpSpread1.ActiveSheet.SetClip(0, 0, 1, 4, "売上" + Chr(9) + "店舗A" + Chr(9) + "店舗B")
    FpSpread1.ActiveSheet.SetClip(1, 0, 1, 4, "商品XYZ" + Chr(9) + "20" + Chr(9) + "15")
    FpSpread1.ActiveSheet.SetClip(2, 0, 1, 4, "商品ABC" + Chr(9) + "25" + Chr(9) + "18")
    FpSpread1.ActiveSheet.SetClip(3, 0, 1, 4, "商品XYZ" + Chr(9) + "21" + Chr(9) + "19")
    FpSpread1.ActiveSheet.SetClip(4, 0, 1, 4, "商品ABC" + Chr(9) + "30" + Chr(9) + "22")
    FpSpread1.ActiveSheet.SetClip(5, 0, 1, 4, "商品XYZ" + Chr(9) + "8" + Chr(9) + "30")
    FpSpread1.ActiveSheet.SetClip(6, 0, 1, 4, "商品ABC" + Chr(9) + "40" + Chr(9) + "8")
    FpSpread1.ActiveSheet.SetClip(7, 0, 1, 4, "商品XYZ" + Chr(9) + "30" + Chr(9) + "9")
    FpSpread1.ActiveSheet.SetClip(8, 0, 1, 4, "商品ABC" + Chr(9) + "12" + Chr(9) + "20")
    ' セル範囲を設定して集合箱ひげ図を作成します
    FpSpread1.ActiveSheet.AddChart(New FarPoint.Win.Spread.Model.CellRange(0, 0, 9, 3), GetType(FarPoint.Win.Chart.ClusteredBoxWhiskerSeries), 250, 200, 250, 30)
    Dim cboxseries As FarPoint.Win.Chart.ClusteredBoxWhiskerSeries = DirectCast(FpSpread1.ActiveSheet.Charts(0).Model.PlotAreas(0).Series(0), FarPoint.Win.Chart.ClusteredBoxWhiskerSeries)
    ' データ系列の表示(ポイント、線、マーカー)を設定します
    For Each boxseries As FarPoint.Win.Chart.BoxWhiskerSeries In cboxseries.Series
        boxseries.ShowInnerPoints = True
        boxseries.ShowMeanLine = True
        boxseries.ShowMeanMarkers = True
        boxseries.ShowOutlierPoints = True
    Next
 End Sub

 

 


© MESCIUS inc. All rights reserved.