예제 #1
0
 public void PointAnnotation()
 {
     var s1 = new PointAnnotation();
     var s2 = new Annotations.PointAnnotation();
     OxyAssert.PropertiesAreEqual(s2, s1);
 }
예제 #2
0
        public void ProcessElem(IChartElement element)
        {
            if (element is LineHorisontal)
            {
                var indi_area = indicators_list.Find(x => (string)x.Tag == element.Area);

                if (indi_area.lines_series_list.Exists(x => (string)x.Tag == element.UniqName + "HorLine"))
                {
                    indi_area.lines_series_list.Remove(indi_area.lines_series_list.Find(x => (string)x.Tag == element.UniqName + "HorLine"));
                }

                var line = new LineSeries()
                {
                    Color = OxyColor.FromArgb(((LineHorisontal)element).Color.A, ((LineHorisontal)element).Color.R, ((LineHorisontal)element).Color.G, ((LineHorisontal)element).Color.B),
                    MarkerStrokeThickness = 1,
                    StrokeThickness       = 1,
                    MarkerStroke          = OxyColor.FromArgb(((LineHorisontal)element).Color.A, ((LineHorisontal)element).Color.R, ((LineHorisontal)element).Color.G, ((LineHorisontal)element).Color.B),
                    Tag = (object)(element.UniqName + "HorLine"),
                };

                line.Points.AddRange(new List <DataPoint>()
                {
                    new DataPoint(DateTimeAxis.ToDouble(((LineHorisontal)element).TimeStart), (double)((LineHorisontal)element).Value),
                    new DataPoint(DateTimeAxis.ToDouble(((LineHorisontal)element).TimeEnd), (double)((LineHorisontal)element).Value)
                });

                indi_area.lines_series_list.Add(line);
            }

            if (element is PointElement)
            {
                MarkerType shape = MarkerType.None;

                int size = (int)(((PointElement)element).Size / 2);

                double stroke_thickness = 1;

                if (((PointElement)element).Style == System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle)
                {
                    shape = MarkerType.Circle;
                }

                else if (((PointElement)element).Style == System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Diamond)
                {
                    shape = MarkerType.Diamond;
                }

                else if (((PointElement)element).Style == System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Square)
                {
                    shape = MarkerType.Square;
                }

                else if (((PointElement)element).Style == System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Cross)
                {
                    shape            = MarkerType.Cross;
                    stroke_thickness = size / 2;
                }

                else if (((PointElement)element).Style == System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Triangle)
                {
                    shape = MarkerType.Triangle;
                }

                else if (((PointElement)element).Style == System.Windows.Forms.DataVisualization.Charting.MarkerStyle.None)
                {
                    shape = MarkerType.None;
                }

                else
                {
                    shape            = MarkerType.Star;
                    stroke_thickness = size / 4;
                }

                PointAnnotation point = new PointAnnotation()
                {
                    X               = DateTimeAxis.ToDouble(((PointElement)element).TimePoint),
                    Y               = (double)((PointElement)element).Y,
                    Layer           = AnnotationLayer.AboveSeries,
                    Fill            = OxyColor.FromArgb(((PointElement)element).Color.A, ((PointElement)element).Color.R, ((PointElement)element).Color.G, ((PointElement)element).Color.B),
                    Shape           = shape,
                    Size            = size,
                    StrokeThickness = stroke_thickness,
                    Stroke          = OxyColor.FromArgb(((PointElement)element).Color.A, ((PointElement)element).Color.R, ((PointElement)element).Color.G, ((PointElement)element).Color.B),
                    Tag             = "point"
                };


                OxyArea area;

                if (indicators_list.Exists(x => (string)x.Tag == element.Area))
                {
                    area = indicators_list.Find(x => (string)x.Tag == element.Area);

                    area.plot_model.Annotations.Add(point);
                }

                if (element.Area == "Prime")
                {
                    prime_chart.plot_model.Annotations.Add(point);
                }
            }
        }
예제 #3
0
 public override AnnotationBase AnnotateWord()
 {
     pointAnnotation = base.InitAnnotationBase(pointAnnotation) as PointAnnotation;
     return(pointAnnotation);
 }
