示例#1
0
        static void AddPowerMaxToChart(Chart vcChart, TGroupTPResult groupTpResult, int c, DateTime dtStart, DateTime dtEnd)
        {
            if (!groupTpResult.PowerMax.HasValue)
            {
                return;
            }

            var titleName = "Pmax - ";

            if (groupTpResult.HierarchyObject != null)
            {
                titleName += groupTpResult.HierarchyObject.ToString();
            }

            var ser = new DataSeries
            {
                Color              = GetColorByIndexSeries(c),//Здесь присваиваем цвет
                LabelEnabled       = false,
                RenderAs           = RenderAs.Line,
                XValueType         = ChartValueTypes.DateTime,
                Name               = titleName,
                XValueFormatString = "dd.MM.yyyy HH:mm",
                //MarkerType = MarkerTypes.Circle,
                MarkerEnabled = false,
                LineThickness = 1,
                //Effect = effect,
                //DataSource = source,
                //ToolTip = titleName,
            };

            ser.BeginInit();
            try
            {
                ser.DataPoints.Add(new DataPoint
                {
                    XValue  = dtStart,
                    YValue  = groupTpResult.PowerMax.Value,
                    ToolTip = titleName + "\n" + dtStart.ToString("dd.MM.yyyy HH:mm") + "  " + groupTpResult.PowerMax.Value.ToString("#,##0.######")
                              //AxisXLabel = Mar
                });

                ser.DataPoints.Add(new DataPoint
                {
                    XValue  = dtEnd,
                    YValue  = groupTpResult.PowerMax.Value,
                    ToolTip = titleName + "\n" + dtEnd.ToString("dd.MM.yyyy HH:mm") + "  " + groupTpResult.PowerMax.Value.ToString("#,##0.######")
                              //AxisXLabel = Mar
                });
            }
            finally
            {
                ser.EndInit();
            }

            vcChart.Series.Add(ser);
        }
