public static PlotModel ConstantBaselineItemsSource()
 {
     var plotModel1 = new PlotModel { Title = "AreaSeries with constant baseline", Subtitle = "ItemsSource and DataField2 not set, ConstantY2 = -20" };
     var areaSeries1 = new AreaSeries();
     var points = new[] { new DataPoint(0, 50), new DataPoint(10, 140), new DataPoint(20, 60) };
     areaSeries1.ItemsSource = points;
     areaSeries1.DataFieldX = "X";
     areaSeries1.DataFieldY = "Y";
     areaSeries1.ConstantY2 = -20;
     plotModel1.Series.Add(areaSeries1);
     return plotModel1;
 }
Beispiel #2
0
        private void UpdateChromatogramPlot()
        {
            var chroSeries = new AreaSeries();

            chroSeries.Color = Colors.ColorBrewer8ClassSet2(255).Last();

            for (int i = 0; i < ChromatogramData.PositionsArray[0].Length; i++)
            {
                chroSeries.Points.Add(new DataPoint(ChromatogramData.PositionsArray[0][i], ChromatogramData.IntensitiesArray[0][i]));
            }

            chromatogram.Series.Clear();
            chromatogram.Series.Add(chroSeries);

            double max = (from i in ChromatogramData.IntensitiesArray[0] select i).Max() * 1.5;

            if (max <= 0)
            {
                max = 1000;
            }

            (chromatogram.Annotations[0] as LineAnnotation).X = RawData.RetentionTimeFromScanNumber(Convert.ToInt32(scanNumber.Text));

            chromatogram.Axes[y].AbsoluteMaximum = max;
            chromatogram.Axes[y].Maximum         = chromatogram.Axes[y].AbsoluteMaximum;

            chromatogram.InvalidatePlot(true);
        }
Beispiel #3
0
        private void GenerateSeries(string seriesType)
        {
            CategoricalAxis horizontalAxis = new CategoricalAxis();
            LinearAxis      verticalAxis   = new LinearAxis();

            verticalAxis.AxisType = AxisType.Second;

            for (int i = 0; i < 2; i++)
            {
                CartesianSeries series;
                if (seriesType == "Area")
                {
                    series = new AreaSeries();
                }
                else
                {
                    series = new LineSeries();
                }

                series.PointSize      = new SizeF(5, 5);
                series.HorizontalAxis = horizontalAxis;
                series.VerticalAxis   = verticalAxis;
                series.BorderWidth    = 2;
                series.CategoryMember = "Month";
                series.ValueMember    = "Revenue";
                series.DataSource     = i == 0 ? collection1 : collection2;
                series.ShowLabels     = showLabels;
                series.CombineMode    = selectedCombineMode;

                this.radChartView1.Series.Add(series);
            }
        }
Beispiel #4
0
        private List <Series> DrawSelectedMember(TS_part selectedPart, TS_contour selectedContour, TS_reinforcement selectedReinforcement)
        {
            OxyColor selectedColor = OxyColors.Magenta;

            List <Series> listaSerii = new List <Series>();

            if (selectedPart != null)
            {
                TS_contour contour    = selectedPart.Contour as TS_contour;
                LineSeries seria_part = new LineSeries();
                seria_part.Color           = selectedColor;
                seria_part.StrokeThickness = 2 * generalThickness;
                seria_part.LineStyle       = LineStyle.Dash;

                foreach (var side in contour.Sides)
                {
                    DataPoint point1 = new DataPoint(side.StartPoint.X, side.StartPoint.Y);
                    seria_part.Points.Add(point1);
                    DataPoint point2 = new DataPoint(side.EndPoint.X, side.EndPoint.Y);
                    seria_part.Points.Add(point2);
                }
                listaSerii.Add(seria_part);
            }

            if (selectedContour != null)
            {
                AreaSeries seria_cont = new AreaSeries();
                seria_cont.Color           = selectedColor;
                seria_cont.StrokeThickness = 2 * generalThickness;

                foreach (var side in selectedContour.Sides)
                {
                    DataPoint point1 = new DataPoint(side.StartPoint.X, side.StartPoint.Y);
                    seria_cont.Points.Add(point1);
                    DataPoint point2 = new DataPoint(side.EndPoint.X, side.EndPoint.Y);
                    seria_cont.Points.Add(point2);
                }
                listaSerii.Add(seria_cont);
            }

            // to poniżej na pewno do poprawy
            if (selectedReinforcement != null)
            {
                TS_reinforcement reo = selectedReinforcement;

                ScatterSeries seria_reo = new ScatterSeries();
                seria_reo.MarkerFill = selectedColor;
                seria_reo.MarkerType = MarkerType.Circle;

                foreach (var bar in reo.Bars)
                {
                    ScatterPoint point = new ScatterPoint(bar.Coordinates.X, bar.Coordinates.Y);
                    point.Size = bar.Diameter * 100;
                    seria_reo.Points.Add(point);
                }
                listaSerii.Add(seria_reo);
            }

            return(listaSerii);
        }
		private RadCartesianChartView createChart(){
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			LinearAxis verticalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			verticalAxis.LabelFormat= "%.0f";
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			chart.VerticalAxis = verticalAxis;
			chart.HorizontalAxis = horizontalAxis;


			for (int i = 0; i < 3; i++) {
				//Create the bar series and attach axes and value bindings.
				AreaSeries areaSeries = new AreaSeries();

				//We want to stack the different area series.
				areaSeries.CombineMode = ChartSeriesCombineMode.Stack;

				areaSeries.ValueBinding = new ValueBinding();
				areaSeries.CategoryBinding = new CategoryBinding();

				//Bind series to data
				areaSeries.Data = this.getData();

				//Add series to chart
				chart.Series.Add(areaSeries);
			}

			ChartTrackBallBehavior tbBehavior = new ChartTrackBallBehavior(this.Activity);
			tbBehavior.ShowIntersectionPoints = true;
			chart.Behaviors.Add(tbBehavior);

			return chart;
		}
Beispiel #6
0
        private void InitializePlot()
        {
            plotmodel = new PlotModel();

            plotmodel.PlotAreaBorderThickness = new OxyThickness(0);

            series = new AreaSeries {
                MarkerType = MarkerType.None
            };
            series.StrokeThickness        = 6.0;
            series.LineStyle              = LineStyle.Solid;
            series.Color                  = OxyColors.DodgerBlue;
            series.InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline;
            series.Fill   = OxyColor.FromArgb(255, 240, 245, 255);
            series.Color2 = OxyColors.Red;

            plotmodel.Series.Add(series);
            plotview.Model = plotmodel;

            plotview.Model.InvalidatePlot(true);

            foreach (var axis in plotview.Model.Axes)
            {
                axis.AxislineStyle = LineStyle.None;
                axis.TickStyle     = TickStyle.None;
                axis.MajorStep     = 1.0;
                axis.Font          = "Calibri";
                axis.TextColor     = OxyColors.DarkGray;
            }

            //plotview.Model.Axes[1].MajorStep = 5;
            //plotview.Model.Axes[1].Minimum = 10;
            //plotview.Model.Axes[1].Maximum = 30;
        }
Beispiel #7
0
        private RadCartesianChartView createChart()
        {
            //Create the Chart View
            RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

            LinearAxis verticalAxis = new LinearAxis();

            //The values in the linear axis will not have values after the decimal point.
            verticalAxis.LabelFormat = "%.0f";
            CategoricalAxis horizontalAxis = new CategoricalAxis();

            chart.VerticalAxis   = verticalAxis;
            chart.HorizontalAxis = horizontalAxis;


            for (int i = 0; i < 3; i++)
            {
                //Create the area series and attach axes and value bindings.
                AreaSeries areaSeries = new AreaSeries();

                //We want to stack the different area series.
                areaSeries.CombineMode = ChartSeriesCombineMode.Stack;

                areaSeries.ValueBinding    = new ValueBinding();
                areaSeries.CategoryBinding = new CategoryBinding();

                //Bind series to data
                areaSeries.Data = this.getData();

                //Add series to chart
                chart.Series.Add(areaSeries);
            }

            return(chart);
        }
        //return a functionserie for integral
        public AreaSeries GetFunctionSerieIntegral(double lowerbound, double upperbound, ref double Result)
        {
            AreaSeries serie = new AreaSeries();
            decimal    result = 0;
            double     n = 20000, x1 = 0, x2 = 0;
            double     delta;

            if (lowerbound <= upperbound)
            {
                x1 = lowerbound;
                x2 = upperbound;
            }
            else
            {
                x1 = upperbound;
                x2 = lowerbound;
            }
            delta = (x2 - x1) / n;
            for (double x = x1; x <= x2; x += delta)
            {
                result += RootFunc.Calculate((decimal)x) * (decimal)delta;
                DataPoint data = new DataPoint(x, (double)RootFunc.Calculate((decimal)x));
                serie.Points.Add(data);
            }
            Result = (double)result;
            return(serie);
        }
        private RadCartesianChartView createChart()
        {
            //Create the Chart View
            RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

            //Create the area series and attach axes and value bindings.
            AreaSeries areaSeries = new AreaSeries();

            areaSeries.ValueBinding    = new ValueBinding();
            areaSeries.CategoryBinding = new CategoryBinding();

            LinearAxis verticalAxis = new LinearAxis();

            //The values in the linear axis will not have values after the decimal point.
            verticalAxis.LabelFormat = "%.0f";
            CategoricalAxis horizontalAxis = new CategoricalAxis();

            areaSeries.VerticalAxis   = verticalAxis;
            areaSeries.HorizontalAxis = horizontalAxis;

            //Bind series to data
            areaSeries.Data = this.getData();

            //Add series to chart
            chart.Series.Add(areaSeries);
            return(chart);
        }
        public void RebuildChartsPanel()
        {
            _plantAreaChartsPanel.Children.Clear();
            foreach (MeasurableParameter measurableParameter in _measurableParameters)
            {
                if (measurableParameter != null)
                {
                    Chart chart = new Chart
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Width = 1100,
                        Height = 225,
                        BorderBrush = Brushes.Black,
                        Background = (LinearGradientBrush) MainWindow.ResourceDictionary["ChartBackground"],
                        Title = measurableParameter.MeasurableType,
                    };

                    AreaSeries areaSeries = new AreaSeries
                    {
                        IndependentValueBinding = new Binding("Key"),
                        DependentValueBinding = new Binding("Value"),
                        Title = measurableParameter.MeasurableType,
                    };
                    chart.Series.Add(areaSeries);
                    _plantAreaChartsPanel.Children.Add(chart);
                }
            }

            DockPanel chartDescriptorPanel = CreateChartDescriptorPanel();

            _plantAreaChartsPanel.Children.Add(chartDescriptorPanel);
        }
Beispiel #11
0
        public static IEnumerable <AreaSeries> StackLineSeries(
            IList <LineSeries> series)
        {
            double[] total = new double[series[0].Points.Count];

            for (int s = 0; s < series.Count; s++)
            {
                LineSeries lineSeries = series[s];
                AreaSeries areaSeries = new AreaSeries()
                {
                    Title = lineSeries.Title,
                    Color = lineSeries.Color,
                };

                for (int p = 0; p < lineSeries.Points.Count; p++)
                {
                    double x = lineSeries.Points[p].X;
                    double y = lineSeries.Points[p].Y;

                    areaSeries.Points.Add(new DataPoint(x, total[p]));
                    total[p] += y;
                    areaSeries.Points2.Add(new DataPoint(x, total[p]));
                }

                yield return(areaSeries);
            }
        }
Beispiel #12
0
        public void InitializeSpendingGraph()
        {
            var configConnectionString = ConfigurationManager.ConnectionStrings["mongodb"].ConnectionString;
            var client            = new MongoClient(configConnectionString);
            var database          = client.GetDatabase("projectdb");
            var projectCollection = database.GetCollection <Project>("projectdbcollection");

            var projectCollectionQueryable = projectCollection.AsQueryable();
            var projectCollectionList      = projectCollectionQueryable.ToList();

            var project = projectCollectionList.First();

            var areaSeries = new AreaSeries();

            foreach (var category in project.Categories)
            {
                areaSeries.DataPoints.Add(new CategoricalDataPoint((double)category.Amount, category.CategoryName));
            }

            //areaSeries.DataPoints.Add(new CategoricalDataPoint(13, "Jan"));
            //areaSeries.DataPoints.Add(new CategoricalDataPoint(20, "Apr"));
            //areaSeries.DataPoints.Add(new CategoricalDataPoint(15, "Jul"));
            //areaSeries.DataPoints.Add(new CategoricalDataPoint(16, "Oct"));

            radChartViewSpendingGraph.Series.Add(areaSeries);
        }
Beispiel #13
0
        private async Task <PlotModel> GetInsulinModel(NightView nv)
        {
            var model = new PlotModel();

            model.Axes.Add(new DateTimeAxis {
                Position = AxisPosition.Bottom,
                Minimum  = DateTimeAxis.ToDouble(Start.LocalDateTime),
                Maximum  = DateTimeAxis.ToDouble(End.LocalDateTime)
            });

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left,
                Minimum  = 0,
                Maximum  = 10
            });

            var basalSeries = new AreaSeries {
                Title = "Basal rate", InterpolationAlgorithm = new PreviousValueInterpolationAlgorithm()
            };

            await foreach (var tv in nv.BasalRates(Start, End))
            {
                basalSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(tv.Time.LocalDateTime), (double)tv.Value));
            }

            model.Series.Add(basalSeries);
            return(model);
        }
Beispiel #14
0
        private void CreateSeriesPoints(ISparqlQueryResult result)
        {
            AreaSeries series = CreateSeries("Facts x 1000", OxyColor.Parse("#119eda"));

            int    d  = 0;
            int    n  = 0;
            double y0 = 0;
            double y1 = 0;

            foreach (BindingSet binding in result.GetBindings())
            {
                DateTime x = DateTime.Parse(binding["time"].ToString());
                double   y = Convert.ToInt32(binding["facts"]);

                if (n == 0)
                {
                    y0 = y;
                }

                if (d != x.DayOfYear)
                {
                    d = x.DayOfYear;

                    n++;
                }

                y1 = y;

                series.Points.Add(DateTimeAxis.CreateDataPoint(x, y / 1000));
            }

            AverageDelta = n > 0 ? (y1 - y0) / n : 0;

            Model.Series.Add(series);
        }
