private void Simplify2(FastChartSerie serie, double tolerance) {
serie.Points.Clear();
double prevX = 0;
double maxY = 0;
foreach (DataRowView rowView in _source) {
var dt = Convert.ToDateTime(rowView[ArgumentFieldName]);
double val = 0;
if (!(rowView[serie.ColumnName] is DBNull)) {
val = Convert.ToDouble(rowView[serie.ColumnName]);
}
double x = calcX(dt);
if (serie.Points.Count==0) {
prevX = x;
maxY = val;
serie.Points.Add(new FastChartPoint() { X = dt, Y = maxY });
} else {
double dist = x - prevX;
if(dist<tolerance) {
if(Math.Abs(val)>Math.Abs(maxY)) {
maxY = val;
}
} else {
prevX = x;
serie.Points.Add(new FastChartPoint() { X = dt, Y = maxY});
maxY = 0;
}
}
}
}