示例#2
0
        static void AddPowerToChart(Chart vcChart, TGroupTPResult groupTpResult,
                                    IVisualDataRequestObjectsNames getNameInterface, int c,
                                    Func <enumPowerFlag, string> getPowerFlagMessage, bool isManySeries, bool isShowMaxPowerLine = false)
        {
            if (groupTpResult.PowerHoursList == null || !groupTpResult.PowerHoursList.Any(p => p != null))
            {
                return; //нет нормальных значений, выходим
            }
            var titleName = string.Empty;

            if (groupTpResult.HierarchyObject != null)
            {
                titleName = groupTpResult.HierarchyObject.ToString();
            }
            else if (groupTpResult.ID.TypeHierarchy == enumTypeHierarchy.Section)
            {
                titleName = getNameInterface.GetSectionName(groupTpResult.ID.ID);
            }
            else if (groupTpResult.ID.TypeHierarchy == enumTypeHierarchy.Info_TP)
            {
                titleName = getNameInterface.GetTPName(groupTpResult.ID.ID);
            }

            Brush colorMax       = new SolidColorBrush(Color.FromArgb(0xFF, 0xAE, 0x7F, 0x2B)),
                  colorMaxExcess = new SolidColorBrush(Color.FromRgb(255, 0, 0)),
                  colorMin       = new SolidColorBrush(Color.FromRgb(0, 0, 255));

            var ser = new DataSeries
            {
                Color              = GetColorByIndexSeries(c), //Здесь присваиваем цвет
                LabelEnabled       = false,
                RenderAs           = isManySeries ? RenderAs.QuickLine : RenderAs.Line,
                XValueType         = ChartValueTypes.DateTime,
                Name               = titleName,
                XValueFormatString = "dd.MM.yyyy HH:mm",
                //MarkerType = MarkerTypes.Circle,
                MarkerEnabled = false,
                LineThickness = 1,
                //Effect = effect,
                //DataSource = source,
            };

            DataSeries maxPowerSerie = null;

            if (isShowMaxPowerLine && groupTpResult.PowerMax.HasValue)
            {
                maxPowerSerie = new DataSeries
                {
                    Color              = GetColorByIndexSeries(c + 1), //Здесь присваиваем цвет
                    LabelEnabled       = false,
                    RenderAs           = RenderAs.Line,
                    XValueType         = ChartValueTypes.DateTime,
                    Name               = @"Pmax - " + titleName,
                    XValueFormatString = "dd.MM.yyyy HH:mm",
                    //MarkerType = MarkerTypes.Circle,
                    MarkerEnabled = false,
                    LineThickness = 1,
                    BorderStyle   = BorderStyles.Dotted,
                    //Effect = effect,
                    //DataSource = source,
                    //ToolTip = titleName,
                };
            }

            ser.BeginInit();
            try
            {
                foreach (var av in groupTpResult.PowerHoursList)
                {
                    if (av == null)
                    {
                        return;
                    }
                    //Это новая серия просто заполняем точками
                    var dp = new DataPoint()
                    {
                        XValue = av.EventDateTime,
                        YValue = av.F_VALUE,

                        //AxisXLabel = Mar
                    };

                    if (getPowerFlagMessage != null)
                    {
                        dp.ToolTipText = titleName + "\n" + av.EventDateTime.ToString("dd.MM.yyyy HH:mm") + "  " +
                                         av.F_VALUE.ToString("#,##0.######") + "\n" + getPowerFlagMessage(av.PowerFlag);
                    }

                    if (av.PowerFlag.HasFlag(enumPowerFlag.MaxPowerExcess))
                    {
                        //превышение максимальной мощности
                        dp.MarkerType    = MarkerTypes.Triangle;
                        dp.MarkerScale   = 2;
                        dp.Color         = colorMaxExcess;
                        dp.MarkerEnabled = true;
                    }
                    else if (av.PowerFlag.HasFlag(enumPowerFlag.IsMaxPowerInDay) ||
                             av.PowerFlag.HasFlag(enumPowerFlag.IsMaxPowerInDayInSystemOperatorHour))
                    {
                        dp.MarkerType    = MarkerTypes.Circle;
                        dp.MarkerScale   = 2;
                        dp.Color         = colorMax;
                        dp.MarkerEnabled = true;
                    }
                    else if (av.PowerFlag.HasFlag(enumPowerFlag.IsMinPowerInDay) ||
                             av.PowerFlag.HasFlag(enumPowerFlag.IsMinPowerInDayInSystemOperatorHour))
                    {
                        dp.MarkerType    = MarkerTypes.Square;
                        dp.MarkerScale   = 2;
                        dp.Color         = colorMin;
                        dp.MarkerEnabled = true;
                    }

                    ser.DataPoints.Add(dp);

                    if (isShowMaxPowerLine && groupTpResult.PowerMax.HasValue)
                    {
                        var tt = titleName + "\n" +
                                 "P max: " + groupTpResult.PowerMax.Value.ToString("#,##0.######");

                        if (av.PowerFlag.HasFlag(enumPowerFlag.MaxPowerExcess))
                        {
                            tt += "\n" + "▲ на : " +
                                  (av.F_VALUE - groupTpResult.PowerMax.Value).ToString("#,##0.######");
                        }

                        maxPowerSerie.DataPoints.Add(new DataPoint
                        {
                            XValue      = av.EventDateTime,
                            YValue      = groupTpResult.PowerMax.Value,
                            ToolTip     = tt,
                            ToolTipText = tt
                                          //AxisXLabel = Mar
                        });
                    }
                } //foreach
            }
            finally
            {
                ser.EndInit();
            }

            vcChart.Series.Add(ser);

            if (isShowMaxPowerLine && groupTpResult.PowerMax.HasValue)
            {
                vcChart.Series.Add(maxPowerSerie);
            }
        }