Beispiel #15
0
        public ScalarProgressionControl()
        {
            InitializeComponent();
            m_Chart = chartControl1.Charts[0];

            m_Line = (AreaSeries)m_Chart.Series[0];
            m_Line.XValues.Clear();
            m_Line.Values.Clear();
            m_Line.UseXValues = true;
            m_Line.Values.ValueFormatting.Format        = ValueFormat.CustomNumber;
            m_Line.Values.ValueFormatting.CustomFormat  = "0.00";
            m_Line.XValues.ValueFormatting.Format       = ValueFormat.CustomNumber;
            m_Line.XValues.ValueFormatting.CustomFormat = "0.00";

            mChartGradientStartColor = Color.Red;
            mChartGradientEndColor   = Color.Yellow;

            m_Line.AreaFillEffect.BeginColor = mChartGradientStartColor;
            m_Line.AreaFillEffect.EndColor   = mChartGradientEndColor;

            m_Line.DataLabels.Mode = DataLabelsMode.None;

            mMinX          = 0;
            mMaxX          = 100;
            mMinY          = -100;
            mMaxY          = 100;
            mDefaultValue0 = mMinY;
            mDefaultValue1 = mMaxY;

            setAxisMinMax(mMinX, mMaxX, mMinY, mMaxY);

            enableLoopControl(LoopControl);
        }
Beispiel #16
0
            public void AreaSeries()
            {
                var s1 = new OxyPlot.Series.AreaSeries();
                var s2 = new AreaSeries();

                OxyAssert.PropertiesAreEqual(s1, s2);
            }
Beispiel #17
0
        public void DrawArea(
            string title,
            IEnumerable x1,
            IEnumerable y1,
            IEnumerable x2,
            IEnumerable y2,
            Models.Graph.Axis.AxisType xAxisType,
            Models.Graph.Axis.AxisType yAxisType,
            Color colour,
            bool showOnLegend)
        {
            AreaSeries series = new AreaSeries();

            series.Color = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B);
            series.Fill  = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B);
            List <DataPoint> points  = this.PopulateDataPointSeries(x1, y1, xAxisType, yAxisType);
            List <DataPoint> points2 = this.PopulateDataPointSeries(x2, y2, xAxisType, yAxisType);

            if (points != null && points2 != null)
            {
                foreach (DataPoint point in points)
                {
                    series.Points.Add(point);
                }

                foreach (DataPoint point in points2)
                {
                    series.Points2.Add(point);
                }
            }
            series.CanTrackerInterpolatePoints = false;

            this.plot1.Model.Series.Add(series);
        }
        public static PlotModel AreaSeries()
        {
            var model = new PlotModel {
                Title = "AreaSeries"
            };

            model.Axes.Add(new LinearAxis()
            {
                Title = "Day", Position = AxisPosition.Bottom
            });
            model.Axes.Add(new LinearAxis()
            {
                Title = "Output", Position = AxisPosition.Left
            });

            var areaSeries = new AreaSeries()
            {
                Color2 = OxyColors.Transparent
            };

            var r           = new Random(1);
            var dailyOutput = 10;

            for (int i = 0; i <= 100; i++)
            {
                areaSeries.Points.Add(new DataPoint(i, dailyOutput));
                //areaSeries.Points2.Add(new DataPoint(i, 0));

                dailyOutput = Math.Max(0, dailyOutput + r.Next(-2, 3));
            }

            model.Series.Add(areaSeries);
            return(model);
        }
        private AreaSeries createPercentileAreaSeries(SemanticHistogramDatum datum)
        {
            AreaSeries series = new AreaSeries();

            if (datum == this.EnergyHistogramDatumFirst)
            {
                series.Title = "A:" + datum.SemanticLink.Semantics;
            }
            else
            {
                series.Title = "B:" + datum.SemanticLink.Semantics;
            }

            double sumValue = datum.HistogramData.Sum(v => v.Value);

            series.Points.Add(new DataPoint(datum.MinLevel - datum.ClassWidth, 0));

            foreach (LevelAndValue item in datum.HistogramData)
            {
                series.Points.Add(new DataPoint(item.Level, item.Value * 100 / sumValue));
            }

            series.Points.Add(new DataPoint(datum.MaxLevel + datum.ClassWidth, 0));

            return(series);
        }
Beispiel #20
0
        public static PlotModel DefaultAnnotationLayer()
        {
            var plotModel1 = new PlotModel {
                Title = "Annotations should be drawn on top by default", Subtitle = "The line annotation should be on top!"
            };
            var areaSeries1 = new AreaSeries();

            areaSeries1.Points.Add(new DataPoint(0, 50));
            areaSeries1.Points.Add(new DataPoint(10, 40));
            areaSeries1.Points.Add(new DataPoint(20, 60));
            areaSeries1.Points2.Add(new DataPoint(0, 60));
            areaSeries1.Points2.Add(new DataPoint(5, 80));
            areaSeries1.Points2.Add(new DataPoint(20, 70));
            areaSeries1.Color  = OxyColors.Red;
            areaSeries1.Color2 = OxyColors.Blue;
            areaSeries1.Fill   = OxyColors.Yellow;

            plotModel1.Series.Add(areaSeries1);
            var lineAnnotation = new LineAnnotation
            {
                Type  = LineAnnotationType.Vertical,
                Layer = AnnotationLayer.AboveSeries,
                X     = 6
            };

            plotModel1.Annotations.Add(lineAnnotation);
            return(plotModel1);
        }
        private static PlotModel CreateKochSnowflake(int n, bool areaSeries = false)
        {
            var data = new[]
            {
                new DataPoint(-1, 0),
                new DataPoint(1, 0),
                new DataPoint(0, Math.Sqrt(3)), new DataPoint(-1, 0)
            };

            for (int i = 0; i < n; i++)
            {
                data = Fractalise(data, KochDetail);
            }
            var model = new PlotModel {
                Title = "Koch Snowflake", PlotType = PlotType.Cartesian
            };

            if (areaSeries)
            {
                var s = new AreaSeries {
                    ItemsSource = data, LineJoin = OxyPenLineJoin.Bevel, Fill = OxyColors.LightGray
                };
                model.Series.Add(s);
            }
            else
            {
                var ls = new LineSeries {
                    ItemsSource = data, LineJoin = OxyPenLineJoin.Bevel
                };
                model.Series.Add(ls);
            }
            return(model);
        }
        public void ConvertSeriesItems_ChartAreaDataWithRandomPointData_ConvertsAllPointsToAreaSeries()
        {
            // Setup
            var converter   = new ChartAreaDataConverter();
            var areaSeries  = new AreaSeries();
            var random      = new Random(21);
            int randomCount = random.Next(5, 10);
            var points      = new Collection <Point2D>();

            for (var i = 0; i < randomCount; i++)
            {
                points.Add(new Point2D(random.NextDouble(), random.NextDouble()));
            }

            var areaData = new ChartAreaData("test data")
            {
                Points = points.ToArray()
            };

            // Call
            converter.ConvertSeriesData(areaData, areaSeries);

            // Assert
            DataPoint[] expectedPoints = points.Select(t => new DataPoint(t.X, t.Y)).ToArray();
            CollectionAssert.AreEqual(expectedPoints, areaSeries.Points);
            CollectionAssert.AreEqual(new Collection <DataPoint>
            {
                expectedPoints.First()
            }, areaSeries.Points2);
        }
Beispiel #23
0
        private void CreateSeriesPoints(ISparqlQueryResult result)
        {
            AreaSeries series = CreateSeries("Size / MB", OxyColors.Orange);

            int    d  = 0;
            int    n  = 0;
            double y0 = 0;
            double y1 = 0;

            foreach (BindingSet binding in result.GetBindings())
            {
                DateTime x = DateTime.Parse(binding["time"].ToString());
                double   y = Convert.ToDouble(binding["size"]);

                if (n == 0)
                {
                    y0 = y;
                }

                if (d != x.DayOfYear)
                {
                    d = x.DayOfYear;

                    n++;
                }

                y1 = y;

                series.Points.Add(DateTimeAxis.CreateDataPoint(x, ToMegaByte(y, 2)));
            }

            AverageDelta = n > 0 ? ToKiloByte((y0 - y1) / n, 2) : 0;

            Model.Series.Add(series);
        }
		private RadCartesianChartView createChart(){
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			//Create the area series and attach axes and value bindings.
			AreaSeries areaSeries = new AreaSeries();

			areaSeries.ValueBinding  = new ValueBinding();
			areaSeries.CategoryBinding = new CategoryBinding();

			LinearAxis verticalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			verticalAxis.LabelFormat = "%.0f";
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			horizontalAxis.LabelInterval = 10;
			horizontalAxis.LabelFitMode = AxisLabelFitMode.MultiLine;
			areaSeries.VerticalAxis = verticalAxis;
			areaSeries.HorizontalAxis = horizontalAxis;

			//Bind series to data
			areaSeries.Data = this.getData();

			//Add series to chart
			chart.Series.Add(areaSeries);

			ChartPanAndZoomBehavior pzBehavior = new ChartPanAndZoomBehavior();

			pzBehavior.PanMode = ChartPanZoomMode.Both;
			pzBehavior.ZoomMode = ChartPanZoomMode.Both;

			chart.Behaviors.Add(pzBehavior);

			return chart;
		}
Beispiel #25
0
        public MemberPlotModel(Member member, string color, DamagePlotMode mode)
        {
            Member = member;
            Series = new AreaSeries();

            ChangeMode(mode);
            ChangeColor(color);
        }
            /// <summary>
            /// Initialize the object.
            /// </summary>
            public PlotData()
            {
                // Store the Profile data
                ProfileData = null;

                // Create a Bottom Track series
                BottomTrackData = null;
            }
Beispiel #27
0
        public static IPlotModel GetPlotModel(MeasurementHistory historyData, SensorClass sensorClass, string sensorName)
        {
            var graphDataPoints = new List <GraphData>();

            foreach (var item in historyData.Values.OrderBy(i => i.Timestamp))
            {
                graphDataPoints.Add(new GraphData()
                {
                    Y = double.Parse(item.Value, CultureInfo.InvariantCulture),
                    X = item.Timestamp
                });
            }

            var theme = (ColorThemeEnum)Preferences.Get(ColorTheme.ColorThemePreferenceName, 0);

            var plotModel = new ViewResolvingPlotModel()
            {
                Title = $"{sensorName} ({historyData.Unit})"
            };
            var ls = new AreaSeries()
            {
                DataFieldX = "X", DataFieldY = "Y", ItemsSource = graphDataPoints
            };

            plotModel.Series.Add(ls);

            // If values are all same, use custom min/max values to show graph
            var minValue = GetMinimumValue(graphDataPoints, sensorClass);
            var maxValue = GetMaximumValue(graphDataPoints, sensorClass);

            if (minValue == maxValue)
            {
                minValue = minValue - 5;
                maxValue = maxValue + 5;
            }

            plotModel.Axes.Add(GetLinearAxis(theme, AxisPosition.Left, minValue, maxValue, GetMajorStep(minValue, maxValue, sensorClass)));
            plotModel.Axes.Add(GetLinearAxis(theme, AxisPosition.Right, minValue, maxValue, GetMajorStep(minValue, maxValue, sensorClass)));
            plotModel.Axes.Add(GetDateTimeAxis(theme));

            switch (theme)
            {
            default:
            case ColorThemeEnum.Gray:
                plotModel.TitleColor                    = OxyColors.WhiteSmoke;
                plotModel.PlotAreaBorderColor           = OxyColors.DimGray;
                ((LineSeries)plotModel.Series[0]).Color = OxyColor.Parse("#FF9FA8DA");
                break;

            case ColorThemeEnum.Light:
                plotModel.TitleColor                    = OxyColors.Black;
                plotModel.PlotAreaBorderColor           = OxyColors.Black;
                ((LineSeries)plotModel.Series[0]).Color = OxyColor.Parse("#FF3F51B5");
                break;
            }
            return(plotModel);
        }
        public override void InitialValues()
        {
            AreaSeries series = (AreaSeries)DefaultControlToTest;

            TestAsync(
                series,
                () => Assert.IsNull(series.Geometry),
                () => Assert.IsNotNull(series.PathStyle));
        }
        private AreaSeries createPercentSeries(SemanticGraph semanticGraph)
        {
            AreaSeries series = new AreaSeries();

            series.Title = semanticGraph.SemanticLink.Semantics;

            series.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    if (SelectedSemanticLinks.Count > 0)
                    {
                        var dialog = new MainPageCompareDialog
                        {
                            Message               = { Text = semanticGraph.SemanticLink.Semantics },
                            TripDirection         = this.TripDirection,
                            SelectedSemanticLinks = this.SelectedSemanticLinks.ToList(),
                            SemanticLink          = semanticGraph.SemanticLink,
                            ViewModel             = this
                        };

                        DialogHost.Show(dialog, "RootDialog");
                    }
                    else
                    {
                        var dialog = new MainPageShowDetailDialog
                        {
                            Message       = { Text = semanticGraph.SemanticLink.Semantics },
                            TripDirection = this.TripDirection,
                            SemanticLink  = semanticGraph.SemanticLink,
                            ViewModel     = this
                        };

                        DialogHost.Show(dialog, "RootDialog");
                    }
                }
            };

            SemanticHistogramDatum datum = this.TimeHistogramData
                                           .Where(v => v.SemanticLink.SemanticLinkId == semanticGraph.SemanticLink.SemanticLinkId)
                                           .ElementAt(0);

            series.Points.Add(new DataPoint(datum.MinLevel - datum.ClassWidth, 0));

            foreach (LevelAndValue item in datum.HistogramData)
            {
                series.Points.Add(new DataPoint(item.Level, item.Value * 100 / datum.HistogramData.Sum(v => v.Value)));
            }

            series.Points.Add(new DataPoint(datum.MaxLevel + datum.ClassWidth, 0));

            AreaSeriesList.Add(series);
            semanticGraph.Series = series;

            return(series);
        }
        private void CalculateResourceChartPlotModel()
        {
            lock (m_Lock)
            {
                IList <ResourceSeriesDto> resourceSeriesSet = ResourceSeriesSet;
                PlotModel plotModel = null;
                if (resourceSeriesSet != null &&
                    resourceSeriesSet.Any())
                {
                    plotModel = new PlotModel();
                    plotModel.Axes.Add(BuildResourceChartXAxis());
                    plotModel.Axes.Add(BuildResourceChartYAxis());
                    plotModel.LegendPlacement = LegendPlacement.Outside;
                    plotModel.LegendPosition  = LegendPosition.RightMiddle;

                    var total = new List <int>();
                    m_DateTimeCalculator.UseBusinessDays(UseBusinessDays);

                    foreach (ResourceSeriesDto series in resourceSeriesSet)
                    {
                        if (series != null)
                        {
                            var areaSeries = new AreaSeries
                            {
                                Smooth          = false,
                                StrokeThickness = 0.0,
                                Title           = series.Title,
                                Color           = OxyColor.FromArgb(
                                    series.ColorFormatDto.A,
                                    series.ColorFormatDto.R,
                                    series.ColorFormatDto.G,
                                    series.ColorFormatDto.B)
                            };
                            for (int i = 0; i < series.Values.Count; i++)
                            {
                                int j = series.Values[i];
                                if (i >= total.Count)
                                {
                                    total.Add(0);
                                }
                                areaSeries.Points.Add(
                                    new DataPoint(ChartHelper.CalculateChartTimeXValue(i, ShowDates, ProjectStart, m_DateTimeCalculator),
                                                  total[i]));
                                total[i] += j;
                                areaSeries.Points2.Add(
                                    new DataPoint(ChartHelper.CalculateChartTimeXValue(i, ShowDates, ProjectStart, m_DateTimeCalculator),
                                                  total[i]));
                            }
                            plotModel.Series.Add(areaSeries);
                        }
                    }
                }
                ResourceChartPlotModel = plotModel;
            }
            RaiseCanExecuteChangedAllCommands();
        }
 public static PlotModel ConstantBaseline()
 {
     var plotModel1 = new PlotModel { Title = "AreaSeries with constant baseline", Subtitle = "Empty Points2, ConstantY2 = 0 (default)" };
     var areaSeries1 = new AreaSeries();
     areaSeries1.Points.Add(new DataPoint(0, 50));
     areaSeries1.Points.Add(new DataPoint(10, 140));
     areaSeries1.Points.Add(new DataPoint(20, 60));
     plotModel1.Series.Add(areaSeries1);
     return plotModel1;
 }
 private static AreaSeries CreateExampleSeries2()
 {
     var areaSeries1 = new AreaSeries();
     areaSeries1.Points.Add(new DataPoint(0, 50));
     areaSeries1.Points.Add(new DataPoint(10, 140));
     areaSeries1.Points.Add(new DataPoint(20, 60));
     areaSeries1.Points2.Add(new DataPoint(0, 60));
     areaSeries1.Points2.Add(new DataPoint(5, 80));
     areaSeries1.Points2.Add(new DataPoint(20, 70));
     return areaSeries1;
 }
        /// <summary>
        /// Add Bottom Track line series.  This will be a line to mark the bottom.
        /// </summary>
        private void PlotBtSeries(AreaSeries series)
        {
            // Lock the plot for an update
            lock (Plot.SyncRoot)
            {
                Plot.Series.Add(series);
            }

            // Then refresh the plot
            Plot.InvalidatePlot(true);
        }