예제 #4
0
        protected override FileProcessingResult MakeOnePlot(ResultFileEntry srcEntry)
        {
            string plotName = "Critical desire threshhold violations for " + srcEntry.HouseholdNumberString;

            Profiler.StartPart(Utili.GetCurrentMethodAndClass());
            var headers = new List <string>();
            var values  = new List <double[]>();

            if (srcEntry.FullFileName == null)
            {
                throw new LPGException("Filename was null");
            }
            using (var sr = new StreamReader(srcEntry.FullFileName)) {
                var top = sr.ReadLine();
                if (top == null)
                {
                    throw new LPGException("Readline failed");
                }
                var header1 = top.Split(Parameters.CSVCharacterArr, StringSplitOptions.None);
                headers.AddRange(header1);
                while (!sr.EndOfStream)
                {
                    var s = sr.ReadLine();
                    if (s == null)
                    {
                        throw new LPGException("Readline failed");
                    }
                    var cols   = s.Split(Parameters.CSVCharacterArr, StringSplitOptions.None);
                    var result = new double[headers.Count];
                    for (var index = 0; index < cols.Length; index++)
                    {
                        var col     = cols[index];
                        var success = double.TryParse(col, out double d);
                        if (success)
                        {
                            result[index] = d;
                        }
                    }
                    values.Add(result);
                }
            }
            var plotModel1 = new PlotModel();

            if (Parameters.ShowTitle)
            {
                plotModel1.Title = plotName;
            }
            var linearAxis1 = new LinearAxis
            {
                Position = AxisPosition.Bottom
            };

            plotModel1.Axes.Add(linearAxis1);
            var linearAxis2 = new LinearAxis();

            plotModel1.Axes.Add(linearAxis2);
            plotModel1.IsLegendVisible = false;
            for (var i = 2; i < headers.Count; i++)
            {
                var lineSeries1 = new LineSeries
                {
                    Title = headers[i]
                };
                for (var j = 0; j < values.Count; j++)
                {
                    lineSeries1.Points.Add(new DataPoint(j, values[j][i]));
                }
                //lineSeries1.Smooth = true;

                plotModel1.Series.Add(lineSeries1);
                var pointAnnotation1 = new PointAnnotation
                {
                    X    = values.Count - 1,
                    Y    = values[values.Count - 1][i],
                    Text = headers[i],
                    TextHorizontalAlignment = HorizontalAlignment.Right,
                    TextVerticalAlignment   = VerticalAlignment.Middle,
                    TextColor = lineSeries1.Color
                };
                plotModel1.Annotations.Add(pointAnnotation1);
            }
            Save(plotModel1, plotName, srcEntry.FullFileName, Parameters.BaseDirectory, CalcOption.CriticalViolations);
            Profiler.StopPart(Utili.GetCurrentMethodAndClass());
            return(FileProcessingResult.ShouldCreateFiles);
        }
예제 #5
0
 void AddPointAnnotation()
 {
     _pointAnnotation = AppleMapsDemoUtils.CreateInitialPointAnnotation();
     _map.AddAnnotation(_pointAnnotation);
 }
예제 #6
0
        protected override FileProcessingResult MakeOnePlot(ResultFileEntry srcEntry)
        {
            string plotName = "Device Duration Curve " + srcEntry.HouseholdNumberString + " " + srcEntry.LoadTypeInformation?.Name;

            Profiler.StartPart(Utili.GetCurrentMethodAndClass());

            var entries = new Dictionary <int, ValueEntry>();

            if (srcEntry.FullFileName == null)
            {
                throw new LPGException("Filename was null");
            }
            ReadFile(srcEntry.FullFileName, entries);
            foreach (var keyValuePair in entries)
            {
                keyValuePair.Value.Values.Sort((x, y) => y.CompareTo(x));
            }
            var plotModel1 = new PlotModel();

            if (Parameters.ShowTitle)
            {
                plotModel1.Title = plotName;
            }
            var linearAxis1 = new LinearAxis
            {
                Position = AxisPosition.Bottom,
                Title    = "Time"
            };

            plotModel1.Axes.Add(linearAxis1);
            var linearAxis2 = new LinearAxis
            {
                Title = srcEntry.LoadTypeInformation?.Name + " [" + srcEntry.LoadTypeInformation?.UnitOfPower + "]"
            };

            plotModel1.Axes.Add(linearAxis2);
            plotModel1.IsLegendVisible = true;
            var globalMax = entries.Values.Where(x => x.Index > 2).Select(x => x.Values.Max()).Max();

            var filtered =
                entries.Values.Where(x => x.Index > 2 && x.Sum != 0 && x.Values.Max() > globalMax * 0.01).ToList();

            if (filtered.Count == 0)
            {
                filtered = entries.Values.Where(x => x.Index > 2).ToList();
            }
            var filtered2 = filtered.OrderByDescending(x => x.Sum).ToList();

            if (filtered2.Count == 0 && entries.Count > 0)
            {
                throw new LPGException("Bug in the filtering for the device duration curves!");
            }
            var labeled = filtered2.Take(10).ToList();

            foreach (var entry in filtered2)
            {
                var lineSeries1 = new LineSeries
                {
                    Title = entry.Name
                };
                for (var j = 0; j < entry.Values.Count; j++)
                {
                    lineSeries1.Points.Add(new DataPoint(j, entry.Values[j]));
                }
                //lineSeries1.Smooth = false;

                plotModel1.Series.Add(lineSeries1);
                if (labeled.Contains(entry))
                {
                    var pointAnnotation1 = new PointAnnotation
                    {
                        X    = 10,
                        Y    = entry.Values[0],
                        Text = entry.Name,
                        TextHorizontalAlignment = HorizontalAlignment.Left,
                        TextVerticalAlignment   = VerticalAlignment.Middle,
                        TextColor = lineSeries1.Color
                    };
                    plotModel1.Annotations.Add(pointAnnotation1);
                }
            }
            Save(plotModel1, plotName, srcEntry.FullFileName, Parameters.BaseDirectory, CalcOption.DurationCurve);
            Profiler.StopPart(Utili.GetCurrentMethodAndClass());
            return(FileProcessingResult.ShouldCreateFiles);
        }