private void Form1_Load(object sender, EventArgs e)
{
this.flexChart1.ChartType = ChartType.RangedHistogram;
var histogram = new C1.Win.Chart.RangedHistogram()
{
Binding = "Value",
BindingX = "Name",
Name = "Count",
SortDescending = true,
DataSource = GetPurchaseFactorsData(),
DataLabel = new DataLabel { Content = "{y:N0}", Position = LabelPosition.Top },
};
this.flexChart1.Series.Add((Series)histogram);
// パレート図のデータを計算します
var histoYs = histogram.GetValues(0);
var sum = histoYs.Sum();
var paretoData = new List<PointF>();
double cumulativeSum = 0;
for (int i = 0; i < histoYs.Length; i++)
{
cumulativeSum += histoYs[i];
paretoData.Add(new PointF
{
X = i,
Y = (float)(cumulativeSum / sum),
});
}
var paretoLine = new Series
{
Name = "Cumulative %",
ChartType = ChartType.LineSymbols,
DataSource = paretoData,
Binding = "Y",
BindingX = "X",
AxisY = new Axis
{
Position = Position.Right,
Min = 0,
Max = 1,
Format = "P0",
Title = "Cumulative Percentage",
},
};
this.flexChart1.Series.Add(paretoLine);
}
Private Sub Form1_Load(sender As Object, e As EventArgs)
Me.flexChart1.ChartType = ChartType.RangedHistogram
Dim histogram As RangedHistogram = New C1.Win.Chart.RangedHistogram() With {
.Binding = "Value",
.BindingX = "Name",
.Name = "Count",
.SortDescending = True,
.DataSource = GetPurchaseFactorsData(),
.DataLabel = New DataLabel() With {
.Content = "{y:N0}",
.Position = LabelPosition.Top
}
}
Me.flexChart1.Series.Add(DirectCast(histogram, Series))
' パレート図のデータを計算します
Dim histoYs As Double() = histogram.GetValues(0)
Dim sum As Double = histoYs.Sum()
Dim paretoData As List(Of PointF) = New List(Of PointF)()
Dim cumulativeSum As Double = 0
For i As Integer = 0 To (histoYs.Length - 1)
cumulativeSum += histoYs(i)
paretoData.Add(New PointF() With {
.X = i,
.Y = CSng(cumulativeSum / sum)
})
Next
Dim paretoLine As Series = New Series() With {
.Name = "Cumulative %",
.ChartType = ChartType.LineSymbols,
.DataSource = paretoData,
.Binding = "Y",
.BindingX = "X",
.AxisY = New Axis() With {
.Position = Position.Right,
.Min = 0,
.Max = 1,
.Format = "P0",
.Title = "Cumulative Percentage"
}
}
Me.flexChart1.Series.Add(paretoLine)
End Sub