public RawValueInfo(double data, double value, ValueMemberDefinition definition) { if (definition == null) throw new Exception("definition can't be null"); Data = data; Value = value; ValueMember = definition; }
double? GetValueY(ValueMemberDefinition vm, double x) { if (rawData == null) return null; var leftVal = rawData.Where(v => v.ValueMember == vm & v.Data >= x).OrderBy(v => v.Data).FirstOrDefault(); var rightVal = rawData.Where(v => v.ValueMember == vm & v.Data <= x).OrderByDescending(v => v.Data).FirstOrDefault(); if (leftVal == null | rightVal == null) return null; return (leftVal.Value - rightVal.Value) / (leftVal.Data - rightVal.Data) * (x - leftVal.Data) + leftVal.Value; }