FlexChart for WPF
箱ひげ図
FlexChart > FlexChart の操作 > FlexChart の要素 > FlexChart の系列 > 箱ひげ図

箱ひげ図系列を使用すると、データのグループを範囲、四分位数、中央値で表示できます。その名前が示すとおり、系列データが箱とひげで描写されます。

箱は、四分位数(上下)と中央値を示す範囲です。一方、ひげは、箱から垂直に伸びる線です。これらの線は、上下の四分位数の外側にあるデータのばらつきを示します。さらに、これらの線の外側にあるポイントは、異常値と呼ばれます。

Box-and-Whisker 系列は、統計分布を視覚化したり、複数のデータセットをグラフィカルに検証する場合に理想的です。FlexChart では、この系列で次の機能を使用できます。

次の図に、各学校の学生の 3 教科の点数を比較するために、これらのデータの四分位数、中央値、ひげを示します。

次のコードは、学校 A、B、C の学生が取った 3 教科の点数に関するデータを使用します。このコードは、FlexChart で箱ひげ系列を実装する方法を示します。

Class DataCreator
    Public Shared Function CreateSchoolScoreData() As List(Of ClassScore)
        Dim result = New List(Of ClassScore)()
        result.Add(New ClassScore() With {
            .ClassName = "英語",
            .SchoolA = 46,
            .SchoolB = 53,
            .SchoolC = 66
        })
        result.Add(New ClassScore() With {
            .ClassName = "理学",
            .SchoolA = 61,
            .SchoolB = 55,
            .SchoolC = 65
        })
        result.Add(New ClassScore() With {
            .ClassName = "英語",
            .SchoolA = 58,
            .SchoolB = 56,
            .SchoolC = 67
        })
        result.Add(New ClassScore() With {
            .ClassName = "数学",
            .SchoolA = 58,
            .SchoolB = 51,
            .SchoolC = 64
        })
        result.Add(New ClassScore() With {
            .ClassName = "英語",
            .SchoolA = 63,
            .SchoolB = 53,
            .SchoolC = 45
        })
        result.Add(New ClassScore() With {
            .ClassName = "英語",
            .SchoolA = 63,
            .SchoolB = 50,
            .SchoolC = 65
        })
        result.Add(New ClassScore() With {
            .ClassName = "数学",
            .SchoolA = 60,
            .SchoolB = 45,
            .SchoolC = 67
        })
        result.Add(New ClassScore() With {
            .ClassName = "数学",
            .SchoolA = 62,
            .SchoolB = 53,
            .SchoolC = 66
        })
        result.Add(New ClassScore() With {
            .ClassName = "理学",
            .SchoolA = 63,
            .SchoolB = 54,
            .SchoolC = 64
        })
        result.Add(New ClassScore() With {
            .ClassName = "英語",
            .SchoolA = 63,
            .SchoolB = 52,
            .SchoolC = 67
        })
        result.Add(New ClassScore() With {
            .ClassName = "理学",
            .SchoolA = 69,
            .SchoolB = 66,
            .SchoolC = 71
        })
        result.Add(New ClassScore() With {
            .ClassName = "理学",
            .SchoolA = 48,
            .SchoolB = 67,
            .SchoolC = 50
        })
        result.Add(New ClassScore() With {
            .ClassName = "理学",
            .SchoolA = 54,
            .SchoolB = 50,
            .SchoolC = 56
        })
        result.Add(New ClassScore() With {
            .ClassName = "理学",
            .SchoolA = 60,
            .SchoolB = 56,
            .SchoolC = 64
        })
        result.Add(New ClassScore() With {
            .ClassName = "数学",
            .SchoolA = 71,
            .SchoolB = 65,
            .SchoolC = 50
        })
        result.Add(New ClassScore() With {
            .ClassName = "数学",
            .SchoolA = 48,
            .SchoolB = 70,
            .SchoolC = 72
        })
        result.Add(New ClassScore() With {
            .ClassName = "数学",
            .SchoolA = 53,
            .SchoolB = 40,
            .SchoolC = 80
        })
        result.Add(New ClassScore() With {
            .ClassName = "数学",
            .SchoolA = 60,
            .SchoolB = 56,
            .SchoolC = 67
        })
        result.Add(New ClassScore() With {
            .ClassName = "数学",
            .SchoolA = 61,
            .SchoolB = 56,
            .SchoolC = 45
        })
        result.Add(New ClassScore() With {
            .ClassName = "英語",
            .SchoolA = 63,
            .SchoolB = 58,
            .SchoolC = 64
        })
        result.Add(New ClassScore() With {
            .ClassName = "理学",
            .SchoolA = 59,
            .SchoolB = 54,
            .SchoolC = 65
        })

        Return result
    End Function
End Class

Public Class ClassScore
    Public Property ClassName() As String
        Get
            Return m_ClassName
        End Get
        Set
            m_ClassName = Value
        End Set
    End Property
    Private m_ClassName As String
    Public Property SchoolA() As Double
        Get
            Return m_SchoolA
        End Get
        Set
            m_SchoolA = Value
        End Set
    End Property
    Private m_SchoolA As Double
    Public Property SchoolB() As Double
        Get
            Return m_SchoolB
        End Get
        Set
            m_SchoolB = Value
        End Set
    End Property
    Private m_SchoolB As Double
    Public Property SchoolC() As Double
        Get
            Return m_SchoolC
        End Get
        Set
            m_SchoolC = Value
        End Set
    End Property
    Private m_SchoolC As Double