Beispiel #34
0
 /// <summary>
 /// Draws the path.
 /// </summary>
 /// <param name="series">The series.</param>
 /// <param name="brush">The brush.</param>
 /// <param name="strokeThickness">The stroke thickness.</param>
 protected override void DrawPath(SeriesBase series, Brush brush, double strokeThickness)
 {
     if (series is AreaSeries)
     {
         AreaSeries areaSeries = series as AreaSeries;
         PartsCanvas.Children.Clear();
         foreach (SeriesPartBase part in areaSeries.Parts)
         {
             PartsCanvas.Children.Add(part.CreatePart());
         }
     }
 }
        private static AreaSeries CreateExampleAreaSeries()
        {
            var areaSeries1 = new AreaSeries();

            areaSeries1.Points.Add(new DataPoint(0, 50));
            areaSeries1.Points.Add(new DataPoint(10, 40));
            areaSeries1.Points.Add(new DataPoint(20, 60));
            areaSeries1.Points2.Add(new DataPoint(0, 60));
            areaSeries1.Points2.Add(new DataPoint(5, 80));
            areaSeries1.Points2.Add(new DataPoint(20, 70));
            return(areaSeries1);
        }
Beispiel #36
0
        private void AddSeries(int id)
        {
            AreaSeries areaSeries = new AreaSeries();

            areaSeries.PointsSource    = ViewModel.Data[id];
            areaSeries.XPath           = "Time";
            areaSeries.YPath           = "Value";
            areaSeries.Stroke          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF117DBB"));
            areaSeries.Fill            = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#11117DBB"));
            areaSeries.StrokeThickness = 1.0;
            Chart.Series.Add(areaSeries);
        }
Beispiel #37
0
 public static PlotModel CrossingLines()
 {
     var plotModel1 = new PlotModel { Title = "AreaSeries with crossing lines" };
     var areaSeries1 = new AreaSeries();
     areaSeries1.Points.Add(new DataPoint(0, 50));
     areaSeries1.Points.Add(new DataPoint(10, 140));
     areaSeries1.Points.Add(new DataPoint(20, 60));
     areaSeries1.Points2.Add(new DataPoint(0, 60));
     areaSeries1.Points2.Add(new DataPoint(5, 80));
     areaSeries1.Points2.Add(new DataPoint(20, 70));
     plotModel1.Series.Add(areaSeries1);
     return plotModel1;
 }
Beispiel #38
0
 public static PlotModel AreaSeries_CanTrackerInterpolatePointsTrue()
 {
     var plotModel1 = new PlotModel { Title = "AreaSeries with CanTrackerInterpolatePoints=true" };
     var areaSeries1 = new AreaSeries { CanTrackerInterpolatePoints = true };
     areaSeries1.Points.Add(new DataPoint(0, 50));
     areaSeries1.Points.Add(new DataPoint(10, 40));
     areaSeries1.Points.Add(new DataPoint(20, 60));
     areaSeries1.Points2.Add(new DataPoint(0, 60));
     areaSeries1.Points2.Add(new DataPoint(5, 80));
     areaSeries1.Points2.Add(new DataPoint(20, 70));
     plotModel1.Series.Add(areaSeries1);
     return plotModel1;
 }
Beispiel #39
0
       public override View GetSampleContent(Context context)
        {
            var chart = new SfChart(context);;
            chart.SetBackgroundColor(Color.White);
            chart.PrimaryAxis = new CategoryAxis {PlotOffset = 20};
            chart.SecondaryAxis = new NumericalAxis();

            var areaSeries = new AreaSeries
            {
                StrokeWidth = 5,
                Color = MainPage.ConvertHexaToColor(0x90FEBE17),
                Alpha = 0.5f,
                StrokeColor = MainPage.ConvertHexaToColor(0xFFFEBE17),
                DataSource = MainPage.GetAreaData(),
            };

            chart.Series.Add(areaSeries);
            return chart;
        }
		private RadCartesianChartView createChart() {
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			LinearAxis verticalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			verticalAxis.LabelFormat = "%.0f";
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			chart.VerticalAxis = verticalAxis;
			chart.HorizontalAxis = horizontalAxis;


			for (int i = 0; i < 3; i++) {
				//Create the bar series and attach axes and value bindings.
				AreaSeries areaSeries = new AreaSeries();

				//We want to stack the different area series.
				areaSeries.CombineMode = ChartSeriesCombineMode.Stack;

				areaSeries.ValueBinding = new ValueBinding();
				areaSeries.CategoryBinding = new CategoryBinding();

				//Bind series to data
				areaSeries.Data = this.getData();

				//Add series to chart
				chart.Series.Add(areaSeries);
			}

			ChartPalette defaultPaletteClone = new ChartPalette(chart.Palette);

			// We acquire the palette entry containing the settings for the third series in the chart setup.
			PaletteEntry areaSeriesEntry = defaultPaletteClone.GetEntry(ChartPalette.AreaFamily, 2);

			//We set the fill color of the third series to be cyan.
			areaSeriesEntry.Fill = Color.Cyan;

			//We reset the chart palette by applying the new one.
			chart.Palette = defaultPaletteClone;

			return chart;
		}
        public static PlotModel FilteringInvalidPointsAreaSeries()
        {
            var plot = new PlotModel { Title = "Filtering NaN points in an AreaSeries" };
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
            plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left });

            var as1 = new AreaSeries();
            as1.Points.Add(new DataPoint(1, 0));
            as1.Points.Add(new DataPoint(2, 10));
            as1.Points.Add(new DataPoint(3, 10));
            as1.Points.Add(new DataPoint(4, 0));
            as1.Points.Add(new DataPoint(5, 0));
            as1.Points.Add(new DataPoint(6, 7));
            as1.Points.Add(new DataPoint(7, 7));
            as1.Points.Add(new DataPoint(double.NaN, double.NaN));
            as1.Points.Add(new DataPoint(double.NaN, double.NaN));
            as1.Points.Add(new DataPoint(8, 0));
            as1.Points.Add(new DataPoint(9, 0));
            as1.Points.Add(new DataPoint(double.NaN, double.NaN));

            as1.Points2.Add(new DataPoint(1, 10));
            as1.Points2.Add(new DataPoint(2, 110));
            as1.Points2.Add(new DataPoint(3, 110));
            as1.Points2.Add(new DataPoint(4, 10));
            as1.Points2.Add(new DataPoint(5, 10));
            as1.Points2.Add(new DataPoint(6, 17));
            as1.Points2.Add(new DataPoint(7, 17));
            as1.Points2.Add(new DataPoint(double.NaN, double.NaN));
            as1.Points2.Add(new DataPoint(double.NaN, double.NaN));
            as1.Points2.Add(new DataPoint(8, 10));
            as1.Points2.Add(new DataPoint(9, 10));
            as1.Points2.Add(new DataPoint(double.NaN, double.NaN));

            plot.Series.Add(as1);

            return plot;
        }
		private RadCartesianChartView createChart(){
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			//Create the area series and attach axes and value bindings.
			AreaSeries areaSeries = new AreaSeries();

			areaSeries.ValueBinding = new ValueBinding();
			areaSeries.CategoryBinding = new CategoryBinding();

			LinearAxis verticalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			verticalAxis.LabelFormat = "%.0f";
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			areaSeries.VerticalAxis = verticalAxis;
			areaSeries.HorizontalAxis = horizontalAxis;

			//Bind series to data
			areaSeries.Data = this.getData();

			//Add series to chart
			chart.Series.Add(areaSeries);
			return chart;
		}
        public async void UpdateChart(bool isSelectedChanged = false)
        {
            if (!IsSelected)
            {
                if (ForecastContainer != null)
                {
                    ForecastContainer.Height = 0;
                }
                _animationPlayed = false;
                return;
            }
            if (!_initialized)
            {
                FindName(nameof(ForecastContainer));
                ForecastContainer.Height = 0;

                ValueAxis.Minimum = 0;
                ValueAxis.Maximum = 100;
                ValueAxis.Interval = 10;

                SelectionComboBox.ItemsSource = ComboBoxValues;
                SelectionComboBox.SelectedItem = ComboBoxValues[0];

                SelectionComboBox.SelectionChanged += (sender, args) => UpdateChart();

                ForecastContainer.Loaded += (sender, args) =>
                {
                    if (!_containerDesiredHeight.HasValue)
                    {
                        _containerDesiredHeight = ForecastChart.DesiredSize.Height +
                                                  SelectionComboBox.DesiredSize.Height;
                        if (isSelectedChanged)
                        {
                            BeginSlideOutAnimation();
                        }
                    }
                };
            }

            BeginSlideOutAnimation();

            var vm = ServiceLocator.Current.GetInstance<MainViewModel>();
            if (!vm.InternetAvailable)
            {
                return;
            }
            var parkingLot = DataContext as ParkingLot;
            if (parkingLot != null && parkingLot.HasForecast)
            {
                if (_initialized)
                {
                    ForecastChart.Series.Clear();
                }
                var timeSpanSelection = SelectionComboBox.SelectedItem as ParkingLotForecastTimespanSelection;
                var timeSpan = timeSpanSelection?.TimeSpan;
                if (timeSpan.HasValue)
                {
                    ForecastChart.Opacity = 0.2;
                    LoadingProgressRing.Visibility = Visibility.Visible;
                    await Task.Factory.StartNew(async () =>
                    {
                        var api = ServiceLocator.Current.GetInstance<IParkenDdClient>();
                        var mainVm = ServiceLocator.Current.GetInstance<MainViewModel>();
                        var now = DateTime.Now;
                        var startDate = _cachedForecastEndDate?.AddMinutes(30) ?? now;
                        var endDate = now.Add(timeSpan.Value);
                        if (endDate > startDate)
                        {
                            Forecast forecast;
                            try
                            {
                                forecast = await
                                    api.GetForecastAsync(mainVm.SelectedCity.Id, parkingLot.Id, startDate, endDate);
                            }
                            catch (ApiException e)
                            {
                                ServiceLocator.Current.GetInstance<ExceptionService>().HandleApiExceptionForForecastData(e, mainVm.SelectedCity, parkingLot);
                                return;
                            }
                            _cachedForecast.AddRange(forecast.Data.Select(
                                    item => new ParkingLotForecastDataPoint(item.Value, item.Key)));
                            if (_cachedForecastEndDate.HasValue)
                            {
                                if (_cachedForecastEndDate.Value < endDate)
                                {
                                    _cachedForecastEndDate = endDate;
                                }
                            }
                            else
                            {
                                _cachedForecastEndDate = endDate;
                            }
                        }
                        var points = _cachedForecast.Where(x => x.Time >= now && x.Time <= now.Add(timeSpan.Value));
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            var series = new AreaSeries
                            {
                                ItemsSource = points,
                                IndependentValuePath = "Time",
                                DependentValuePath = "Value",
                                Style = Application.Current.Resources["ParkingLotForecastChartAreaSeriesStyle"] as Style
                            };
                            ForecastChart.Series.Add(series);
                            ForecastChart.Opacity = 1;
                            LoadingProgressRing.Visibility = Visibility.Collapsed;
                        });
                        if (!_initialized)
                        {
                            ServiceLocator.Current.GetInstance<TrackingService>()?
                                .TrackForecastRangeEvent(parkingLot, timeSpanSelection?.Mode);
                        }
                        _initialized = true;
                    });
                }
            }
        }
        private AreaSeries ToAreaSeries(IEnumerable<KeyValuePair<double, double>> points, double integralValue)
        {
            var result = new AreaSeries
            {
                Title = integralValue.ToString(),
            };
            var p = points.ToList();
            result.Points.Add(new DataPoint(p[0].Key,0));
            for (int i = 0; i < p.Count-1; i++)
            {
                result.Points.Add(new DataPoint(p[i].Key, p[i].Value));
                result.Points.Add(new DataPoint(p[i + 1].Key, p[i].Value));
            }
            result.Points.Add(new DataPoint(p[p.Count-1].Key,0));
            result.Points.Add(new DataPoint(p[0].Key, 0));

            return result;
        }
