public void Show(VotingResults votingResults, Func <Vote, bool> filter) { lock (_plotModel.SyncRoot) { _xAxis.SetAxisMinMax(TimeSpanAxis.ToDouble(votingResults.StartTime), TimeSpanAxis.ToDouble(votingResults.EndTime)); _plotModel.Series.Clear(); LineSeries series = TotalCumulativeVotedByTimeUtils.CreateSeries(votingResults, filter, out var max); series.Title = "Всего проголосовало"; _yAxis.SetAxisMax(max); _plotModel.Series.Add(series); } _plotModel.InvalidatePlot(true); }
public void Show(IBlockTimestampInterpolator blockTimestampInterpolator, string[] names, BlockGraphItem <int>[][] array) { Contract.Requires(names.Length == array.Length); lock (_plotModel.SyncRoot) { ConfigureAxes(blockTimestampInterpolator, array); _plotModel.Series.Clear(); const double GapSize = 0.05; int AxisCount = names.Length; double size = (1 - GapSize * (AxisCount - 1)) / AxisCount; double start = 0; for (int axisCounter = 0; axisCounter < names.Length; axisCounter++) { var data = array[axisCounter]; var yAxisKey = Guid.NewGuid().ToString(); var yAxis = new LinearAxis() { Position = AxisPosition.Left, Key = yAxisKey, StartPosition = start, EndPosition = start + size, Title = names[axisCounter] }; start += size + GapSize; _plotModel.Axes.Add(yAxis); var series = new LineSeries() { CanTrackerInterpolatePoints = false, YAxisKey = yAxisKey }; _plotModel.Series.Add(series); ref var lastPoint = ref data[0]; series.Points.Add(new DataPoint( TimeSpanAxis.ToDouble(blockTimestampInterpolator.GetBlockTimestamp(lastPoint.BlockNumber)), lastPoint.Data)); int maxVotes = lastPoint.Data; for (int i = 1; i < data.Length; i++) { ref var currentPoint = ref data[i]; for (int point = lastPoint.BlockNumber + 1; point < currentPoint.BlockNumber; point++) { var xPoint = TimeSpanAxis.ToDouble(blockTimestampInterpolator.GetBlockTimestamp(point)); series.Points.Add(new DataPoint(xPoint, 0)); } if (currentPoint.Data > maxVotes) { maxVotes = currentPoint.Data; } series.Points.Add(new DataPoint(TimeSpanAxis.ToDouble(blockTimestampInterpolator.GetBlockTimestamp(currentPoint.BlockNumber)), currentPoint.Data)); lastPoint = currentPoint; } yAxis.SetAxisMin(0); yAxis.SetAxisMax(maxVotes); }