/// <summary> /// Creates dataPoints from the actual values. /// Null points are not permitted in the middle of 2 valid points, these will be replaced with 0 /// </summary> internal void InitDataPoints(double scaleX, double scaleY, double offSetX, double offSetY) { var dataStarted = false; var dataList = new List <DataPoint>(); for (var i = 0; i < DataValues.Length; i++) { if (!dataStarted && DataValues[i].HasValue) { dataStarted = true; } //look forward. if the null count is equal to the number of items remaining, it means the rest are nulls if (dataStarted) { var nullCount = DataValues.Skip(i - 1).Count(v => v == null); dataStarted = nullCount != DataValues.Length - i; } if (!dataStarted) { continue; } if (!DataValues[i].HasValue) { dataList.Add(new DataPoint( (i * scaleX) + offSetX, offSetY - (0 * scaleY), (i + 1).ToString(), "0")); continue; } dataList.Add(new DataPoint( (i * scaleX) + offSetX, offSetY - (DataValues[i].Value * scaleY), (i + 1).ToString(), DataValues[i].Value.ToString(CultureInfo.InvariantCulture))); } _dataPoints = dataList.ToArray(); }