Beispiel #45
0
 public void AreaSeries()
 {
     var s1 = new OxyPlot.Series.AreaSeries();
     var s2 = new AreaSeries();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
        private AreaSeries createAreaSeries(SemanticHistogramDatum datum)
        {
            AreaSeries series = new AreaSeries();

            if (datum == this.EnergyHistogramDatumFirst)
                series.Title = "A:" + datum.SemanticLink.Semantics;
            else
                series.Title = "B:" + datum.SemanticLink.Semantics;

            series.Points.Add(new DataPoint(datum.MinLevel - datum.ClassWidth, 0));

            foreach (LevelAndValue item in datum.HistogramData)
            {
                series.Points.Add(new DataPoint(item.Level, item.Value));
            }

            series.Points.Add(new DataPoint(datum.MaxLevel + datum.ClassWidth, 0));

            return series;
        }
Beispiel #47
0
        public void DrawArea(
            string title,
            IEnumerable x1,
            IEnumerable y1,
            IEnumerable x2,
            IEnumerable y2,
            Models.Graph.Axis.AxisType xAxisType,
            Models.Graph.Axis.AxisType yAxisType,
            Color colour,
            bool showOnLegend)
        {
            AreaSeries series = new AreaSeries();
            series.Color = ConverterExtensions.ToOxyColor(colour);
            series.Fill = ConverterExtensions.ToOxyColor(colour);
            List<DataPoint> points = this.PopulateDataPointSeries(x1, y1, xAxisType, yAxisType);
            List<DataPoint> points2 = this.PopulateDataPointSeries(x2, y2, xAxisType, yAxisType);

            if (points != null && points2 != null)
            {
                foreach (DataPoint point in points)
                {
                    series.Points.Add(point);
                }

                foreach (DataPoint point in points2)
                {
                    series.Points2.Add(point);
                }
            }
            series.CanTrackerInterpolatePoints = false;

            this.plot1.Model.Series.Add(series);
        }
        private void updateChart()
        {
            var instance = SelectedDistribution.Instance;
            var plot = SelectedDistribution.Measures.CreatePDF();

            var colorTrue = OxyColor.FromRgb(250, 0, 0);
            var colorFalse = OxyColor.FromRgb(200, 200, 200);

            if (Double.IsNaN(RightValue))
                return;


            if (instance is UnivariateDiscreteDistribution)
            {
                ValueStep = 1;

                string comparison = Comparisons[selectedIndex];

                var x = SelectedDistribution.Measures.XAxis;
                var y = SelectedDistribution.Measures.YAxis;

                var series = plot.Series[0] as ColumnSeries;

                if (comparison == EqualTo)
                {
                    int index = Array.IndexOf(x, (int)RightValue);
                    if (index >= 0)
                        series.Items[index].Color = (index >= 0) ? colorTrue : colorFalse;
                }
                else
                {
                    switch (comparison)
                    {
                        case LessThan:
                            for (int i = 0; i < x.Length; i++)
                                series.Items[i].Color = (x[i] <= RightValue) ? colorTrue : colorFalse;
                            break;
                        case GreaterThan:
                            for (int i = 0; i < x.Length; i++)
                                series.Items[i].Color = (x[i] > RightValue) ? colorTrue : colorFalse;
                            break;
                        case Between:
                            for (int i = 0; i < x.Length; i++)
                                series.Items[i].Color = (x[i] > LeftValue && x[i] <= RightValue) ? colorTrue : colorFalse;
                            break;
                        case Outside:
                            for (int i = 0; i < x.Length; i++)
                                series.Items[i].Color = (x[i] <= LeftValue || x[i] > RightValue) ? colorTrue : colorFalse;
                            break;
                        default:
                            break;
                    }
                }
            }
            else
            {
                ValueStep = SelectedDistribution.Measures.Range.Length / 100.0;

                string comparison = Comparisons[selectedIndex];

                var x = SelectedDistribution.Measures.XAxis;
                var y = SelectedDistribution.Measures.YAxis;

                if (comparison == EqualTo)
                {
                    var area = new LineSeries();
                    area.XAxisKey = "xAxis";
                    area.YAxisKey = "yAxis";
                    area.MarkerType = MarkerType.Circle;
                    area.MarkerSize = 10;
                    area.Points.Add(new DataPoint(RightValue, Probability));
                    plot.Series.Add(area);
                }
                else
                {
                    var left = new AreaSeries();
                    left.XAxisKey = "xAxis";
                    left.YAxisKey = "yAxis";
                    left.Fill = colorTrue;
                    left.Smooth = true;

                    var right = new AreaSeries();
                    right.XAxisKey = "xAxis";
                    right.YAxisKey = "yAxis";
                    right.Fill = colorTrue;
                    right.Smooth = true;

                    switch (comparison)
                    {
                        case LessThan:
                            for (int i = 0; i < x.Length; i++)
                                if (x[i] <= RightValue)
                                    left.Points.Add(new DataPoint(x[i], y[i]));
                            break;
                        case GreaterThan:
                            for (int i = 0; i < x.Length; i++)
                                if (x[i] > RightValue)
                                    left.Points.Add(new DataPoint(x[i], y[i]));
                            break;
                        case Between:
                            for (int i = 0; i < x.Length; i++)
                                if (x[i] >= LeftValue && x[i] < RightValue)
                                    left.Points.Add(new DataPoint(x[i], y[i]));
                            break;
                        case Outside:
                            for (int i = 0; i < x.Length; i++)
                            {
                                if (x[i] <= LeftValue)
                                    left.Points.Add(new DataPoint(x[i], y[i]));
                                if (x[i] >= RightValue)
                                    right.Points.Add(new DataPoint(x[i], y[i]));
                            }
                            break;
                        default:
                            break;
                    }

                    foreach (var point in left.Points)
                        left.Points2.Add(new DataPoint(point.X, 0));

                    foreach (var point in right.Points)
                        right.Points2.Add(new DataPoint(point.X, 0));

                    if (left.Points.Count > 0)
                        plot.Series.Add(left);

                    if (right.Points.Count > 0)
                        plot.Series.Add(right);
                }
            }

            this.DensityFunction = plot;
        }
        /// <summary>
        /// Function that plots a <see cref="Measurement"/> to the <see cref="MeasurementsPlotModel"/>.
        /// </summary>
        /// <param name="measurement"><see cref="Measurement"/> to be plotted.</param>
        public void PlotMeasurement(Measurement measurement)
        {
            if (SelectedDataBindingInterval > 0 && measurement.EnergyCalLinear > SelectedDataBindingInterval)
            { MessageBox.Show("Selected data binding interval is smaller than the actual channel spacing!", "Error"); SelectedDataBindingInterval = 0; return; }

            OfflineUpdateTimer.Stop();

            var MeassuredPlot = new AreaSeries
            {
                Tag = measurement,
                StrokeThickness = 2,
                MarkerSize = 3,
                Color = LineColors[measurement.MeasurementID % LineColors.Count],
                CanTrackerInterpolatePoints = false,
                Title = GetMeasurementTitle(measurement),
                Smooth = false,
            };

            var SimulatedPlot = new AreaSeries
            {
                Tag = measurement,
                StrokeThickness = 2,
                MarkerSize = 3,
                Color = LineColors[measurement.MeasurementID % LineColors.Count],
                CanTrackerInterpolatePoints = false,
                Title = GetMeasurementTitle(measurement) + " (Sim.)",
                Smooth = false,
            };

            float[] spectrumX = measurement.SpectrumXCal;
            int[] spectrumY = measurement.SpectrumY;
            int[] spectrumYCalculated = measurement.SpectrumYSimulated;

            if (spectrumYCalculated == null || ShowSimulatedSpectra == false)
            {
                spectrumYCalculated = new int[measurement.NumOfChannels];
            }

            // Remove "Counts<CutOffCounts" data points from start/end of the spectra
            int BorderOffset = 200;

            double CutOffCounts = spectrumY.Max() * CutOffCountsPercent / 100;
            if (CutOffCounts == 0) CutOffCounts = 1;

            int rightBorderIndex = spectrumY.Count();
            while (spectrumY[rightBorderIndex - 1] < CutOffCounts && rightBorderIndex > 2) rightBorderIndex--;

            int leftBorderIndex = 0;
            while (spectrumY[leftBorderIndex] < CutOffCounts && leftBorderIndex < spectrumY.Count() - 2) leftBorderIndex++;

            if (rightBorderIndex < 5) rightBorderIndex = spectrumY.Count();
            if (leftBorderIndex > spectrumY.Count() - 5) leftBorderIndex = 0;

            if (rightBorderIndex + BorderOffset < spectrumY.Count()) rightBorderIndex += BorderOffset; else rightBorderIndex = spectrumY.Count();
            if (leftBorderIndex - BorderOffset > 0) leftBorderIndex -= BorderOffset; else leftBorderIndex = 0;

            // Add points to plot
            switch (SelectedDataBindingInterval)
            {
                case 0: // Average undistinguishable points in spectrumX/spectrumY
                    {
                        var XAxis = MeasurementsPlotModel.Axes.FirstOrDefault(x => x.Position == AxisPosition.Bottom);

                        int XPlotWidth = (int)(XAxis.ScreenMax.X - XAxis.ScreenMin.X);

                        int XDataWidth = rightBorderIndex - leftBorderIndex;

                        int AverageCount = (int)Math.Floor((double)XDataWidth / XPlotWidth / 2);
                        if (AverageCount == 0) AverageCount = 1;

                        int Count = 0;
                        int newY = 0;
                        int newYCalculated = 0;

                        for (int i = leftBorderIndex; i < rightBorderIndex; i++)
                        {
                            newY += spectrumY[i];
                            newYCalculated = +spectrumYCalculated[i];

                            if (Count < AverageCount - 1)
                            {
                                Count++;
                            }
                            else
                            {
                                if (newY == 0) newY = 1;
                                if (newYCalculated == 0) newYCalculated = 1;

                                MeassuredPlot.Points.Add(new DataPoint(spectrumX[i], (double)newY / AverageCount));
                                MeassuredPlot.Points2.Add(new DataPoint(spectrumX[i], (float)0.0001));

                                SimulatedPlot.Points.Add(new DataPoint(spectrumX[i], (double)newYCalculated / AverageCount));
                                SimulatedPlot.Points2.Add(new DataPoint(spectrumX[i], (float)0.0001));

                                Count = 0;
                                newY = 0;
                                newYCalculated = 0;
                            }
                        }
                        break;
                    }
                default: // Bind points inside SelectedDataBinding intervall
                    {
                        float x, y = 0, yCalculated = 0;
                        float intervalStart = SelectedDataBindingInterval * ((int)(spectrumX[leftBorderIndex] / SelectedDataBindingInterval) + (float)0.5); ;
                        int numOfPoints = 0;

                        for (int i = leftBorderIndex; i < rightBorderIndex; i++)
                        {
                            if (spectrumX[i] - intervalStart > SelectedDataBindingInterval)
                            {
                                x = intervalStart + (float)SelectedDataBindingInterval / 2;

                                if (y == 0) y = (float)0.0001;
                                if (yCalculated == 0) yCalculated = (float)0.0001;

                                MeassuredPlot.Points.Add(new DataPoint(x, y / numOfPoints * (SelectedDataBindingInterval / measurement.EnergyCalLinear)));
                                MeassuredPlot.Points2.Add(new DataPoint(x, (float)0.0001));

                                SimulatedPlot.Points.Add(new DataPoint(x, yCalculated / numOfPoints * (SelectedDataBindingInterval / measurement.EnergyCalLinear)));
                                SimulatedPlot.Points2.Add(new DataPoint(x, (float)0.0001));

                                y = 0;
                                yCalculated = 0;
                                numOfPoints = 0;
                                intervalStart += SelectedDataBindingInterval;
                            }
                            y += spectrumY[i];
                            yCalculated += spectrumYCalculated[i];
                            numOfPoints++;
                        }
                        break;
                    }
            }
            MeasurementsPlotModel.Series.Add(MeassuredPlot);
            if (measurement.SpectrumYSimulated != null && ShowSimulatedSpectra == true)
                MeasurementsPlotModel.Series.Add(SimulatedPlot);
            MeasurementsPlotModel.InvalidatePlot(true);

            // Check if measurement is running on another computer -> update measurement periodically
            if (measurement.Runs == true && MyGlobals.CanMeasure == false)
            {
                OfflineUpdateTimer = new Timer(MyGlobals.OfflineUpdateWorkerInterval);
                OfflineUpdateTimer.Elapsed += delegate { OfflineUpdateWorker(measurement.MeasurementID); };
                OfflineUpdateTimer.Start();
            }

            // Update TimePlotModel
            var lineSeries = (LineSeries)TimePlotModel.Series.FirstOrDefault();

            if (lineSeries.Points.Count() != MyGlobals.Charge_CountsOverTime.Count() && MyGlobals.Charge_CountsOverTime.Count() >= 2)
            {
                lineSeries.Points.Clear();
                foreach (var temp in MyGlobals.Charge_CountsOverTime)
                {
                    if (temp.Value > 0)
                    {
                        lineSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(temp.Time), temp.Value));
                    }
                }
                TimePlotModel.Axes.FirstOrDefault(x => x.Position == AxisPosition.Left).Minimum = 0.7 * MyGlobals.Charge_CountsOverTime.Where(x => x.Value > 0).Min(x => x.Value);
                TimePlotModel.Axes.FirstOrDefault(x => x.Position == AxisPosition.Left).Maximum = 1.3 * MyGlobals.Charge_CountsOverTime.Max(x => x.Value);

                TimePlotModel.InvalidatePlot(true);
            }
        }