End Class
namespace BoxWhiskers
{
    class DataCreator
    {
        public static List<ClassScore> CreateSchoolScoreData()
        {
            var result = new List<ClassScore>();
            result.Add(new ClassScore() { ClassName ="英語",SchoolA= 46,SchoolB= 53,SchoolC= 66});
            result.Add(new ClassScore() { ClassName ="理学",SchoolA= 61,SchoolB= 55,SchoolC= 65});
            result.Add(new ClassScore() { ClassName ="英語",SchoolA= 58,SchoolB= 56,SchoolC= 67});
            result.Add(new ClassScore() { ClassName ="数学",SchoolA= 58,SchoolB= 51,SchoolC= 64});
            result.Add(new ClassScore() { ClassName ="英語",SchoolA= 63,SchoolB= 53,SchoolC= 45});
            result.Add(new ClassScore() { ClassName ="英語",SchoolA= 63,SchoolB= 50,SchoolC= 65});
            result.Add(new ClassScore() { ClassName ="数学",SchoolA= 60,SchoolB= 45,SchoolC= 67});
            result.Add(new ClassScore() { ClassName ="数学",SchoolA= 62,SchoolB= 53,SchoolC= 66});
            result.Add(new ClassScore() { ClassName ="理学",SchoolA= 63,SchoolB= 54,SchoolC= 64});
            result.Add(new ClassScore() { ClassName ="英語",SchoolA= 63,SchoolB= 52,SchoolC= 67});
            result.Add(new ClassScore() { ClassName ="理学",SchoolA= 69,SchoolB= 66,SchoolC= 71});
            result.Add(new ClassScore() { ClassName ="理学",SchoolA= 48,SchoolB= 67,SchoolC= 50});
            result.Add(new ClassScore() { ClassName ="理学",SchoolA= 54,SchoolB= 50,SchoolC= 56});
            result.Add(new ClassScore() { ClassName ="理学",SchoolA= 60,SchoolB= 56,SchoolC= 64});
            result.Add(new ClassScore() { ClassName ="数学",SchoolA= 71,SchoolB= 65,SchoolC= 50});
            result.Add(new ClassScore() { ClassName ="数学",SchoolA= 48,SchoolB= 70,SchoolC= 72});
            result.Add(new ClassScore() { ClassName ="数学",SchoolA= 53,SchoolB= 40,SchoolC= 80});
            result.Add(new ClassScore() { ClassName ="数学",SchoolA= 60,SchoolB= 56,SchoolC= 67});
            result.Add(new ClassScore() { ClassName ="数学",SchoolA= 61,SchoolB= 56,SchoolC= 45});
            result.Add(new ClassScore() { ClassName ="英語",SchoolA= 63,SchoolB= 58,SchoolC= 64});
            result.Add(new ClassScore() { ClassName ="理学",SchoolA= 59,SchoolB= 54,SchoolC= 65});

            return result;
        }
    }
     
    public class ClassScore
    {
        public string ClassName { get; set; }
        public double SchoolA { get; set; }
        public double SchoolB { get; set; }
        public double SchoolC { get; set; }
    }
Partial Public Class MainWindow
    Private _data As List(Of ClassScore) = Nothing
    Public Sub New()
        InitializeComponent()

        ' 平均線を表示します。
        boxWhiskerA.ShowMeanLine = True
        boxWhiskerB.ShowMeanLine = True
        boxWhiskerC.ShowMeanLine = True

        ' 内側ポイントを表示します。
        boxWhiskerA.ShowInnerPoints = True
        boxWhiskerB.ShowInnerPoints = True
        boxWhiskerC.ShowInnerPoints = True

        ' 異常値を表示します。
        boxWhiskerA.ShowOutliers = True
        boxWhiskerB.ShowOutliers = True
        boxWhiskerC.ShowOutliers = True

        ' 平均マークを表示します。
        boxWhiskerA.ShowMeanMarks = True
        boxWhiskerB.ShowMeanMarks = True
        boxWhiskerC.ShowMeanMarks = True

        ' 四分位計算を指定します。
        boxWhiskerA.QuartileCalculation = QuartileCalculation.InclusiveMedian
        boxWhiskerB.QuartileCalculation = QuartileCalculation.InclusiveMedian
        boxWhiskerC.QuartileCalculation = QuartileCalculation.InclusiveMedian
    End Sub

End Class

Public ReadOnly Property Data() As List(Of ClassScore)
    Get
        If _data Is Nothing Then
            _data = DataCreator.CreateSchoolScoreData()
        End If

        Return _data
    End Get
End Property
namespace BoxWhiskers
{
    public partial class BoxWhisker : UserControl
    {
        private List<ClassScore> _data = null;
        public BoxWhisker()
        {
            InitializeComponent();

            // 平均線を表示します。
            boxWhiskerA.ShowMeanLine = true;
            boxWhiskerB.ShowMeanLine = true;
            boxWhiskerC.ShowMeanLine = true;

            // 内側ポイントを表示します。
            boxWhiskerA.ShowInnerPoints = true;
            boxWhiskerB.ShowInnerPoints = true;
            boxWhiskerC.ShowInnerPoints = true;

            // 異常値を表示します。
            boxWhiskerA.ShowOutliers = true;
            boxWhiskerB.ShowOutliers = true;
            boxWhiskerC.ShowOutliers = true;

            // 平均マークを表示します。
            boxWhiskerA.ShowMeanMarks = true;
            boxWhiskerB.ShowMeanMarks = true;
            boxWhiskerC.ShowMeanMarks = true;

            // 四分位計算を指定します。
            boxWhiskerA.QuartileCalculation = QuartileCalculation.InclusiveMedian;
            boxWhiskerB.QuartileCalculation = QuartileCalculation.InclusiveMedian;
            boxWhiskerC.QuartileCalculation = QuartileCalculation.InclusiveMedian;
        }
        public List<ClassScore> Data
        {
            get
            {
                if (_data == null)
                {
                    _data = DataCreator.CreateSchoolScoreData();
                }

                return _data;
            }
        }
    }
}