private void UpdateSummaryData(SummaryData summaryData) { TrimToGraphRange(this.DataPointsHashRate, this.SelectedGraphTimeSpan.Span); // add the data point to our series if it will actually result in an additional pixel, this prevents the graph from getting overloaded with too many // data points even if the UI stays open for long periods of time (for example, a new point every 10 seconds at 7d time range - that would result // in a very high density that would impact performance while not actually showing any additional detail on the screen) var dataPoint = new DataPoint() { TimeLocal = summaryData.TimestampUtc.ToLocalTime(), Value = summaryData.TotalKiloHashesAverage5Sec }; var minimumGap = TimeSpan.FromMilliseconds(this.SelectedGraphTimeSpan.Span.TotalMilliseconds / Math.Max(this.GraphWidth, InitialWindowWidth)); if (this.DataPointsHashRate.Count == 0 || (dataPoint.TimeLocal - this.DataPointsHashRate.Last().TimeLocal) >= minimumGap) { PerformFlatLineFix(this.DataPointsHashRate, dataPoint); this.DataPointsHashRate.Add(dataPoint); } // inform the data manager about the new point (regardless of display density logic) if (this.summaryDataManager != null) { this.summaryDataManager.Add(summaryData); } this.ApplicationTitle = string.Format("Mining Controller ({0:0.#} KH/s)", summaryData.TotalKiloHashesAverage5Sec); }
private static void PerformFlatLineFix(IEnumerable<DataPoint> hashRateData, DataPoint referencePoint = null) { // workaround for charting component unable to handle displaying a straight line (if all viewable data points are equal to the same value it throws an overflow exception) if (referencePoint == null) { referencePoint = hashRateData.FirstOrDefault(); } if (hashRateData.Count() > 0 && hashRateData.All(p => p.Value == referencePoint.Value)) { referencePoint.Value += 1.0 / 10000; } }