Beispiel #50
0
        private void UpdateDataSet(DataSet ds)
        {

            foreach (var rls in model.Series.OfType<LineSeries>().ToList())
            {
                //Todo rls.Tag is null sometimes and throwing null pointer exception fix it
                if (!DataSets.Any(k=>k.Id.ToString() == rls.Tag.ToString()))
                {
                    model.Series.Remove(rls);
                }
            }
            if (ds.SparkLine || SparkLine)
            {
                SparkLine = true;
                model.IsLegendVisible = false;
                model.TitlePadding = 0;
                model.TitleFontSize = 0;
                model.SubtitleFontSize = 0;
                model.Title = "";
                model.Subtitle = "";
                model.Padding = new OxyThickness(0);
                model.PlotMargins = new OxyThickness(0);
                model.PlotAreaBorderThickness = 0;
                model.Axes.Clear();
                model.Axes.Add(new InvisibleAxis() { Position = AxisPosition.Left, IsAxisVisible = false });
                if (ds.DData != null)
                    model.Axes.Add(new InvisibleAxis() { Position = AxisPosition.Bottom, IsAxisVisible = false });
                else
                    model.Axes.Add(new InvisibleDateAxis() { Position = AxisPosition.Bottom, IsAxisVisible = false });

                if (ds.SparkLineAmount > 2)
                {
                    if (ds.DData != null)
                        ds.ReducedData = mf.CalculateReduction(ds.DData, ds.SparkLineAmount);
                    else
                    {

                        var r = (from n in ds.Data select new KeyValuePair<double, double>(DateTimeAxis.ToDouble(n.Key), n.Value)).ToSortedDictionary(k => k.Key, k => k.Value);
                        ds.ReducedData = mf.CalculateReduction(r, ds.SparkLineAmount);
                    }
                    ds.FunctionOperation = FunctionOperations.auto;
                }
                else if (ds.SparkLinePercentage > 0)
                {
                    if (ds.DData != null)
                        ds.ReducedData = mf.CalculateReduction(ds.DData, ds.SparkLinePercentage);
                    else
                    {
                        var r = (from n in ds.Data select new KeyValuePair<double, double>(DateTimeAxis.ToDouble(n.Key), n.Value)).ToSortedDictionary(k => k.Key, k => k.Value);
                        ds.ReducedData = mf.CalculateReduction(r, ds.SparkLinePercentage);
                    }
                    ds.FunctionOperation = FunctionOperations.auto;
                }
                foreach (var ax in model.Axes)
                {
                    ax.IsPanEnabled = false;
                    ax.IsZoomEnabled = false;
                }
                //foreach (var ax in model.Axes)
                //    ax.IsAxisVisible = false;
            }
            else SparkLine = false;

            if (model.Series.Count(k => ((Guid)k.Tag) == ds.Id) > 1)
                foreach (var r in model.Series.Where(k => ((Guid)k.Tag) == ds.Id).ToList())
                {
                    model.Series.Remove(r);
                }
            
            var ls = model.Series.FirstOrDefault(k => k.Tag.ToString() == ds.Id.ToString()) as LineSeries;
            if (ls==null)
                ls = new LineSeries(){Tag = ds.Id};
            ls.Smooth = ds.Smooth;
            ls.YAxisKey = (ds.RightAxis) ? "Right" : "Left";
            if (ls.YAxisKey == "Right")
            {
                var ra = model.Axes.FirstOrDefault(k => k.Key == "Right");
                if (ra == null)
                {
                    var linearAxis2 = new LinearAxis();
                    linearAxis2.Position = AxisPosition.Right;
                    linearAxis2.Key = "Right";
                    linearAxis2.Title = ds.Unit != null ? ds.Unit : "Value";
                    model.Axes.Add(linearAxis2);
                }

            }
            if (ls != null)
            {
                var res = GetDataSet(ds);
                

                if (res.Count == 1)
                {
                    ls.Points.Clear();
                    foreach (var a in res.First())
                    {
                        ls.Points.Add(new DataPoint(a.Key, a.Value));
                    }
                    var ap = model.Series.OfType<AreaSeries>().FirstOrDefault(k => k.Tag.ToString() == ds.Id.ToString());
                    if (ap != null)
                    {
                        model.Series.Remove(ap);
                    }
                }
                else if (ds.FunctionOperation == FunctionOperations.auto)
                {
                    var ap = model.Series.OfType<AreaSeries>().FirstOrDefault(k => k.Tag.ToString() == ds.Id.ToString());
                    if (ap == null)
                    {
                        ap = new AreaSeries() { Tag = ds.Id };
                        model.Series.Add(ap);
                    }
                    ap.Fill = OxyColor.FromAColor((byte)96,OxyColors.LightBlue);
                    ap.Color = OxyColors.Black;
                    ap.Points.Clear();
                    ap.Points2.Clear();
                    foreach (var a in res.Last())
                    {
                        ap.Points.Add(new DataPoint(a.Key, a.Value));
                    }
                    foreach (var a in res.First())
                    {
                        ap.Points2.Add(new DataPoint(a.Key, a.Value));
                    }
                    foreach (var a in res[1])
                    {
                        ls.Points.Add(new DataPoint(a.Key, a.Value));
                    }
                }
                else
                {
                    foreach (var r in model.Series.Where(k => ((Guid)k.Tag) == ds.Id).ToList())
                    {
                        model.Series.Remove(r);
                    }
                    var l = new List<SortedDictionary<DateTime, double>>();
                    int colidx = 0;
                    foreach (var lineseries in res)
                    {
                        var lss = new LineSeries();
                        var ll = new SortedDictionary<DateTime, double>();

                        ds.Color = AvailableColors[colidx];
                        colidx++;

                        lss.YAxisKey = (ds.RightAxis) ? "Right" : "Left";
                        lss.Smooth = ds.Smooth;
                        lss.Color = OxyColor.FromArgb(ds.Color.A, ds.Color.R, ds.Color.G, ds.Color.B);
                        lss.MarkerFill = OxyColor.FromArgb(255, 78, 154, 6);
                        lss.Tag = ds.Id;
                        foreach (var a in lineseries)
                        {
                            lss.Points.Add(new DataPoint(a.Key, a.Value));
                            ll.Add(DateTimeAxis.ToDateTime(a.Key), a.Value);
                        }
                        model.Series.Add(lss);
                        l.Add(ll);
                    }
                }



                model.RefreshPlot(true);
            }
        }
 private static PlotModel CreateKochSnowflake(int n, bool areaSeries = false)
 {
     var data = new[]
                    {
                        new DataPoint(-1, 0),
                        new DataPoint(1, 0),
                        new DataPoint(0, Math.Sqrt(3)), new DataPoint(-1, 0) };
     for (int i = 0; i < n; i++)
         data = Fractalise(data, KochDetail);
     var model = new PlotModel("Koch Snowflake") { PlotType = PlotType.Cartesian };
     if (areaSeries)
     {
         var s = new AreaSeries { ItemsSource = data, LineJoin = OxyPenLineJoin.Bevel, Fill=OxyColors.LightGray };
         model.Series.Add(s);
     }
     else
     {
         var ls = new LineSeries { ItemsSource = data, LineJoin = OxyPenLineJoin.Bevel };
         model.Series.Add(ls);
     }
     return model;
 }
        /// <summary>
        /// Function that plots all selected <see cref="Measurement"/>s over their channel number.
        /// </summary>
        public void PlotMeasurements()
        {
            foreach (Measurement measurement in selectedMeasurements)
            {
                var areaSeries = new AreaSeries
                {
                    Tag = measurement.MeasurementID,
                    StrokeThickness = 2,
                    MarkerSize = 3,
                    Color = LineColors[measurement.MeasurementID % LineColors.Count],
                    CanTrackerInterpolatePoints = false,
                    Title = string.Format("SpectrumID {0}", measurement.MeasurementID),
                    Smooth = false,
                };

                int[] spectrumY = measurement.SpectrumY;
                for (int i = 0; i < spectrumY.Count(); i++)
                {
                    areaSeries.Points.Add(new DataPoint(i, spectrumY[i]));
                    areaSeries.Points2.Add(new DataPoint(i, 0));
                }
                SelectedMeasurementsPlot.Series.Add(areaSeries);
            }
            SelectedMeasurementsPlot.InvalidatePlot(true);
        }
        public static PlotModel LineSeriesandAreaSeries()
        {
            var plotModel1 = new PlotModel("LineSeries and AreaSeries");
            var linearAxis1 = new LinearAxis(AxisPosition.Bottom);
            plotModel1.Axes.Add(linearAxis1);
            var linearAxis2 = new LinearAxis();
            plotModel1.Axes.Add(linearAxis2);
            var areaSeries1 = new AreaSeries
                {
                    Fill = OxyColors.LightBlue,
                    DataFieldX2 = "Time",
                    DataFieldY2 = "Minimum",
                    Color = OxyColors.Red,
                    StrokeThickness = 0,
                    MarkerFill = OxyColors.Transparent,
                    DataFieldX = "Time",
                    DataFieldY = "Maximum"
                };
            areaSeries1.Points2.Add(new DataPoint(0, -5.04135905692417));
            areaSeries1.Points2.Add(new DataPoint(2.5, -4.91731850813018));
            areaSeries1.Points2.Add(new DataPoint(5, -4.45266314658926));
            areaSeries1.Points2.Add(new DataPoint(7.5, -3.87303874542613));
            areaSeries1.Points2.Add(new DataPoint(10, -3.00101110255393));
            areaSeries1.Points2.Add(new DataPoint(12.5, -2.17980725503518));
            areaSeries1.Points2.Add(new DataPoint(15, -1.67332229254456));
            areaSeries1.Points2.Add(new DataPoint(17.5, -1.10537158549082));
            areaSeries1.Points2.Add(new DataPoint(20, -0.6145459544447));
            areaSeries1.Points2.Add(new DataPoint(22.5, 0.120028106039404));
            areaSeries1.Points2.Add(new DataPoint(25, 1.06357270435597));
            areaSeries1.Points2.Add(new DataPoint(27.5, 1.87301405606466));
            areaSeries1.Points2.Add(new DataPoint(30, 2.57569854952195));
            areaSeries1.Points2.Add(new DataPoint(32.5, 3.59165537664278));
            areaSeries1.Points2.Add(new DataPoint(35, 4.87991958133872));
            areaSeries1.Points2.Add(new DataPoint(37.5, 6.36214537958714));
            areaSeries1.Points2.Add(new DataPoint(40, 7.62564585126268));
            areaSeries1.Points2.Add(new DataPoint(42.5, 8.69606320261772));
            areaSeries1.Points2.Add(new DataPoint(45, 10.0118704438265));
            areaSeries1.Points2.Add(new DataPoint(47.5, 11.0434480519236));
            areaSeries1.Points2.Add(new DataPoint(50, 11.9794171576758));
            areaSeries1.Points2.Add(new DataPoint(52.5, 12.9591851832621));
            areaSeries1.Points2.Add(new DataPoint(55, 14.172107889304));
            areaSeries1.Points2.Add(new DataPoint(57.5, 15.5520057698488));
            areaSeries1.Points2.Add(new DataPoint(60, 17.2274942386092));
            areaSeries1.Points2.Add(new DataPoint(62.5, 18.6983982186757));
            areaSeries1.Points2.Add(new DataPoint(65, 20.4560332001448));
            areaSeries1.Points2.Add(new DataPoint(67.5, 22.4867327382261));
            areaSeries1.Points2.Add(new DataPoint(70, 24.5319674302041));
            areaSeries1.Points2.Add(new DataPoint(72.5, 26.600547815813));
            areaSeries1.Points2.Add(new DataPoint(75, 28.5210891459701));
            areaSeries1.Points2.Add(new DataPoint(77.5, 30.6793080755413));
            areaSeries1.Points2.Add(new DataPoint(80, 33.0546651200646));
            areaSeries1.Points2.Add(new DataPoint(82.5, 35.3256065179713));
            areaSeries1.Points2.Add(new DataPoint(85, 37.6336074839968));
            areaSeries1.Points2.Add(new DataPoint(87.5, 40.2012266359763));
            areaSeries1.Points2.Add(new DataPoint(90, 42.8923555399256));
            areaSeries1.Points2.Add(new DataPoint(92.5, 45.8665211907432));
            areaSeries1.Points2.Add(new DataPoint(95, 48.8200195945427));
            areaSeries1.Points2.Add(new DataPoint(97.5, 51.8304284402311));
            areaSeries1.Points2.Add(new DataPoint(100, 54.6969868542147));
            areaSeries1.Points2.Add(new DataPoint(102.5, 57.7047292990632));
            areaSeries1.Points2.Add(new DataPoint(105, 60.4216644602929));
            areaSeries1.Points2.Add(new DataPoint(107.5, 62.926258762519));
            areaSeries1.Points2.Add(new DataPoint(110, 65.1829734629407));
            areaSeries1.Points2.Add(new DataPoint(112.5, 67.2365592083133));
            areaSeries1.Points2.Add(new DataPoint(115, 69.5713628691022));
            areaSeries1.Points2.Add(new DataPoint(117.5, 71.7267046705944));
            areaSeries1.Points2.Add(new DataPoint(120, 73.633463102781));
            areaSeries1.Points2.Add(new DataPoint(122.5, 75.4660150158061));
            areaSeries1.Points2.Add(new DataPoint(125, 77.5669292504745));
            areaSeries1.Points2.Add(new DataPoint(127.5, 79.564218544664));
            areaSeries1.Points2.Add(new DataPoint(130, 81.8631309028078));
            areaSeries1.Points2.Add(new DataPoint(132.5, 83.9698189969034));
            areaSeries1.Points2.Add(new DataPoint(135, 86.3847886532009));
            areaSeries1.Points2.Add(new DataPoint(137.5, 88.5559348267764));
            areaSeries1.Points2.Add(new DataPoint(140, 91.0455050418365));
            areaSeries1.Points2.Add(new DataPoint(142.5, 93.6964157585504));
            areaSeries1.Points2.Add(new DataPoint(145, 96.284336864941));
            areaSeries1.Points2.Add(new DataPoint(147.5, 98.7508602689723));
            areaSeries1.Points2.Add(new DataPoint(150, 100.904510594255));
            areaSeries1.Points2.Add(new DataPoint(152.5, 103.266136681506));
            areaSeries1.Points2.Add(new DataPoint(155, 105.780951269521));
            areaSeries1.Points2.Add(new DataPoint(157.5, 108.032859257065));
            areaSeries1.Points2.Add(new DataPoint(160, 110.035478448093));
            areaSeries1.Points2.Add(new DataPoint(162.5, 112.10655731615));
            areaSeries1.Points2.Add(new DataPoint(165, 114.37480786097));
            areaSeries1.Points2.Add(new DataPoint(167.5, 116.403992550869));
            areaSeries1.Points2.Add(new DataPoint(170, 118.61663988727));
            areaSeries1.Points2.Add(new DataPoint(172.5, 120.538730287384));
            areaSeries1.Points2.Add(new DataPoint(175, 122.515721057177));
            areaSeries1.Points2.Add(new DataPoint(177.5, 124.474386629124));
            areaSeries1.Points2.Add(new DataPoint(180, 126.448283293214));
            areaSeries1.Points2.Add(new DataPoint(182.5, 128.373811322299));
            areaSeries1.Points2.Add(new DataPoint(185, 130.33627914667));
            areaSeries1.Points2.Add(new DataPoint(187.5, 132.487933658477));
            areaSeries1.Points2.Add(new DataPoint(190, 134.716989778456));
            areaSeries1.Points2.Add(new DataPoint(192.5, 136.817287595392));
            areaSeries1.Points2.Add(new DataPoint(195, 139.216488664698));
            areaSeries1.Points2.Add(new DataPoint(197.5, 141.50803227574));
            areaSeries1.Points2.Add(new DataPoint(200, 143.539586683614));
            areaSeries1.Points2.Add(new DataPoint(202.5, 145.535911545221));
            areaSeries1.Points2.Add(new DataPoint(205, 147.516964978686));
            areaSeries1.Points2.Add(new DataPoint(207.5, 149.592416731684));
            areaSeries1.Points2.Add(new DataPoint(210, 151.600983566512));
            areaSeries1.Points2.Add(new DataPoint(212.5, 153.498210993362));
            areaSeries1.Points2.Add(new DataPoint(215, 155.512606828247));
            areaSeries1.Points2.Add(new DataPoint(217.5, 157.426564302774));
            areaSeries1.Points2.Add(new DataPoint(220, 159.364474964172));
            areaSeries1.Points2.Add(new DataPoint(222.5, 161.152806492128));
            areaSeries1.Points2.Add(new DataPoint(225, 162.679069434562));
            areaSeries1.Points2.Add(new DataPoint(227.5, 163.893622036741));
            areaSeries1.Points2.Add(new DataPoint(230, 165.475827621238));
            areaSeries1.Points2.Add(new DataPoint(232.5, 167.303960444734));
            areaSeries1.Points2.Add(new DataPoint(235, 169.259393394952));
            areaSeries1.Points2.Add(new DataPoint(237.5, 171.265193646758));
            areaSeries1.Points2.Add(new DataPoint(240, 173.074304345192));
            areaSeries1.Points2.Add(new DataPoint(242.5, 174.975492766814));
            areaSeries1.Points2.Add(new DataPoint(245, 176.684088218484));
            areaSeries1.Points2.Add(new DataPoint(247.5, 178.406887247603));
            areaSeries1.Points.Add(new DataPoint(0, 5.0184649433561));
            areaSeries1.Points.Add(new DataPoint(2.5, 5.27685959268215));
            areaSeries1.Points.Add(new DataPoint(5, 5.81437064628786));
            areaSeries1.Points.Add(new DataPoint(7.5, 6.51022475040994));
            areaSeries1.Points.Add(new DataPoint(10, 7.49921246878766));
            areaSeries1.Points.Add(new DataPoint(12.5, 8.41941631823751));
            areaSeries1.Points.Add(new DataPoint(15, 9.09826907222079));
            areaSeries1.Points.Add(new DataPoint(17.5, 9.89500750098145));
            areaSeries1.Points.Add(new DataPoint(20, 10.6633345249404));
            areaSeries1.Points.Add(new DataPoint(22.5, 11.6249613445368));
            areaSeries1.Points.Add(new DataPoint(25, 12.8816391467497));
            areaSeries1.Points.Add(new DataPoint(27.5, 13.9665185705603));
            areaSeries1.Points.Add(new DataPoint(30, 14.8501816818724));
            areaSeries1.Points.Add(new DataPoint(32.5, 16.0683128022441));
            areaSeries1.Points.Add(new DataPoint(35, 17.5378799723172));
            areaSeries1.Points.Add(new DataPoint(37.5, 19.1262752954039));
            areaSeries1.Points.Add(new DataPoint(40, 20.4103953650735));
            areaSeries1.Points.Add(new DataPoint(42.5, 21.5430627723891));
            areaSeries1.Points.Add(new DataPoint(45, 22.9105459463366));
            areaSeries1.Points.Add(new DataPoint(47.5, 23.9802361888719));
            areaSeries1.Points.Add(new DataPoint(50, 24.8659461235003));
            areaSeries1.Points.Add(new DataPoint(52.5, 25.7303194442439));
            areaSeries1.Points.Add(new DataPoint(55, 26.7688545912359));
            areaSeries1.Points.Add(new DataPoint(57.5, 28.0545112571933));
            areaSeries1.Points.Add(new DataPoint(60, 29.7036634266394));
            areaSeries1.Points.Add(new DataPoint(62.5, 31.2273634344467));
            areaSeries1.Points.Add(new DataPoint(65, 33.1038196356519));
            areaSeries1.Points.Add(new DataPoint(67.5, 35.2639893610328));
            areaSeries1.Points.Add(new DataPoint(70, 37.434293559489));
            areaSeries1.Points.Add(new DataPoint(72.5, 39.7109359368267));
            areaSeries1.Points.Add(new DataPoint(75, 41.7573881676222));
            areaSeries1.Points.Add(new DataPoint(77.5, 44.0460374479862));
            areaSeries1.Points.Add(new DataPoint(80, 46.5098714746581));
            areaSeries1.Points.Add(new DataPoint(82.5, 48.7754012129155));
            areaSeries1.Points.Add(new DataPoint(85, 51.1619816926597));
            areaSeries1.Points.Add(new DataPoint(87.5, 53.9036778414639));
            areaSeries1.Points.Add(new DataPoint(90, 56.7448825012636));
            areaSeries1.Points.Add(new DataPoint(92.5, 59.9294987878434));
            areaSeries1.Points.Add(new DataPoint(95, 63.0148831289797));
            areaSeries1.Points.Add(new DataPoint(97.5, 66.0721745989622));
            areaSeries1.Points.Add(new DataPoint(100, 68.8980036274521));
            areaSeries1.Points.Add(new DataPoint(102.5, 71.7719322611447));
            areaSeries1.Points.Add(new DataPoint(105, 74.4206055336728));
            areaSeries1.Points.Add(new DataPoint(107.5, 76.816198386632));
            areaSeries1.Points.Add(new DataPoint(110, 79.0040432726983));
            areaSeries1.Points.Add(new DataPoint(112.5, 80.9617606926066));
            areaSeries1.Points.Add(new DataPoint(115, 83.1345574620341));
            areaSeries1.Points.Add(new DataPoint(117.5, 85.0701022046479));
            areaSeries1.Points.Add(new DataPoint(120, 86.8557530286516));
            areaSeries1.Points.Add(new DataPoint(122.5, 88.5673387745243));
            areaSeries1.Points.Add(new DataPoint(125, 90.6003321543338));
            areaSeries1.Points.Add(new DataPoint(127.5, 92.439864576254));
            areaSeries1.Points.Add(new DataPoint(130, 94.5383744861178));
            areaSeries1.Points.Add(new DataPoint(132.5, 96.4600166864507));
            areaSeries1.Points.Add(new DataPoint(135, 98.6091052949006));
            areaSeries1.Points.Add(new DataPoint(137.5, 100.496459351478));
            areaSeries1.Points.Add(new DataPoint(140, 102.705767030085));
            areaSeries1.Points.Add(new DataPoint(142.5, 105.009994476992));
            areaSeries1.Points.Add(new DataPoint(145, 107.31287026052));
            areaSeries1.Points.Add(new DataPoint(147.5, 109.584842542272));
            areaSeries1.Points.Add(new DataPoint(150, 111.641435600837));
            areaSeries1.Points.Add(new DataPoint(152.5, 113.988459973544));
            areaSeries1.Points.Add(new DataPoint(155, 116.50349048027));
            areaSeries1.Points.Add(new DataPoint(157.5, 118.753612704274));
            areaSeries1.Points.Add(new DataPoint(160, 120.801728924085));
            areaSeries1.Points.Add(new DataPoint(162.5, 122.902486914165));
            areaSeries1.Points.Add(new DataPoint(165, 125.104391935796));
            areaSeries1.Points.Add(new DataPoint(167.5, 127.06056966547));
            areaSeries1.Points.Add(new DataPoint(170, 129.217086578495));
            areaSeries1.Points.Add(new DataPoint(172.5, 131.151968896274));
            areaSeries1.Points.Add(new DataPoint(175, 133.159906275133));
            areaSeries1.Points.Add(new DataPoint(177.5, 135.065263957561));
            areaSeries1.Points.Add(new DataPoint(180, 137.041870026822));
            areaSeries1.Points.Add(new DataPoint(182.5, 138.937477489811));
            areaSeries1.Points.Add(new DataPoint(185, 140.776914926282));
            areaSeries1.Points.Add(new DataPoint(187.5, 142.786975776398));
            areaSeries1.Points.Add(new DataPoint(190, 144.862762377347));
            areaSeries1.Points.Add(new DataPoint(192.5, 146.89654967049));
            areaSeries1.Points.Add(new DataPoint(195, 149.204343821204));
            areaSeries1.Points.Add(new DataPoint(197.5, 151.369748673527));
            areaSeries1.Points.Add(new DataPoint(200, 153.324438580137));
            areaSeries1.Points.Add(new DataPoint(202.5, 155.173148715344));
            areaSeries1.Points.Add(new DataPoint(205, 157.0501827528));
            areaSeries1.Points.Add(new DataPoint(207.5, 159.109122278359));
            areaSeries1.Points.Add(new DataPoint(210, 161.044446932778));
            areaSeries1.Points.Add(new DataPoint(212.5, 162.942364031841));
            areaSeries1.Points.Add(new DataPoint(215, 164.966769883021));
            areaSeries1.Points.Add(new DataPoint(217.5, 166.89711806788));
            areaSeries1.Points.Add(new DataPoint(220, 168.906874949069));
            areaSeries1.Points.Add(new DataPoint(222.5, 170.85692034995));
            areaSeries1.Points.Add(new DataPoint(225, 172.602125010408));
            areaSeries1.Points.Add(new DataPoint(227.5, 173.964258466598));
            areaSeries1.Points.Add(new DataPoint(230, 175.629908385654));
            areaSeries1.Points.Add(new DataPoint(232.5, 177.495778359378));
            areaSeries1.Points.Add(new DataPoint(235, 179.432933300749));
            areaSeries1.Points.Add(new DataPoint(237.5, 181.400180771342));
            areaSeries1.Points.Add(new DataPoint(240, 183.232300309899));
            areaSeries1.Points.Add(new DataPoint(242.5, 185.225502661441));
            areaSeries1.Points.Add(new DataPoint(245, 186.979590140413));
            areaSeries1.Points.Add(new DataPoint(247.5, 188.816640077725));
            areaSeries1.Title = "Maximum/Minimum";
            plotModel1.Series.Add(areaSeries1);

            var lineSeries1 = new LineSeries
                {
                    Color = OxyColors.Blue,
                    MarkerFill = OxyColors.Transparent,
                    DataFieldX = "Time",
                    DataFieldY = "Value"
                };
            lineSeries1.Points.Add(new DataPoint(0, -0.011447056784037));
            lineSeries1.Points.Add(new DataPoint(2.5, 0.179770542275985));
            lineSeries1.Points.Add(new DataPoint(5, 0.6808537498493));
            lineSeries1.Points.Add(new DataPoint(7.5, 1.31859300249191));
            lineSeries1.Points.Add(new DataPoint(10, 2.24910068311687));
            lineSeries1.Points.Add(new DataPoint(12.5, 3.11980453160117));
            lineSeries1.Points.Add(new DataPoint(15, 3.71247338983811));
            lineSeries1.Points.Add(new DataPoint(17.5, 4.39481795774531));
            lineSeries1.Points.Add(new DataPoint(20, 5.02439428524784));
            lineSeries1.Points.Add(new DataPoint(22.5, 5.87249472528812));
            lineSeries1.Points.Add(new DataPoint(25, 6.97260592555283));
            lineSeries1.Points.Add(new DataPoint(27.5, 7.91976631331247));
            lineSeries1.Points.Add(new DataPoint(30, 8.71294011569719));
            lineSeries1.Points.Add(new DataPoint(32.5, 9.82998408944345));
            lineSeries1.Points.Add(new DataPoint(35, 11.208899776828));
            lineSeries1.Points.Add(new DataPoint(37.5, 12.7442103374955));
            lineSeries1.Points.Add(new DataPoint(40, 14.0180206081681));
            lineSeries1.Points.Add(new DataPoint(42.5, 15.1195629875034));
            lineSeries1.Points.Add(new DataPoint(45, 16.4612081950815));
            lineSeries1.Points.Add(new DataPoint(47.5, 17.5118421203978));
            lineSeries1.Points.Add(new DataPoint(50, 18.4226816405881));
            lineSeries1.Points.Add(new DataPoint(52.5, 19.344752313753));
            lineSeries1.Points.Add(new DataPoint(55, 20.47048124027));
            lineSeries1.Points.Add(new DataPoint(57.5, 21.8032585135211));
            lineSeries1.Points.Add(new DataPoint(60, 23.4655788326243));
            lineSeries1.Points.Add(new DataPoint(62.5, 24.9628808265612));
            lineSeries1.Points.Add(new DataPoint(65, 26.7799264178984));
            lineSeries1.Points.Add(new DataPoint(67.5, 28.8753610496295));
            lineSeries1.Points.Add(new DataPoint(70, 30.9831304948466));
            lineSeries1.Points.Add(new DataPoint(72.5, 33.1557418763199));
            lineSeries1.Points.Add(new DataPoint(75, 35.1392386567962));
            lineSeries1.Points.Add(new DataPoint(77.5, 37.3626727617638));
            lineSeries1.Points.Add(new DataPoint(80, 39.7822682973613));
            lineSeries1.Points.Add(new DataPoint(82.5, 42.0505038654434));
            lineSeries1.Points.Add(new DataPoint(85, 44.3977945883283));
            lineSeries1.Points.Add(new DataPoint(87.5, 47.0524522387201));
            lineSeries1.Points.Add(new DataPoint(90, 49.8186190205946));
            lineSeries1.Points.Add(new DataPoint(92.5, 52.8980099892933));
            lineSeries1.Points.Add(new DataPoint(95, 55.9174513617612));
            lineSeries1.Points.Add(new DataPoint(97.5, 58.9513015195966));
            lineSeries1.Points.Add(new DataPoint(100, 61.7974952408334));
            lineSeries1.Points.Add(new DataPoint(102.5, 64.738330780104));
            lineSeries1.Points.Add(new DataPoint(105, 67.4211349969828));
            lineSeries1.Points.Add(new DataPoint(107.5, 69.8712285745755));
            lineSeries1.Points.Add(new DataPoint(110, 72.0935083678195));
            lineSeries1.Points.Add(new DataPoint(112.5, 74.0991599504599));
            lineSeries1.Points.Add(new DataPoint(115, 76.3529601655682));
            lineSeries1.Points.Add(new DataPoint(117.5, 78.3984034376212));
            lineSeries1.Points.Add(new DataPoint(120, 80.2446080657163));
            lineSeries1.Points.Add(new DataPoint(122.5, 82.0166768951652));
            lineSeries1.Points.Add(new DataPoint(125, 84.0836307024042));
            lineSeries1.Points.Add(new DataPoint(127.5, 86.002041560459));
            lineSeries1.Points.Add(new DataPoint(130, 88.2007526944628));
            lineSeries1.Points.Add(new DataPoint(132.5, 90.2149178416771));
            lineSeries1.Points.Add(new DataPoint(135, 92.4969469740507));
            lineSeries1.Points.Add(new DataPoint(137.5, 94.5261970891274));
            lineSeries1.Points.Add(new DataPoint(140, 96.875636035961));
            lineSeries1.Points.Add(new DataPoint(142.5, 99.3532051177711));
            lineSeries1.Points.Add(new DataPoint(145, 101.798603562731));
            lineSeries1.Points.Add(new DataPoint(147.5, 104.167851405622));
            lineSeries1.Points.Add(new DataPoint(150, 106.272973097546));
            lineSeries1.Points.Add(new DataPoint(152.5, 108.627298327525));
            lineSeries1.Points.Add(new DataPoint(155, 111.142220874895));
            lineSeries1.Points.Add(new DataPoint(157.5, 113.39323598067));
            lineSeries1.Points.Add(new DataPoint(160, 115.418603686089));
            lineSeries1.Points.Add(new DataPoint(162.5, 117.504522115157));
            lineSeries1.Points.Add(new DataPoint(165, 119.739599898383));
            lineSeries1.Points.Add(new DataPoint(167.5, 121.732281108169));
            lineSeries1.Points.Add(new DataPoint(170, 123.916863232882));
            lineSeries1.Points.Add(new DataPoint(172.5, 125.845349591829));
            lineSeries1.Points.Add(new DataPoint(175, 127.837813666155));
            lineSeries1.Points.Add(new DataPoint(177.5, 129.769825293343));
            lineSeries1.Points.Add(new DataPoint(180, 131.745076660018));
            lineSeries1.Points.Add(new DataPoint(182.5, 133.655644406055));
            lineSeries1.Points.Add(new DataPoint(185, 135.556597036476));
            lineSeries1.Points.Add(new DataPoint(187.5, 137.637454717438));
            lineSeries1.Points.Add(new DataPoint(190, 139.789876077902));
            lineSeries1.Points.Add(new DataPoint(192.5, 141.856918632941));
            lineSeries1.Points.Add(new DataPoint(195, 144.210416242951));
            lineSeries1.Points.Add(new DataPoint(197.5, 146.438890474634));
            lineSeries1.Points.Add(new DataPoint(200, 148.432012631876));
            lineSeries1.Points.Add(new DataPoint(202.5, 150.354530130282));
            lineSeries1.Points.Add(new DataPoint(205, 152.283573865743));
            lineSeries1.Points.Add(new DataPoint(207.5, 154.350769505022));
            lineSeries1.Points.Add(new DataPoint(210, 156.322715249645));
            lineSeries1.Points.Add(new DataPoint(212.5, 158.220287512602));
            lineSeries1.Points.Add(new DataPoint(215, 160.239688355634));
            lineSeries1.Points.Add(new DataPoint(217.5, 162.161841185327));
            lineSeries1.Points.Add(new DataPoint(220, 164.135674956621));
            lineSeries1.Points.Add(new DataPoint(222.5, 166.004863421039));
            lineSeries1.Points.Add(new DataPoint(225, 167.640597222485));
            lineSeries1.Points.Add(new DataPoint(227.5, 168.928940251669));
            lineSeries1.Points.Add(new DataPoint(230, 170.552868003446));
            lineSeries1.Points.Add(new DataPoint(232.5, 172.399869402056));
            lineSeries1.Points.Add(new DataPoint(235, 174.346163347851));
            lineSeries1.Points.Add(new DataPoint(237.5, 176.33268720905));
            lineSeries1.Points.Add(new DataPoint(240, 178.153302327545));
            lineSeries1.Points.Add(new DataPoint(242.5, 180.100497714128));
            lineSeries1.Points.Add(new DataPoint(245, 181.831839179449));
            lineSeries1.Points.Add(new DataPoint(247.5, 183.611763662664));
            lineSeries1.Title = "Average";
            plotModel1.Series.Add(lineSeries1);
            return plotModel1;
        }
