public void Show(VotingResults votingResults, Func <Vote, bool> filter) { lock (_plotModel.SyncRoot) { _xAxis.SetMinMaxBlocksToXAxis(votingResults); _plotModel.Series.Clear(); var series = new LineSeries() { CanTrackerInterpolatePoints = false }; _plotModel.Series.Add(series); var points = votingResults.Votes .Where(x => filter(x)) .GroupBy(x => x.BlockNumber, (key, votes) => (blockNumber: key, votesCount: votes.Count())) .OrderBy(x => x.blockNumber) .ToArray(); ref var lastPoint = ref points[0]; series.Points.Add(new DataPoint(lastPoint.blockNumber, lastPoint.votesCount)); int maxVotes = lastPoint.votesCount; for (int i = 1; i < points.Length; i++) { ref var currentPoint = ref points[i]; for (int point = lastPoint.blockNumber + 1; point < currentPoint.blockNumber; point++) { series.Points.Add(new DataPoint(point, 0)); } if (currentPoint.votesCount > maxVotes) { maxVotes = currentPoint.votesCount; } series.Points.Add(new DataPoint(currentPoint.blockNumber, currentPoint.votesCount)); lastPoint = currentPoint; }