private void PlotOffRep(PlotModel m) { if (OffReputations == null) { return; } //miasta LinearAxis yAxis = new LinearAxis(); yAxis.Title = Labels.OffReputation; yAxis.Key = "off_rep"; yAxis.Position = AxisPosition.Right; yAxis.MajorGridlineStyle = LineStyle.None; yAxis.MinorGridlineStyle = LineStyle.None; m.Axes.Add(yAxis); foreach (var empire in OffReputations.OrderBy(x => x.Key.OffReputation)) { var s = new OxyPlot.Series.StairStepSeries(); s.XAxisKey = "x"; s.YAxisKey = "off_rep"; s.LineStyle = LineStyle.Dash; //s.VerticalStrokeThickness = 0.2; s.MarkerType = MarkerType.Diamond; s.Title = string.Format("A: {0} ({1})", empire.Key.PlayerName, empire.Key.AlianceName); DateTime?lastTime = null; long lastScore = 0; foreach (var hr in empire.Value.OrderBy(x => x.CreateDT.Value)) { s.Points.Add(DateTimeAxis.CreateDataPoint(hr.CreateDT.Value, hr.Score)); lastScore = hr.Score; lastTime = hr.CreateDT; } //sztucznie dodaję pomiar, żeb widać było poziomą kreskę if (lastTime.HasValue) { s.Points.Add(DateTimeAxis.CreateDataPoint(lastTime.Value.AddHours(1), lastScore)); } m.Series.Add(s); } }
private void PlotOffRepBars(PlotModel m) { if (OffReputations == null) { return; } //daty if (m_XCatDates == null) { m_XCatDates = new CategoryAxis(); m_XCatDates.Title = Labels.Date; m_XCatDates.Position = AxisPosition.Bottom; m_XCatDates.GapWidth = 0.1; m.Axes.Add(m_XCatDates); } long lastScore = -1; double scoreValue = 0; foreach (var empire in OffReputations.OrderBy(x => x.Key.OffReputation)) { lastScore = -1; scoreValue = 0; var s = new OxyPlot.Series.ColumnSeries(); s.FontSize = 9; s.LabelFormatString = "A: " + empire.Key.PlayerName; s.Title = string.Format("A: {0} ({1})", empire.Key.PlayerName, empire.Key.AlianceName); s.YAxisKey = "reputation"; s.StackGroup = empire.Key.PlayerName; s.IsStacked = true; s.LabelPlacement = OxyPlot.Series.LabelPlacement.Inside; int categoryIx = -1; foreach (var hr in empire.Value.OrderBy(x => x.CreateDT.Value)) { if (DiffDefReputation) { if (lastScore < 0) { //pierwszy wynik, zaczynam od zera lastScore = hr.Score; scoreValue = 0; } else { scoreValue = hr.Score - lastScore; lastScore = hr.Score; } } else { scoreValue = hr.Score; } if (scoreValue == 0) { continue; } var serverTime = hr.CreateDT.Value.AddHours(ServerTimeDiffH); if (FromDate.HasValue && serverTime >= FromDate) { string catName = string.Format("{0} h:{1}", serverTime.ToString("yy.MM.dd"), serverTime.ToString("HH")); categoryIx = m_XCatDates.Labels.IndexOf(catName); if (categoryIx < 0) { m_XCatDates.Labels.Add(catName); categoryIx = m_XCatDates.Labels.IndexOf(catName); } s.Items.Add(new OxyPlot.Series.ColumnItem(scoreValue, categoryIx)); } } m.Series.Add(s); } }