Beispiel #54
0
        public static PlotModel SunriseandsunsetinOslo()
        {
            int year = DateTime.Now.Year;

            // Convert UTC time to Western European Time (WET)
            Func<DateTime, DateTime> utcToLocalTime = utc => utc.AddHours(IsDaylightSaving(utc) ? 2 : 1);

            var sunData = CreateSunData(year, 59.91, 10.75, utcToLocalTime);

            var plotModel1 = new PlotModel { Title = "Sunrise and sunset in Oslo", Subtitle = "UTC time" };

            var dateTimeAxis1 = new DateTimeAxis
                {
                    CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
                    FirstDayOfWeek = DayOfWeek.Monday,
                    IntervalType = DateTimeIntervalType.Months,
                    MajorGridlineStyle = LineStyle.Solid,
                    Position = AxisPosition.Bottom,
                    StringFormat = "MMM"
                };
            plotModel1.Axes.Add(dateTimeAxis1);
            var timeSpanAxis1 = new TimeSpanAxis { MajorGridlineStyle = LineStyle.Solid, Maximum = 86400, Minimum = 0, StringFormat = "h:mm" };
            plotModel1.Axes.Add(timeSpanAxis1);
            var areaSeries1 = new AreaSeries
                {
                    ItemsSource = sunData,
                    DataFieldX = "Day",
                    DataFieldY = "Sunrise",
                    DataFieldX2 = "Day",
                    DataFieldY2 = "Sunset",
                    Fill = OxyColor.FromArgb(128, 255, 255, 0),
                    Color = OxyColors.Black
                };
            plotModel1.Series.Add(areaSeries1);
            return plotModel1;
        }
