private void onDataBind()
{
samples = null;
if (dataSource == null)
return;
Histogram source = dataSource as Histogram;
if (source == null)
{
if (histogram == null)
histogram = new Histogram();
if (dataSource is DataSet)
{
// throw new NotSupportedException();
}
else if (dataSource is DataTable)
{
DataTable table = dataSource as DataTable;
if (dataMember != null && dataMember.Length > 0)
{
if (table.Columns.Contains(dataMember))
{
DataColumn column = table.Columns[dataMember];
samples = Matrix.ToArray(column);
}
else
{
samples = new double[0];
}
}
else
{
return;
}
}
else if (dataSource is double[])
{
samples = dataSource as double[];
}
else if (dataSource is IListSource)
{
// throw new NotSupportedException();
}
else
{
return; // invalid data source
}
if (binWidth != null)
this.histogram.Compute(samples, binWidth.Value);
else if (numberOfBins != null)
this.histogram.Compute(samples, numberOfBins.Value);
else
this.histogram.Compute(samples);
}
else
{
this.histogram = source;
}
this.UpdateTrackbar();
this.UpdateGraph();
if (histogram.Bins.Count > 0 &&
histogram.Bins.Count < trackBar.Maximum)
trackBar.Value = histogram.Bins.Count;
}