Пример #1
0
        private void PlotDefRep(PlotModel m)
        {
            if (DefReputations == null)
            {
                return;
            }

            //miasta
            LinearAxis yAxis = new LinearAxis();

            yAxis.Title              = Labels.DefReputation;
            yAxis.Key                = "def_rep";
            yAxis.Position           = AxisPosition.Left;
            yAxis.MajorGridlineStyle = LineStyle.None;
            yAxis.MinorGridlineStyle = LineStyle.None;
            m.Axes.Add(yAxis);

            foreach (var empire in DefReputations.OrderBy(x => x.Key.DefReputation))
            {
                var s = new OxyPlot.Series.StairStepSeries();
                s.XAxisKey = "x";
                s.YAxisKey = "def_rep";
                //s.VerticalStrokeThickness = 0.2;

                s.MarkerType = MarkerType.Diamond;
                s.Title      = string.Format("D: {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);
            }
        }
Пример #2
0
        private void PlotDefRepBars(PlotModel m)
        {
            if (DefReputations == 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 DefReputations.OrderBy(x => x.Key.DefReputation))
            {
                lastScore  = -1;
                scoreValue = 0;
                var s = new OxyPlot.Series.ColumnSeries();
                s.LabelFormatString = "D: " + empire.Key.PlayerName;
                s.Title             = string.Format("D: {0} ({1})", empire.Key.PlayerName, empire.Key.AlianceName);
                s.YAxisKey          = "reputation";
                s.StackGroup        = empire.Key.PlayerName;
                s.IsStacked         = true;
                s.FontSize          = 9;
                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);
            }
        }