Beispiel #55
0
        bool ProcessSeriesData(ref List<object> listOfSeries, string chartType, string seriesDataString, ref string failOverMessage)
        {
            bool parsed = false;
            bool isSingleSeries = false;

            List<ColumnSeries> columnSeriesList = new List<ColumnSeries>();

            string[] seriesDataStringArray = seriesDataString.Split(new string[] { Statics.SeparateLineSeries }, StringSplitOptions.RemoveEmptyEntries);

            if (seriesDataStringArray.Length < 1)
            {
                isSingleSeries = true;
            }

            foreach (string lineSeriesItemString in seriesDataStringArray)
            {
                object series;
                switch (chartType.ToUpper().Replace(" ",""))
                {
                    case Statics.Area:
                        series = new AreaSeries();
                        ((AreaSeries)series).IndependentValuePath = "Key";
                        ((AreaSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Bar:
                        series = new ColumnSeries();
                        ((ColumnSeries)series).IndependentValuePath = "Key";
                        ((ColumnSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Bubble:
                        series = new BubbleSeries();
                        ((BubbleSeries)series).IndependentValuePath = "Key";
                        ((BubbleSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.RotatedBar:
                        series = new BarSeries();
                        ((BarSeries)series).IndependentValuePath = "Key";
                        ((BarSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Histogram:
                        series = new ColumnSeries();
                        ((ColumnSeries)series).IndependentValuePath = "Key";
                        ((ColumnSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Line:
                        series = new LineSeries();
                        ((LineSeries)series).IndependentValuePath = "Key";
                        ((LineSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Pie:
                        series = new PieSeries();
                        ((PieSeries)series).IndependentValuePath = "Key";
                        ((PieSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Scatter:
                        series = new ScatterSeries();
                        ((ScatterSeries)series).IndependentValuePath = "Key";
                        ((ScatterSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Stacked:
                        //series = new StackedBarSeries();
                        //((StackedBarSeries)series).IndependentValuePath = "Key";
                        //((StackedBarSeries)series).DependentValuePath = "Value";

                    case Statics.TreeMap:
                    default:
                        failOverMessage = "The specified graph type supplied in the input parameters (initParams) could not be parsed.";
                        return false;
                }

                string[] titleSplit = lineSeriesItemString.Split(new string[] { Statics.LineSeriesTitle }, StringSplitOptions.None);

                if (titleSplit.Length == 3)
                {
                    switch (chartType.ToUpper().Replace(" ", ""))
                    {
                        case Statics.Area:
                            ((AreaSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Bar:
                            ((ColumnSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Bubble:
                            ((BubbleSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.RotatedBar:
                            ((BarSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Histogram:
                            ((ColumnSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Line:
                            ((LineSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Pie:
                            ((PieSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Scatter:
                            ((ScatterSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Stacked:
                        case Statics.TreeMap:
                        default:
                            break;
                    }
                }

                Dictionary<object, object> pointList = new Dictionary<object, object>();

                string[] dataSplit = lineSeriesItemString.Split(new string[] { Statics.LineSeriesDataString }, StringSplitOptions.None);

                object independentValue = string.Empty;
                object dependentValue = 0.0;

                if (dataSplit.Length == 3)
                {
                    string dataString = dataSplit[1];

                    string[] dataPairStringArray = dataString.Split(new string[] { Statics.SeparateDataPoints }, StringSplitOptions.None);

                    foreach (string pair in dataPairStringArray)
                    {
                        if (pair.Length > 0)
                        {
                            string[] set = pair.Split(new string[] { Statics.SeparateIndDepValues }, StringSplitOptions.None);

                            try
                            {
                                if (set.Length == 2)
                                {
                                    Double doubleCandidate;
                                    DateTime dateTimeCandidate;

                                    // < independent >
                                    if (Double.TryParse(set[0], out doubleCandidate))
                                    {
                                        independentValue = doubleCandidate;

                                        if (_minIndependentValueIsValid)
                                        {
                                            if ((double)independentValue < (double)_minIndependentValue)
                                            {
                                                _minIndependentValue = independentValue;
                                            }
                                        }
                                        else
                                        {
                                            _minIndependentValue = independentValue;
                                            _minIndependentValueIsValid = true;
                                        }

                                        if (_maxIndependentValueIsValid)
                                        {
                                            if ((double)independentValue > (double)_maxIndependentValue)
                                            {
                                                _maxIndependentValue = independentValue;
                                            }
                                        }
                                        else
                                        {
                                            _maxIndependentValue = independentValue;
                                            _maxIndependentValueIsValid = true;
                                        }
                                    }
                                    else if (DateTime.TryParse(set[0], out dateTimeCandidate))
                                    {
                                        independentValue = dateTimeCandidate;

                                        if (_minIndependentValueIsValid)
                                        {
                                            if ((DateTime)independentValue < (DateTime)_minIndependentValue)
                                            {
                                                _minIndependentValue = independentValue;
                                            }
                                        }
                                        else
                                        {
                                            _minIndependentValue = independentValue;
                                            _minIndependentValueIsValid = true;
                                        }

                                        if (_maxIndependentValueIsValid)
                                        {
                                            if ((DateTime)independentValue > (DateTime)_maxIndependentValue)
                                            {
                                                _maxIndependentValue = independentValue;
                                            }
                                        }
                                        else
                                        {
                                            _maxIndependentValue = independentValue;
                                            _maxIndependentValueIsValid = true;
                                        }
                                    }
                                    else
                                    {
                                        independentValue = set[0].ToString();
                                    }

                                    // < dependent >
                                    if (Double.TryParse(set[1], out doubleCandidate))
                                    {
                                        dependentValue = doubleCandidate;
                                    }
                                    else if (DateTime.TryParse(set[1], out dateTimeCandidate))
                                    {
                                        dependentValue = dateTimeCandidate;
                                    }
                                    else
                                    {
                                        dependentValue = set[1].ToString();
                                    }

                                    pointList.Add(independentValue, dependentValue);
                                }
                            }
                            catch
                            {
                                return false;
                            }
                        }
                    }
                }
                else
                {
                    failOverMessage = string.Format("Parse fail with '{0}'", lineSeriesItemString);
                    return false;
                }

                AddItemSourceToSeries(chartType, series, pointList);

                if (isSingleSeries)
                {
                    AddAxesToSeries(chartType, series, independentValue);
                }
                else
                {
                    //((ColumnSeries)series).IndependentAxis = new LinearAxis
                    //{
                    //    Title = _independentLabel,
                    //    Orientation = AxisOrientation.X,
                    //    Minimum = (double)_minIndependentValue,
                    //    Maximum = (double)_maxIndependentValue
                    //};
                }

                listOfSeries.Add(series);
                parsed = true;
            }
            return parsed;
        }
        private AreaSeries createCalculatedAreaSeries(SemanticHistogramDatum datum, int numberOfTrip)
        {
            AreaSeries series = new AreaSeries();

            if (datum == this.EnergyHistogramDatumFirst)
                series.Title = "A:" + datum.SemanticLink.Semantics;
            else
                series.Title = "B:" + datum.SemanticLink.Semantics;

            double sumValue = datum.HistogramData.Sum(v => v.Value);

            series.Points.Add(new DataPoint(datum.MinLevel - datum.ClassWidth, 0));

            foreach (LevelAndValue item in datum.HistogramData)
            {
                series.Points.Add(new DataPoint(item.Level, item.Value * numberOfTrip));
            }

            series.Points.Add(new DataPoint(datum.MaxLevel + datum.ClassWidth, 0));

            return series;
        }
Beispiel #57
0
        public static PlotModel DefaultAnnotationLayer()
        {
            var plotModel1 = new PlotModel { Title = "Annotations should be drawn on top by default", Subtitle = "The line annotation should be on top!" };
            var areaSeries1 = new AreaSeries();
            areaSeries1.Points.Add(new DataPoint(0, 50));
            areaSeries1.Points.Add(new DataPoint(10, 40));
            areaSeries1.Points.Add(new DataPoint(20, 60));
            areaSeries1.Points2.Add(new DataPoint(0, 60));
            areaSeries1.Points2.Add(new DataPoint(5, 80));
            areaSeries1.Points2.Add(new DataPoint(20, 70));
            areaSeries1.Color = OxyColors.Red;
            areaSeries1.Color2 = OxyColors.Blue;
            areaSeries1.Fill = OxyColors.Yellow;

            plotModel1.Series.Add(areaSeries1);
            var lineAnnotation = new LineAnnotation
            {
                Type = LineAnnotationType.Vertical,
                Layer = AnnotationLayer.AboveSeries,
                X = 6
            };

            plotModel1.Annotations.Add(lineAnnotation);
            return plotModel1;
        }
        void Setup(View itemView)
        { 
            CurrencyPairLabel = itemView.FindViewById<TextView>(Resource.Id.SpotTileCurrencyPairTextView);
            BidButton = itemView.FindViewById<PriceButton>(Resource.Id.SpotTileBidPriceButton);
            AskButton = itemView.FindViewById<PriceButton>(Resource.Id.SpotTileAskPriceButton);
            SpreadLabel = itemView.FindViewById<TextView>(Resource.Id.SpotTileSpreadTextView);
            UpArrow = itemView.FindViewById<DirectionArrow>(Resource.Id.SpotTileUpArrow);
            DownArrow = itemView.FindViewById<DirectionArrow>(Resource.Id.SpotTileDownArrow);
            DealtCurrencyLabel = itemView.FindViewById<TextView>(Resource.Id.SpotTileDealtCurrencyTextView);
            NotionalTextBox = itemView.FindViewById<EditText>(Resource.Id.SpotTileNotionalEditText);
            SpotDateLabel = itemView.FindViewById<TextView>(Resource.Id.SpotTileSpotDateTextView);
            Content = itemView.FindViewById<LinearLayout>(Resource.Id.SpotTileContent);
            CardView = itemView.FindViewById<CardView>(Resource.Id.CardView);
            ViewAnimator = itemView.FindViewById<ViewAnimator>(Resource.Id.ViewAnimator);
            PlotView = itemView.FindViewById<PlotView>(Resource.Id.plotView);
            PriceNotAvailableOverlay = itemView.FindViewById<LinearLayout>(Resource.Id.PriceNotAvailableOverlay);

            CardView.PreventCornerOverlap = false;
            CardView.Radius = 5;
            NotionalTextBox.EditorAction += (sender, args) =>
            {
                if (args.ActionId == ImeAction.Done)
                {
                    NotionalTextBox.ClearFocus();
                    HideKeyboard(NotionalTextBox);
                }
            };

            _plotModel = new PlotModel
            {
                PlotAreaBorderThickness = new OxyThickness(0),
                PlotAreaBorderColor = OxyColor.FromRgb(46, 59, 75)
            };
            _plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, IsAxisVisible = false, MaximumPadding = 0, MinimumPadding = 0, IsPanEnabled = false, IsZoomEnabled = false });
            _plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, IsAxisVisible = false, MaximumPadding = 0, MinimumPadding = 0, IsPanEnabled = false, IsZoomEnabled = false });

            _areaSeries = new AreaSeries {LineStyle = LineStyle.Solid, Color = OxyColor.FromRgb(46, 59, 75)};
            _plotModel.Series.Add(_areaSeries);
            _plotModel.Background = OxyColor.FromRgb(33, 42, 53);
            PlotView.Model = _plotModel;
            PlotView.OverScrollMode = OverScrollMode.Never;
            PlotView.ScrollBarSize = 0;
            PlotView.HorizontalScrollBarEnabled = false;
            PlotView.VerticalScrollBarEnabled = false;
        }
        public static PlotModel SunriseandsunsetinOslo()
        {
            int year = DateTime.Now.Year;
#if PCL
            var sunData = CreateSunData(year, 59.91, 10.75);
#else
            var sunData = CreateSunData(year, 59.91, 10.75, TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time"));
#endif
            var plotModel1 = new PlotModel("Sunrise and sunset in Oslo", "UTC time");

            var dateTimeAxis1 = new DateTimeAxis
                {
                    CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
                    FirstDayOfWeek = DayOfWeek.Monday,
                    IntervalType = DateTimeIntervalType.Months,
                    MajorGridlineStyle = LineStyle.Solid,
                    Position = AxisPosition.Bottom,
                    StringFormat = "MMM"
                };
            plotModel1.Axes.Add(dateTimeAxis1);
            var timeSpanAxis1 = new TimeSpanAxis { MajorGridlineStyle = LineStyle.Solid, Maximum = 86400, Minimum = 0, StringFormat = "h:mm" };
            plotModel1.Axes.Add(timeSpanAxis1);
            var areaSeries1 = new AreaSeries
                {
                    ItemsSource = sunData,
                    DataFieldX = "Day",
                    DataFieldY = "Sunrise",
                    DataFieldX2 = "Day",
                    DataFieldY2 = "Sunset",
                    Fill = OxyColor.FromArgb(128, 255, 255, 0),
                    Color = OxyColors.Black
                };
            plotModel1.Series.Add(areaSeries1);
            return plotModel1;
        }
        private void BindChartData()
        {
            try
            {
                if (Session["LegendA"] != null)
                {
                    //   lblLegend.Text = "Cashflow for " + Session["LegendA"].ToString();
                    // Session.Remove("Legend");
                }
                if (Session["LegendB"] != null)
                {
                    //if (lblLegend.Text.Length == 0)
                    //    lblLegend.Text = "Cashflow for " + Session["LegendB"].ToString();
                    //else
                    //    lblLegend.Text = lblLegend.Text + "And " + Session["LegendB"].ToString();
                }
                if (Session["LegendC"] != null)
                {
                    //if (lblLegend.Text.Length == 0)
                    //    lblLegend.Text = "Cashflow for " + Session["LegendC"].ToString();
                    //else
                    //    lblLegend.Text = lblLegend.Text + "And " + Session["LegendC"].ToString();
                }

                DataTable dt = new DataTable();

                dt.Columns.Add("ID");
                dt.Columns.Add("EndDate");
                dt.Columns.Add("Notation");

                if (Session["LegendA"] != null)
                {
                    dt = GetCompactChartData(Session["LegendA"].ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        //        RadHtmlChart1.HttpHandlerUrl = ResolveUrl("ChartImage.axd");

                        AreaSeries chartLoanA = new AreaSeries();

                        chartLoanA.Name = Session["LegendA"].ToString();

                        object maxDate = dt.Compute("MAX(EndDate)", null);
                        // chartLoanA.PlotArea.XAxis.MaxValue = Convert.ToDouble(Convert.ToDateTime(maxDate).ToOADate());

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            var dr = (dt.Rows[i]).ItemArray;
                            SeriesItem item = new SeriesItem();

                            if (dr[1] != null && dr[2] != null)
                            {
                                CategorySeriesItem seriesItem = new CategorySeriesItem();
                                //item.ActiveRegion.Tooltip = "On Date" + Convert.ToDateTime(dr[1]) + "Fraction Value is" + Convert.ToDouble(dr[2]);
                                AxisItem axisItem = new AxisItem();
                                DateTime date = Convert.ToDateTime(dr[1]);
                                item.XValue = date.Ticks;
                                //axisItem.LabelText =
                                //RadHtmlChart1.PlotArea.XAxis.LabelsAppearance.RotationAngle = 60;
                                string month = date.Date.Month.ToString();
                                if (month.Length == 1)
                                {
                                    month = "0" + month;
                                }

                                string str = month + date.Date.Year.ToString();
                                RadHtmlChart1.PlotArea.XAxis.Items.Add(str);
                                item.YValue = Convert.ToDecimal(dr[2].ToString());
                                //chartLoanA.Items.Add(item);
                                seriesItem.Y = Convert.ToDecimal(dr[2].ToString());
                                chartLoanA.SeriesItems.Add(seriesItem);

                            }

                        }

                        chartLoanA.LabelsAppearance.Visible = false;
                        chartLoanA.LineAppearance.LineStyle = ExtendedLineStyle.Step;
                        RadHtmlChart1.PlotArea.Series.Add(chartLoanA);

                    }
                }

                if (Session["LegendB"] != null)
                {
                    dt = GetCompactChartData(Session["LegendB"].ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {

                        AreaSeries chartLoanB = new AreaSeries();

                        chartLoanB.Name = Session["LegendB"].ToString();

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            var dr = (dt.Rows[i]).ItemArray;
                            SeriesItem item = new SeriesItem();

                            if (dr[1] != null && dr[2] != null)
                            {
                                CategorySeriesItem seriesItem = new CategorySeriesItem();
                                DateTime date = Convert.ToDateTime(dr[1]);
                                //item.XValue = date.ToOADate();
                                //item.YValue = Convert.ToDouble(dr[2]);
                                item.YValue = Convert.ToDecimal(dr[2].ToString());
                                //chartLoanA.Items.Add(item);
                                string month = date.Date.Month.ToString();
                                if (month.Length == 1)
                                {
                                    month = "0" + month;
                                }

                                string str = month + date.Date.Year.ToString();
                                RadHtmlChart1.PlotArea.XAxis.Items.Add(str);
                                seriesItem.Y = Convert.ToDecimal(dr[2].ToString());
                                chartLoanB.SeriesItems.Add(seriesItem);
                            }

                        }
                        chartLoanB.LabelsAppearance.Visible = false;
                        chartLoanB.LineAppearance.LineStyle = ExtendedLineStyle.Step;
                        RadHtmlChart1.PlotArea.Series.Add(chartLoanB);
                    }
                }

                if (Session["LegendC"] != null)
                {
                    dt = GetCompactChartData(Session["LegendC"].ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        AreaSeries chartLoanC = new AreaSeries();

                        chartLoanC.Name = Session["LegendC"].ToString();

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            var dr = (dt.Rows[i]).ItemArray;
                            SeriesItem item = new SeriesItem();
                            if (dr[1] != null && dr[2] != null)
                            {
                                CategorySeriesItem seriesItem = new CategorySeriesItem();
                                DateTime date = Convert.ToDateTime(dr[1]);
                                //item.XValue = date.ToOADate();
                                //item.YValue = Convert.ToDouble(dr[2]);
                                item.YValue = Convert.ToDecimal(dr[2].ToString());
                                //chartLoanA.Items.Add(item);
                                string month = date.Date.Month.ToString();
                                if (month.Length == 1)
                                {
                                    month = "0" + month;
                                }

                                string str = month + date.Date.Year.ToString();
                                RadHtmlChart1.PlotArea.XAxis.Items.Add(str);
                                seriesItem.Y = Convert.ToDecimal(dr[2].ToString());
                                chartLoanC.SeriesItems.Add(seriesItem);

                            }
                        }

                        chartLoanC.LabelsAppearance.Visible = false;
                        chartLoanC.LineAppearance.LineStyle = ExtendedLineStyle.Step;
                        RadHtmlChart1.PlotArea.Series.Add(chartLoanC);
                    }
                }
            }
            //RadHtmlChart1.DataSource = GetData();
            //RadHtmlChart1.DataBind();
            // tempCalculatedList = null;

            catch (Exception)
            {

            }
        }