private PlotModel CreateModel(String title)
 {
     var plotModel1 = new PlotModel();
     plotModel1.Title = title;
     var linearAxis1 = new DateTimeAxis(AxisPosition.Bottom, _start, _start + TimeSpan.FromMinutes(1));
     linearAxis1.MajorGridlineStyle = LineStyle.Solid;
     linearAxis1.MinorGridlineStyle = LineStyle.Dot;
     plotModel1.Axes.Add(linearAxis1);
     var linearAxis2 = new LinearAxis(AxisPosition.Left, "Value");
     linearAxis2.MajorGridlineStyle = LineStyle.Solid;
     linearAxis2.MinorGridlineStyle = LineStyle.Dot;
     plotModel1.Axes.Add(linearAxis2);
     plotModel1.Series.Add(new LineSeries()
     {
         Title = "X",
         Points = new List<IDataPoint>()
     });
     plotModel1.Series.Add(new LineSeries()
     {
         Title = "Y",
         Points = new List<IDataPoint>()
     });
     plotModel1.Series.Add(new LineSeries()
     {
         Title = "Z",
         Points = new List<IDataPoint>()
     });
     return plotModel1;
 }
        public static PlotModel MinuteData_DateTimeAxis()
        {
            var pm = new PlotModel { Title = "Minute Data (DateTimeAxis)" };

            var timeSpanAxis1 = new DateTimeAxis { Position = AxisPosition.Bottom, StringFormat = "hh:mm" };
            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis { Position = AxisPosition.Left };
            pm.Axes.Add(linearAxis1);
            var candleStickSeries = new CandleStickSeries
            {
                CandleWidth = 6,
                Color = OxyColors.Black,
                IncreasingFill = OxyColors.DarkGreen,
                DecreasingFill = OxyColors.Red,
                DataFieldX = "Time",
                DataFieldHigh = "H",
                DataFieldLow = "L",
                DataFieldOpen = "O",
                DataFieldClose = "C",
                TrackerFormatString = "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
                ItemsSource = lst
            };
            pm.Series.Add(candleStickSeries);
            return pm;
        }
Esempio n. 3
0
        public GraphSalesRank()
        {
            model = new PlotModel();
              model.Title = "SalesRank";

              DateTimeAxis axisX = new DateTimeAxis();
              axisX.Position = AxisPosition.Bottom;
              axisX.Title = "Date";
              model.Axes.Add(axisX);

              LinearAxis axisY = new LinearAxis();
              axisY.Position = AxisPosition.Left;
              axisY.Minimum = 0;
              axisY.Title = "SalesRank";
              model.Axes.Add(axisY);

              series = new LineSeries();
              series.Title = string.Format("ASIN: {0}", this.Asin);

              this.Asin = "0061670898";

              model.Series.Add(series);

              InitializeComponent();

              oxyPlotView.Model = model;
        }
        public static PlotModel DaylightSavingsBreak()
        {
            var m = new PlotModel();

            var xa = new DateTimeAxis(AxisPosition.Bottom);
#if PCL
            // TimeZone not available in PCL...
#else
            xa.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(
                "W. Europe Standard Time");
#endif
            m.Axes.Add(xa);
            m.Axes.Add(new LinearAxis(AxisPosition.Left));
            var ls = new LineSeries { MarkerType = MarkerType.Circle };
            m.Series.Add(ls);

            // set the origin of the curve to 2013-03-31 00:00:00 (UTC)
            var o = new DateTime(2013, 3, 31, 0, 0, 0, DateTimeKind.Utc);

            // add points at 10min intervals
            // at 2am the clocks are turned forward 1 hour (W. Europe Standard Time)
            for (int i = 0; i < 400; i += 10)
            {
                var time = o.AddMinutes(i);
                ls.Points.Add(DateTimeAxis.CreateDataPoint(time, i));
            }

            return m;
        }
        public static Example LargeDataSetNarrow()
        {
            var pm = new PlotModel { Title = "Large Data Set (narrow window)" };

            var timeSpanAxis1 = new DateTimeAxis { Position = AxisPosition.Bottom };
            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis { Position = AxisPosition.Left };
            pm.Axes.Add(linearAxis1);
            var n = 1000000;
            var items = HighLowItemGenerator.MRProcess(n).ToArray();
            var series = new CandleStickSeries
                             {
                                 Color = OxyColors.Black,
                                 IncreasingColor = OxyColors.DarkGreen,
                                 DecreasingColor = OxyColors.Red,
                                 TrackerFormatString =
                                     "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
                                 ItemsSource = items
                             };

            timeSpanAxis1.Minimum = items[0].X;
            timeSpanAxis1.Maximum = items[29].X;

            linearAxis1.Minimum = items.Take(30).Select(x => x.Low).Min();
            linearAxis1.Maximum = items.Take(30).Select(x => x.High).Max();

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();
            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return new Example(pm, controller);
        }
        public static PlotModel HighLowSeriesDateTimeAxis()
        {
            var m = new PlotModel();
            var x0 = DateTimeAxis.ToDouble(new DateTime(2013, 05, 04));
            var a = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Minimum = x0 - 0.9,
                Maximum = x0 + 1.9,
                IntervalType = DateTimeIntervalType.Days,
                MajorStep = 1,
                MinorStep = 1,
                StringFormat = "yyyy-MM-dd"
            };
            m.Axes.Add(a);
            var s = new HighLowSeries
            {
                TrackerFormatString =
                    "X: {1:yyyy-MM-dd}\nHigh: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}"
            };

            s.Items.Add(new HighLowItem(x0, 14, 10, 13, 12.4));
            s.Items.Add(new HighLowItem(x0 + 1, 17, 8, 12.4, 16.3));
            m.Series.Add(s);

            return m;
        }
Esempio n. 7
0
		void Line3()
		{
			Transaction[] transactions = LoadTransactions();

			DateTimeAxis dateTimeAxis = new DateTimeAxis();
			plotter.Add(dateTimeAxis);

			lineChart.DataSource = transactions;
			lineChart.XMapping = "Date";
			lineChart.XAxis = dateTimeAxis;
			lineChart.YMapping = "Value";
		}
Esempio n. 8
0
        private void SetUpChartModel()
        {
            _plotModel = new PlotModel
            {
                   
            };

            var stockDateTimeAxes = new DateTimeAxis();

            _plotModel.Axes.Add(stockDateTimeAxes);
            var linearAxes = new LinearAxis();

            _plotModel.Axes.Add(linearAxes);
        }
Esempio n. 9
0
        private void SetUpModel()
        {
            PlotModel.LegendTitle = "Legend";
            PlotModel.LegendOrientation = LegendOrientation.Horizontal;
            PlotModel.LegendPlacement = LegendPlacement.Outside;
            PlotModel.LegendPosition = LegendPosition.TopRight;
            PlotModel.LegendBackground = OxyColor.FromAColor(200, OxyColors.White);
            PlotModel.LegendBorder = OxyColors.Black;

            var dateAxis = new DateTimeAxis(AxisPosition.Bottom, "Date", "HH:mm") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80 };
            PlotModel.Axes.Add(dateAxis);
            var valueAxis = new LinearAxis(AxisPosition.Left, 0) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" };
            PlotModel.Axes.Add(valueAxis);

        }
        private void SetupChartModel()
        {
            _plotModel = new PlotModel
            {
                LegendTitle       = "Legend",
                LegendOrientation = LegendOrientation.Horizontal,
                LegendPlacement   = LegendPlacement.Outside,
                LegendPosition    = LegendPosition.TopRight,
                LegendBackground  = OxyColor.FromAColor(200, OxyColors.White),
                LegendBorder      = OxyColors.Black
            };

            var stockDateTimeAxis = new DateTimeAxis
            {
                Position           = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                Title        = "Date",
                StringFormat = "HH:mm:ss"
            };

            _plotModel.Axes.Add(stockDateTimeAxis);

            var stockPriceAxis = new LinearAxis
            {
                Minimum            = 0,
                Maximum            = 100,
                IsZoomEnabled      = false,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                Title = "% CPU"
            };

            _plotModel.Axes.Add(stockPriceAxis);

            var newLineSeries = new LineSeries()
            {
                StrokeThickness             = 2,
                MarkerSize                  = 3,
                MarkerStroke                = OxyColors.Black,
                MarkerType                  = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                Title  = "CPU",
                Smooth = false
            };

            _plotModel.Series.Add(newLineSeries);
        }
        private void LoadDistributorValueSeries()
        {
            var distributorSeries = new LineSeries
            {
                Title               = "Verteiler",
                Color               = OxyColors.DarkOrange,
                StrokeThickness     = 3,
                TrackerFormatString = "{0} " + Environment.NewLine + "{1}: {2:dd.MM.yy} " + Environment.NewLine + "{3}: {4} "
            };

            foreach (var reading in SelectedDistributor.Readings.OrderBy(r => r.ReadingDate))
            {
                distributorSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(reading.ReadingDate), reading.CounterReading));
            }
            m_DistributorPlot.Series.Add((distributorSeries));
        }
Esempio n. 12
0
        private LineSeries OneYearOfUsd(int year)
        {
            var result = new LineSeries()
            {
                Title = year.ToString()
            };

            foreach (var nbRbRateOnScreen in _rates.Where(r => r.Date.Year == year))
            {
                var rate = nbRbRateOnScreen.Date < new DateTime(2016, 7, 1)
                    ? nbRbRateOnScreen.TodayRates.NbRates.Usd.Value / 10000
                    : nbRbRateOnScreen.TodayRates.NbRates.Usd.Value;
                result.Points.Add(new DataPoint(DateTimeAxis.ToDouble(nbRbRateOnScreen.Date), rate));
            }
            return(result);
        }
Esempio n. 13
0
 private void GetLinesOfBasket(out LineSeries basket, out ColumnSeries basketDelta)
 {
     basket = new LineSeries()
     {
         Title = "Basket", TextColor = OxyColors.Orange
     };
     basketDelta = new ColumnSeries()
     {
         Title = "DeltaP", FillColor = OxyColors.Red, NegativeFillColor = OxyColors.Green
     };
     foreach (var nbRbRateOnScreen in _rates.Where(r => r.Date >= _startDate))
     {
         basket.Points.Add(new DataPoint(DateTimeAxis.ToDouble(nbRbRateOnScreen.Date), nbRbRateOnScreen.Basket));
         basketDelta.Items.Add(new ColumnItem(nbRbRateOnScreen.ProcBasketDelta));
     }
 }
Esempio n. 14
0
        /// <summary>
        /// sets axes to be those saved in the cache.
        /// </summary>
        public void OriginalDimensions()
        {
            if (xAxis1ZoomCache_ != null)
            {
                this.XAxis1 = xAxis1ZoomCache_;
                this.XAxis2 = xAxis2ZoomCache_;
                this.YAxis1 = yAxis1ZoomCache_;
                this.YAxis2 = yAxis2ZoomCache_;

                xAxis1ZoomCache_ = null;
                xAxis2ZoomCache_ = null;
                yAxis1ZoomCache_ = null;
                yAxis2ZoomCache_ = null;
            }
            this.Refresh();
        }
Esempio n. 15
0
 private void RecordValue(Channel channel, double value, DateTime time)
 {
     if (channelSeriesMap.ContainsKey(channel))
     {
         var seriesList = channelSeriesMap[channel];
         seriesList.ForEach(series =>
         {
             if (series.Points.Count >= NumPoints)
             {
                 series.Points.RemoveAt(0);
             }
             series.Points.Add(DateTimeAxis.CreateDataPoint(time, value));
             series.PlotModel?.InvalidatePlot(true);
         });
     }
 }
Esempio n. 16
0
        public StartingPageModel()
        {
            IsLoading       = true;
            IsScreenVisable = false;
            GetProfileInformationAndRefreshToken();
            Plans = new ObservableCollection <Plan>();
            User  = new Account();

            CreateActivitesCollection();

            Model = new PlotModel();
            XAXIS = new DateTimeAxis();
            YAXIS = new LinearAxis();

            DrawPlot();
        }
Esempio n. 17
0
        public static LineSeries LineSeries(string seriesTitle, DateTime[] x, double[] y, System.Drawing.Color markerColor, MarkerType mType)
        {
            var lineSeries = new LineSeries();

            lineSeries.Title = seriesTitle;
            for (int i = 0; i < x.Length; i++)
            {
                var b = DateTimeAxis.CreateDataPoint(x[i], y[i]);

                lineSeries.Points.Add(b);
            }
            lineSeries.Color = OxyColor.FromRgb(markerColor.R, markerColor.G, markerColor.B);
            //lineSeries.MarkerFill =
            lineSeries.MarkerType = mType;
            return(lineSeries);
        }
Esempio n. 18
0
        public void UpdateModel()
        {
            List <Measurement> measurements = Data.GetUpdateData(lastUpdate);
            var dataPerDetector             = measurements.GroupBy(m => m.DetectorId).OrderBy(m => m.Key).ToList();

            foreach (var data in dataPerDetector)
            {
                var lineSerie = PlotModelMain.Series[data.Key] as LineSeries;
                if (lineSerie != null)
                {
                    data.ToList()
                    .ForEach(d => lineSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(d.DateTime), d.Value)));
                }
            }
            lastUpdate = DateTime.Now;
        }
        private void UpdateLineSeries(float value, DateTime date)
        {
            var series = _plotModel.Series[0] as LineSeries;

            var newDataPoint = new DataPoint(DateTimeAxis.ToDouble(date),
                                             LinearAxis.ToDouble(value));

            //show only last 20 datapoints
            if (series.Points.Count > 20)
            {
                series.Points.RemoveAt(0);
            }

            series.Points.Add(newDataPoint);
            _plotModel.InvalidatePlot(true);
        }
        /// <summary>
        /// Called when a new stock price is received.
        /// </summary>
        /// <param name="message"></param>
        private void HandleNewStockPrice(StockPriceMessage message)
        {
            if (!this._series.ContainsKey(message.StockSymbol))
            {
                return;
            }
            var series = this._series[message.StockSymbol];

            // Show at most 10 points
            if (series.Points.Count > 10)
            {
                series.Points.RemoveAt(0);
            }
            series.Points.Add(new DataPoint(DateTimeAxis.ToDouble(message.Date), Axis.ToDouble(message.Price)));
            this.RefreshChart();
        }
Esempio n. 21
0
        private void PlotOffRep(PlotModel m)
        {
            if (OffReputations == null)
            {
                return;
            }

            //miasta
            LinearAxis yAxis = new LinearAxis();

            yAxis.Title              = Labels.OffReputation;
            yAxis.Key                = "off_rep";
            yAxis.Position           = AxisPosition.Right;
            yAxis.MajorGridlineStyle = LineStyle.None;
            yAxis.MinorGridlineStyle = LineStyle.None;
            m.Axes.Add(yAxis);

            foreach (var empire in OffReputations.OrderBy(x => x.Key.OffReputation))
            {
                var s = new OxyPlot.Series.StairStepSeries();
                s.XAxisKey  = "x";
                s.YAxisKey  = "off_rep";
                s.LineStyle = LineStyle.Dash;
                //s.VerticalStrokeThickness = 0.2;

                s.MarkerType = MarkerType.Diamond;
                s.Title      = string.Format("A: {0} ({1})", empire.Key.PlayerName, empire.Key.AlianceName);

                DateTime?lastTime  = null;
                long     lastScore = 0;

                foreach (var hr in empire.Value.OrderBy(x => x.CreateDT.Value))
                {
                    s.Points.Add(DateTimeAxis.CreateDataPoint(hr.CreateDT.Value, hr.Score));
                    lastScore = hr.Score;
                    lastTime  = hr.CreateDT;
                }

                //sztucznie dodaję pomiar, żeb widać było poziomą kreskę
                if (lastTime.HasValue)
                {
                    s.Points.Add(DateTimeAxis.CreateDataPoint(lastTime.Value.AddHours(1), lastScore));
                }

                m.Series.Add(s);
            }
        }
        private void InitializePlot()
        {
            var textForegroundColor      = (Color)Application.Current.Resources["TextForegroundColor"];
            var lightControlColor        = (Color)Application.Current.Resources["LightControlColor"];
            var workspaceBackgroundColor = (Color)Application.Current.Resources["WorkspaceBackgroundColor"];

            m_Plot = new PlotModel
            {
                PlotAreaBorderColor = OxyColor.Parse(textForegroundColor.ToString()),
                LegendTitle         = TranslationProvider.Translate(Assembly.GetExecutingAssembly(), "Reading"),
                LegendOrientation   = LegendOrientation.Horizontal,
                LegendPlacement     = LegendPlacement.Outside,
                LegendPosition      = LegendPosition.TopRight,
                LegendBackground    = OxyColor.Parse(workspaceBackgroundColor.ToString()),
                LegendBorder        = OxyColor.Parse(textForegroundColor.ToString()),
                TextColor           = OxyColor.Parse(textForegroundColor.ToString())
            };

            var dateAxis = new DateTimeAxis(AxisPosition.Bottom, TranslationProvider.Translate("ReadingAt"), TranslationProvider.Translate("DateFormat"))
            {
                MajorGridlineColor = OxyColor.Parse(lightControlColor.ToString()),
                TicklineColor      = OxyColor.Parse(lightControlColor.ToString()),
                TitleColor         = OxyColor.Parse(textForegroundColor.ToString()),
                TextColor          = OxyColor.Parse(textForegroundColor.ToString()),
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                IntervalLength     = 80,
                IsZoomEnabled      = false,
                IsPanEnabled       = false
            };

            m_Plot.Axes.Add(dateAxis);

            var valueAxis = new LinearAxis(AxisPosition.Left, 0)
            {
                MajorGridlineColor = OxyColor.Parse(lightControlColor.ToString()),
                TicklineColor      = OxyColor.Parse(lightControlColor.ToString()),
                TextColor          = OxyColor.Parse(textForegroundColor.ToString()),
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                Title         = TranslationProvider.Translate("ValueOfReading"),
                IsZoomEnabled = false,
                IsPanEnabled  = false
            };

            m_Plot.Axes.Add(valueAxis);
        }
Esempio n. 23
0
        private LineSeries GenPointsXFVelocity(int period)
        {
            OxyPlot.Series.LineSeries series = new LineSeries();

            List <int>          periods = XF.Periods;
            List <double>       list    = XF.PeriodVelocityData[period];
            List <HistoryPrice> quotes  = XF.Quotes;

            for (int i = 0; i < list.Count(); i++)
            {
                series.Points.Add(new DataPoint(DateTimeAxis.ToDouble(quotes[i].Date), list[i]));
            }

            series.Color = OxyColors.Green;

            return(series);
        }
Esempio n. 24
0
 private void TimerEmul_Elapsed(object sender, ElapsedEventArgs e)
 {
     this.Dispatcher.Invoke(new System.Threading.ThreadStart(delegate {
         int sample = Convert.ToInt32(cbSample.SelectionBoxItem);
         for (int i = 0; i < selectedParam.Count; i++)
         {
             ((LineSeries)plotter.Model.Series[i]).Points.Add(new DataPoint(DateTimeAxis.ToDouble(selectedParam[i].Points[index].X), selectedParam[i].Points[index].Y));
         }
         plotter.InvalidatePlot(true);
         index += sample;
         if (index >= selectedParam[0].Points.Count)
         {
             timerEmul.Stop();
             index = 0;
         }
     }));
 }
        private void InitializeTrendDistributorPlot()
        {
            m_DistributorPlot = new PlotModel
            {
                LegendTitle = "Legende",
            };

            m_DistributorPlot.Axes.Clear();
            m_DistributorPlot.Series.Clear();

            var textForegroundColor = (Color)Application.Current.Resources["BlackColor"];
            var lightControlColor   = (Color)Application.Current.Resources["WhiteColor"];

            m_DistributorPlot.Title                   = "Gesamtverbrauch Verteiler";
            m_DistributorPlot.LegendOrientation       = LegendOrientation.Horizontal;
            m_DistributorPlot.LegendPlacement         = LegendPlacement.Outside;
            m_DistributorPlot.LegendPosition          = LegendPosition.BottomLeft;
            m_DistributorPlot.TextColor               = OxyColor.Parse(textForegroundColor.ToString());
            m_DistributorPlot.PlotAreaBorderColor     = OxyColor.Parse(textForegroundColor.ToString());
            m_DistributorPlot.PlotAreaBorderThickness = new OxyThickness(1);

            var dateAxis = new DateTimeAxis()
            {
                IsPanEnabled  = false,
                IsZoomEnabled = false,
                Title         = "Datum",
                StringFormat  = "dd-MM-yyyy",
            };

            m_DistributorPlot.Axes.Add(dateAxis);

            var valueAxis = new LinearAxis(AxisPosition.Left, 0)
            {
                ShowMinorTicks     = true,
                MinorGridlineStyle = LineStyle.Dot,
                MajorGridlineStyle = LineStyle.Dot,
                MajorGridlineColor = OxyColor.Parse(lightControlColor.ToString()),
                MinorGridlineColor = OxyColor.Parse(lightControlColor.ToString()),
                TicklineColor      = OxyColor.Parse(textForegroundColor.ToString()),
                Title         = "kWh pro Jahr",
                IsZoomEnabled = false,
                IsPanEnabled  = false
            };

            m_DistributorPlot.Axes.Add(valueAxis);
        }
Esempio n. 26
0
        public override IValueConverter TryBuildConverter(Type dataType, IValueConversionContext context)
        {
            var plotter = context.Plotter;

            if (dataType == typeof(DateTime))
            {
                foreach (var child in plotter.Children)
                {
                    DateTimeAxis axis = child as DateTimeAxis;
                    if (axis != null)
                    {
                        return(new DateTimeValueConverter(axis));
                    }
                }
            }
            return(null);
        }
Esempio n. 27
0
        public static PlotModel DateTimeaxisPlotModel()
        {
            var    start     = new DateTime(2010, 01, 01);
            var    end       = new DateTime(2015, 01, 01);
            double increment = 3600 * 24 * 14;

            // Create a random data collection
            var r    = new Random();
            var data = new Collection <DateValue>();
            var date = start;

            while (date <= end)
            {
                data.Add(new DateValue {
                    Date = date, Value = r.NextDouble()
                });
                date = date.AddSeconds(increment);
            }

            var plotModel1    = new PlotModel("DateTime axis");
            var dateTimeAxis1 = new DateTimeAxis
            {
                CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
                FirstDayOfWeek   = DayOfWeek.Monday,
                Position         = AxisPosition.Bottom
            };

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

            plotModel1.Axes.Add(linearAxis1);
            var lineSeries1 = new LineSeries
            {
                Color           = OxyColor.FromArgb(255, 78, 154, 6),
                MarkerFill      = OxyColor.FromArgb(255, 78, 154, 6),
                MarkerStroke    = OxyColors.ForestGreen,
                MarkerType      = MarkerType.Plus,
                StrokeThickness = 1,
                DataFieldX      = "Date",
                DataFieldY      = "Value",
                ItemsSource     = data
            };

            plotModel1.Series.Add(lineSeries1);
            return(plotModel1);
        }
        /// <summary>
        /// Create a ISeriesHost with a DateTime Axis and a TimeSpan so it can pick the appropriate interval.
        /// </summary>
        /// <param name="timeSpan">Time span for the data.</param>
        /// <returns>ISeriesHost for testing.</returns>
        private static Chart CreateDateTimeAxisWithIntervalChart(TimeSpan timeSpan)
        {
            Chart        chart        = new Chart();
            DateTimeAxis dateTimeAxis = new DateTimeAxis();

            dateTimeAxis.Orientation = AxisOrientation.X;
            chart.Axes.Add(dateTimeAxis);
            DataPointSeries series = new LineSeries();

            series.DependentValueBinding   = new Binding("Day");
            series.IndependentValueBinding = new Binding();
            DateTime start = new DateTime(2008, 1, 1);

            series.ItemsSource = new DateTime[] { start, start + timeSpan };
            chart.Series.Add(series);
            return(chart);
        }
Esempio n. 29
0
 private void Param_OnChangeValue(DataParam dataParam)
 {
     this.Dispatcher.Invoke(new ThreadStart(delegate {
         foreach (LineSeries line in plotter.Model.Series)
         {
             if (line.Title == dataParam.Title)
             {
                 if (line.Points.Count > CountDot)
                 {
                     line.Points.RemoveAt(0);
                 }
                 line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now), dataParam.Value));
                 plotter.InvalidatePlot(true);
             }
         }
     }));
 }
Esempio n. 30
0
        public static Example SmallDataSet()
        {
            var pm = new PlotModel {
                Title = "Small Data Set"
            };

            var timeSpanAxis1 = new DateTimeAxis {
                Position = AxisPosition.Bottom
            };

            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis {
                Position = AxisPosition.Left
            };

            pm.Axes.Add(linearAxis1);
            var series = new CandleStickSeries
            {
                Color               = OxyColors.Black,
                IncreasingColor     = OxyColors.DarkGreen,
                DecreasingColor     = OxyColors.Red,
                DataFieldX          = "Time",
                DataFieldHigh       = "H",
                DataFieldLow        = "L",
                DataFieldOpen       = "O",
                DataFieldClose      = "C",
                TrackerFormatString = "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
            };

            var n = 100;

            foreach (var bar in HighLowItemGenerator.MRProcess(n))
            {
                series.Append(bar);
            }

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(pm, controller));
        }
Esempio n. 31
0
        /// <summary>
        /// Timer-Tick Event-Handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void timer_Tick(object sender, EventArgs e)
        {
            var areaSeries = (LineSeries)this.RAMPlot.Series[0];

            if (areaSeries.Points.Count > 60)
            {
                areaSeries.Points.RemoveAt(0);
            }

            // Update-Plot
            this.GetMemoryInformaton();

            areaSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(this.time), this.UsedPhysicalMemoryInPercent));
            time = time.AddSeconds(1);

            this.RAMPlot.InvalidatePlot(true);
        }
        public async Task <List <DataPoint> > FetchData(DateTime startTime, DateTime endTime)
        {
            List <DataPoint>        dataPoints  = new List <DataPoint>();
            List <ScadaPointResult> dataResults = FetchHistoricalPointData(startTime, endTime);

            if (dataResults != null)
            {
                for (int resIter = 0; resIter < dataResults.Count; resIter++)
                {
                    DateTime dataTime = dataResults[resIter].ResultTime_;

                    DataPoint dataPoint = new DataPoint(DateTimeAxis.ToDouble(dataTime), dataResults[resIter].Val_);
                    dataPoints.Add(dataPoint);
                }
            }
            return(dataPoints);
        }
Esempio n. 33
0
        private void UpdatePaymentPlot(DayIncomeManager dayIncomeManager, IEnumerable <PaymentObject> payments)
        {
            var points = new List <ScatterPoint>();

            foreach (var payment in payments)
            {
                var Date           = UnixTimeHelper.UnixTimeToDateTime(payment.time);
                var dayIncomeValue = dayIncomeManager.GetRow((long)UnixTimeHelper.Convert(Date)).value;
                if (dayIncomeValue > 0)
                {
                    var sp = new ScatterPoint(DateTimeAxis.ToDouble(Date), dayIncomeValue);
                    points.Add(sp);
                }
            }

            BasePlot.LoadPayment(points.ToArray());
        }
Esempio n. 34
0
 public void SetLinearDataAxis(PlotModel PlotModel)
 {
     var dateAxis = new DateTimeAxis(AxisPosition.Bottom, "Дата", "yyyy-MM-dd HH:mm:ss")
     {
         MajorGridlineStyle = LineStyle.Solid,
         MinorGridlineStyle = LineStyle.Dot,
         IntervalLength = 150
     };
     PlotModel.Axes.Add(dateAxis);
     var valueAxis = new LinearAxis(AxisPosition.Left, -0.05)
     {
         MajorGridlineStyle = LineStyle.Solid,
         MinorGridlineStyle = LineStyle.Dot,
         Title = "Значение"
     };
     PlotModel.Axes.Add(valueAxis);
 }
Esempio n. 35
0
        private PlotModel HeartRateCreatePlotModel()
        {
            HeartRateStreamViewModel heartRateStream = new HeartRateStreamViewModel();
            var plotModel = new PlotModel();

            plotModel.Axes.Add(new LinearAxis
            {
                Position       = AxisPosition.Left,
                Title          = "BPM",
                MaximumPadding = 0.05
            });

            var dateTimeAxis = new DateTimeAxis()
            {
                Position       = AxisPosition.Bottom,
                Title          = "Date",
                StringFormat   = DATE_FORMAT,
                MinimumPadding = 0.05,
                MaximumPadding = 0.05
            };

            plotModel.Axes.Add(dateTimeAxis);

            var series = new ScatterSeries()
            {
                MarkerType   = MarkerType.Circle,
                MarkerSize   = 4,
                MarkerStroke = OxyColor.FromRgb(0, 0, 139),    // darkblue
                MarkerFill   = OxyColor.FromRgb(255, 165, 0),  // orange
                Background   = OxyColor.FromRgb(33, 150, 243), // blue
            };

            List <Entry> entries = heartRateStream.GetEntries();

            if (entries != null)
            {
                foreach (var entry in entries)
                {
                    series.Points.Add(new ScatterPoint(DateTimeAxis.ToDouble(entry.date), entry.value));
                }
            }

            plotModel.Series.Add(series);

            return(plotModel);
        }
        public void SetUpModel()
        {
            plotModel.Series.Clear();
            var series = new LineSeries {
                Title = CurrentSensor, MarkerType = MarkerType.Circle
            };
            var metrics = Metrics.Where(m => m.SId == CurrentSensor).ToList();

            metrics.Sort();
            foreach (var item in metrics)
            {
                series.Points.Add(new DataPoint(DateTimeAxis.ToDouble(item.Session), item.Svalue));
            }
            plotModel.Title = currentSensor;
            plotModel.Series.Add(series);
            plotModel.InvalidatePlot(true);
        }
        private void ChartXDurationSetAction(object obj)
        {
            //TODO - done
            //bool saveChartFlow = ChartFlow;
            //ChartFlow = false;
            //OnPropertyChanged("ChartFlow");

            double max = plot.Axes[0].ActualMaximum;

            plot.Axes[0].Reset();
            plot.Axes[0].PositionAtZeroCrossing = false;
            //plot.Axes[0].Maximum = plot.Axes[0].DataMaximum;
            plot.Axes[0].Maximum = max;
            plot.Axes[0].Minimum = DateTimeAxis.ToDouble(DateTimeAxis.ToDateTime(max).AddSeconds(-(ChartXDurationValue)));
            //Console.WriteLine("Powinno ustawic na " + DateTimeAxis.ToDateTime(plot.Axes[0].Minimum) + " " + DateTimeAxis.ToDateTime(plot.Axes[0].Maximum));
            Plot.InvalidatePlot(true);
        }
Esempio n. 38
0
        public ViewResolvingPlotModel InitializeDefault(IEnumerable <MultiRoomInfo> collection, int code)
        {
            ViewResolvingPlotModel result      = ViewResolvingPlotModel.CreateDefault();
            var humidityLineSerie              = result.GetLast();
            var temperatureLineSerie           = result.GetFirst();
            List <DataPoint> humidityPoints    = new List <DataPoint>();
            List <DataPoint> temperaturePoints = new List <DataPoint>();

            switch (code)
            {
            case 1:
                humidityPoints    = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.Humidity)).ToList();
                temperaturePoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.Temperature)).ToList();
                break;

            case 2:
                humidityPoints    = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.HumidityMiddle)).ToList();
                temperaturePoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.TemperatureMiddle)).ToList();
                break;

            case 3:
                humidityPoints    = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.HumidityProcess)).ToList();
                temperaturePoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.TemperatureNord)).ToList();
                break;

            case 4:
                humidityPoints    = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.HumidityProcess)).ToList();
                temperaturePoints = collection.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.Date), x.TemperatureProcess)).ToList();
                break;

            default:
                break;
            }


            result.FillCollection(temperatureLineSerie, temperaturePoints);
            result.FillCollection(humidityLineSerie, humidityPoints);

            result.SetLastNHours(6);
            result.AddAnnotationEveryDay();

            //		GraphInfo.GraphLineModelForDefault.InvalidatePlot(true);

            return(result);
        }
Esempio n. 39
0
		private async void GetData()
		{
			var yAxis = new DateTimeAxis();
			byte c = 0;
			foreach (var address in AddressList)
			{
				var i = address.IndexOf('.');
				var deviceAdress = address.Substring(0, i);
				var objectAdress = address.Substring(i + 1, address.Length - i - 1);

				string requestUrl = string.Format("{0}/{1}/{2}/history",
					HistoryUri,
					deviceAdress,
					objectAdress
					);

				var a = await _dataTransport.GetRequestAsync<Dictionary<DateTime, string>>(requestUrl, true, 30000);

				if (a == null || a.Count == 0)
					continue;

				var model = new GraphModel
				{
					Address = address,
					Color = _graphColours[c%_graphColours.Count()],
					Name = UnitsList[c],
					Times = a.Keys.ToList(),
					Values = a.Values.Select(val => double.Parse(val.Replace('.', ','))).ToList()
				};

				var xDs = new EnumerableDataSource<DateTime>(model.Times);
				var yDs = new EnumerableDataSource<double>(model.Values);

				model.MinValue = model.Values.Min() - 1;
				model.MaxValue = model.Values.Max() + 1;

				//set the mappings
				xDs.SetXMapping(x => yAxis.ConvertToDouble(x));
				yDs.SetYMapping(y => y);

				model.PointDataSource = new CompositeDataSource(xDs, yDs);
				Graphs.Add(model);
				c++;
			}
		}
        public void AddAnnotationEveryDay()
        {
            var points = GetFirst().Points;

            if (points.Count == 0)
            {
                points = GetLast().Points;
                if (points.Count == 0)
                {
                    return;
                }
            }
            var lastPoint  = points.Where(x => !x.Equals(DataPoint.Undefined)).Max(x => x.X);
            var firstPoint = points.Where(x => !x.Equals(DataPoint.Undefined)).Min(x => x.X);

            var beginingDate = DateTimeAxis.ToDateTime(firstPoint);

            var lastDate = DateTimeAxis.ToDateTime(lastPoint);


            double Y     = 70;
            var    date  = new DateTime(beginingDate.Date.Year, beginingDate.Date.Month, beginingDate.Date.Day);
            var    date2 = new DateTime(lastDate.Date.Year, lastDate.Date.Month, lastDate.Date.Day);
            var    days  = (int)(date2 - date).TotalDays;

            double X = DateTimeAxis.ToDouble(date);

            for (int i = 0; i <= days + 1; i++)
            {
                LineAnnotation Line = new LineAnnotation()
                {
                    Tag             = "period",
                    StrokeThickness = 2,
                    Color           = OxyColors.Green,
                    Type            = LineAnnotationType.Vertical,
                    Text            = Y.ToString(),
                    TextColor       = OxyColors.White,
                    X         = X,
                    LineStyle = LineStyle.Dash,
                };
                Annotations.Add(Line);
                date = date.AddDays(1);
                X    = DateTimeAxis.ToDouble(date);
            }
        }
Esempio n. 41
0
        /// <summary>
        /// Sets up the plot model to be displayed.
        /// </summary>
        /// <returns>The plot model.</returns>
        protected override PlotModel SetupPlot()
        {
            // Create the plot model
            var newPlot = new PlotModel {
                Title = "% Books In Translation"
            };

            OxyPlotUtilities.SetupPlotLegend(newPlot, "% Books In Translation");
            SetupBooksInTranslationVsTimeAxes(newPlot);

            // create series and add them to the plot
            LineSeries overallSeries;
            LineSeries lastTenSeries;
            LineSeries overallTrendlineSeries;

            OxyPlotUtilities.CreateLineSeries(out overallSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksInTranslationKey, "Overall", 1);
            OxyPlotUtilities.CreateLineSeries(out lastTenSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksInTranslationKey, "Last 10", 0);
            OxyPlotUtilities.CreateLineSeries(out overallTrendlineSeries, ChartAxisKeys.DateKey, ChartAxisKeys.BooksInTranslationKey, "Overall Trendline", 4);
            double yintercept;
            double slope;

            GetBooksInTranslationLinearTrendlineParameters(out yintercept, out slope);


            foreach (var delta in BooksReadProvider.BookDeltas)
            {
                double trendDaysPerBook = yintercept + (slope * delta.DaysSinceStart);

                overallSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.OverallTally.PercentageInTranslation));
                lastTenSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), delta.LastTenTally.PercentageInTranslation));
                overallTrendlineSeries.Points.Add(
                    new DataPoint(DateTimeAxis.ToDouble(delta.Date), trendDaysPerBook));
            }


            OxyPlotUtilities.AddLineSeriesToModel(newPlot,
                                                  new[] { overallSeries, lastTenSeries, overallTrendlineSeries }
                                                  );


            // finally update the model with the new plot
            return(newPlot);
        }
Esempio n. 42
0
 static void AddAxis(PlotModel IncomePlot,
     ObservableCollection<Transaction> transactions)
 {
     var dateAxis = new DateTimeAxis
     {
         MajorGridlineStyle = LineStyle.Solid,
         MinorGridlineStyle = LineStyle.Dot,
         Angle = -45
     };
     IncomePlot.Axes.Add(dateAxis);
     var valueAxis = new LinearAxis
     {
         MajorGridlineStyle = LineStyle.Solid,
         MinorGridlineStyle = LineStyle.Dot,
         Title = "Amount"
     };
     IncomePlot.Axes.Add(valueAxis);
 }
Esempio n. 43
0
        public static PlotModel DateTimeaxisPlotModel()
        {
            var start = new DateTime(2010, 01, 01);
            var end = new DateTime(2015, 01, 01);
            double increment = 3600 * 24 * 14;

            // Create a random data collection
            var r = new Random(13);
            var data = new Collection<DateValue>();
            var date = start;
            while (date <= end)
            {
                data.Add(new DateValue { Date = date, Value = r.NextDouble() });
                date = date.AddSeconds(increment);
            }

            var plotModel1 = new PlotModel { Title = "DateTime axis" };
            var dateTimeAxis1 = new DateTimeAxis
            {
                CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
                FirstDayOfWeek = DayOfWeek.Monday,
                Position = AxisPosition.Bottom
            };
            plotModel1.Axes.Add(dateTimeAxis1);
            var linearAxis1 = new LinearAxis();
            plotModel1.Axes.Add(linearAxis1);
            var lineSeries1 = new LineSeries
            {
                Color = OxyColor.FromArgb(255, 78, 154, 6),
                MarkerFill = OxyColor.FromArgb(255, 78, 154, 6),
                MarkerStroke = OxyColors.ForestGreen,
                MarkerType = MarkerType.Plus,
                StrokeThickness = 1,
                DataFieldX = "Date",
                DataFieldY = "Value",
                ItemsSource = data
            };
            plotModel1.Series.Add(lineSeries1);
            return plotModel1;
        }
Esempio n. 44
0
        public static PlotModel DateTimeAxisWithIntervalTypeMinutes()
        {
            var plotModel1 = new PlotModel();
            var linearAxis1 = new LinearAxis();
            linearAxis1.MinorGridlineStyle = LineStyle.Dot;
            plotModel1.Axes.Add(linearAxis1);

            var dateTimeAxis1 = new DateTimeAxis();
            dateTimeAxis1.IntervalType = DateTimeIntervalType.Minutes;
            // dateTimeAxis1.MajorStep = 1.0 / 24 / 60;
            dateTimeAxis1.EndPosition = 0;
            dateTimeAxis1.StartPosition = 1;
            dateTimeAxis1.StringFormat = "hh:mm:ss";
            plotModel1.Axes.Add(dateTimeAxis1);
            var time0 = new DateTime(2013, 5, 6, 3, 24, 0);
            var time1 = new DateTime(2013, 5, 6, 3, 28, 0);
            //dateTimeAxis1.Minimum = DateTimeAxis.ToDouble(time0);
            //dateTimeAxis1.Maximum = DateTimeAxis.ToDouble(time1);
            var lineSeries1 = new LineSeries();
            lineSeries1.Points.Add(new DataPoint(DateTimeAxis.ToDouble(time0), 36));
            lineSeries1.Points.Add(new DataPoint(DateTimeAxis.ToDouble(time1), 26));
            plotModel1.Series.Add(lineSeries1);
            return plotModel1;
        }
        /// <summary>
        /// Adjusts the Y extent.
        /// </summary>
        /// <param name="series">Series.</param>
        /// <param name="xaxis">Xaxis.</param>
        /// <param name="yaxis">Yaxis.</param>
        private static void AdjustYExtent(CandleStickSeries series, DateTimeAxis xaxis, LinearAxis yaxis)
        {
            var xmin = xaxis.ActualMinimum;
            var xmax = xaxis.ActualMaximum;

            var istart = series.FindByX(xmin);
            var iend = series.FindByX(xmax, istart);

            var ymin = double.MaxValue;
            var ymax = double.MinValue;
            for (int i = istart; i <= iend; i++)
            {
                var bar = series.Items[i];
                ymin = Math.Min(ymin, bar.Low);
                ymax = Math.Max(ymax, bar.High);
            }

            var extent = ymax - ymin;
            var margin = extent * 0.10;

            yaxis.Zoom(ymin - margin, ymax + margin);
        }
Esempio n. 46
0
        private void btnPointSeries_Click(object sender, EventArgs e)
        {
            plotView1.Focus();

            var dateAxis = new DateTimeAxis(AxisPosition.Bottom, "Date", "dd/MM/yyyy") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, IntervalLength = 80 };
            var valueAxis = new LinearAxis(AxisPosition.Left, 0) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Value" };

            var plotModel = new PlotModel { Title = "BarSeries" };
            plotModel.LegendTitle = "Legend";
            plotModel.LegendOrientation = LegendOrientation.Horizontal;
            plotModel.LegendPlacement = LegendPlacement.Outside;
            plotModel.LegendPosition = LegendPosition.TopRight;
            plotModel.LegendBackground = OxyColor.FromAColor(200, OxyColors.White);
            plotModel.LegendBorder = OxyColors.Black;
            plotModel.Axes.Add(dateAxis);
            plotModel.Axes.Add(valueAxis);

            plotView1.Model = plotModel;
            configurarPlotModel(plotModel);
        }
Esempio n. 47
0
        public static PlotModel DataPointsRemainVisibleOutsideBoundsOnPanning()
        {
            var plotModel1 = new PlotModel();

            var masterAxis = new DateTimeAxis { Key = "MasterDateTimeAxis", Position = AxisPosition.Bottom };
            plotModel1.Axes.Add(masterAxis);

            var verticalAxis = new LinearAxis
            {
                Position = AxisPosition.Left,
                Title = "Measurement",
                Key = "Measurement",
                AbsoluteMinimum = -100,
                Minimum = -100,
                AbsoluteMaximum = 100,
                Maximum = 100,
                IsZoomEnabled = false,
                IsPanEnabled = false
            };

            plotModel1.Axes.Add(verticalAxis);

            var line = new LineSeries { Title = "Measurement", XAxisKey = masterAxis.Key, YAxisKey = verticalAxis.Key };
            line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now), 10));
            line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now.AddSeconds(1)), 10));
            line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now.AddSeconds(2)), 45));
            line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now.AddSeconds(3)), 17));

            line.Points.Add(DataPoint.Undefined);

            // this point should be visible
            line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now.AddSeconds(4)), 10));
            //// line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now.AddSeconds(4)), 10));

            line.Points.Add(DataPoint.Undefined);

            line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now.AddSeconds(5)), 45));
            line.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now.AddSeconds(6)), 17));

            plotModel1.Series.Add(line);

            return plotModel1;
        }
Esempio n. 48
0
        public static PlotModel DateTimeAxisWithIntervalTypeMinutes()
        {
            var plotModel1 = new PlotModel();
            var linearAxis1 = new LinearAxis();
            plotModel1.Axes.Add(linearAxis1);

            var dateTimeAxis1 = new DateTimeAxis
                                    {
                                        IntervalType = DateTimeIntervalType.Minutes,
                                        EndPosition = 0,
                                        StartPosition = 1,
                                        StringFormat = "hh:mm:ss"
                                    };
            plotModel1.Axes.Add(dateTimeAxis1);
            var time0 = new DateTime(2013, 5, 6, 3, 24, 0);
            var time1 = new DateTime(2013, 5, 6, 3, 28, 0);
            var lineSeries1 = new LineSeries();
            lineSeries1.Points.Add(new DataPoint(DateTimeAxis.ToDouble(time0), 36));
            lineSeries1.Points.Add(new DataPoint(DateTimeAxis.ToDouble(time1), 26));
            plotModel1.Series.Add(lineSeries1);
            return plotModel1;
        }
Esempio n. 49
0
 public void DateTimeAxis()
 {
     var s1 = new OxyPlot.Axes.DateTimeAxis();
     var s2 = new DateTimeAxis();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
Esempio n. 50
0
 /// <summary>
 /// Plota um eixo de Data e hora.
 /// </summary>
 /// <param name="titulo"> Título do eixo considerado. </param>
 private void plotEixoData(string titulo = "Data e Hora")
 {
     //Criando um eixo de Data.
     DateTimeAxis eixoData = new DateTimeAxis();
     eixoData.MajorGridlineStyle = LineStyle.Solid;
     eixoData.MinorGridlineStyle = LineStyle.Dot;
     eixoData.MinimumPadding = 0.1;
     eixoData.MaximumPadding = 0.1;
     eixoData.FirstDayOfWeek = System.DayOfWeek.Sunday;
     eixoData.Title = titulo;
     myModel.Axes.Add(eixoData);
 }
Esempio n. 51
0
        private PlotModel InitModel()
        {
            if (Data == null) return new PlotModel();
            Data.Grouping = GroupingOptions.hourly;
            var plotModel = new PlotModel {PlotAreaBorderThickness = 0, Background = null, PlotMargins = new OxyThickness(0, 0, 0, 0), Title = Data.Title};
            var dateAxis = new DateTimeAxis {Minimum = DateTimeAxis.ToDouble(AppState.TimelineManager.Start), Maximum = DateTimeAxis.ToDouble(AppState.TimelineManager.End), IsAxisVisible = true, Position = AxisPosition.Bottom};
            plotModel.Axes.Add(dateAxis);
            var linearAxis2 = new LinearAxis {IsAxisVisible = true};

            var maxvalue = (Data.Data.Values.Any()) ? Data.Data.Values.Max() :  10.0;
            linearAxis2.Maximum = maxvalue;
            //linearAxis2.Maximum = 5;
            linearAxis2.Minimum = 0;
            linearAxis2.MinorStep = 1;
            plotModel.Axes.Add(linearAxis2);

            CreateBarSeries(linearAxis2, plotModel);

            return plotModel;
        }
 public static PlotModel BoxPlotSeries_DateTimeAxis()
 {
     var m = new PlotModel();
     var x0 = DateTimeAxis.ToDouble(new DateTime(2013, 05, 04));
     var a = new DateTimeAxis(AxisPosition.Bottom)
                 {
                     Minimum = x0 - 0.9,
                     Maximum = x0 + 1.9,
                     IntervalType = DateTimeIntervalType.Days,
                     MajorStep = 1,
                     MinorStep = 1
                 };
     a.StringFormat = "yyyy-MM-dd";
     m.Axes.Add(a);
     var s = new BoxPlotSeries();
     s.TrackerFormatString =
                     "X: {1:yyyy-MM-dd}\nUpper Whisker: {2:0.00}\nThird Quartil: {3:0.00}\nMedian: {4:0.00}\nFirst Quartil: {5:0.00}\nLower Whisker: {6:0.00}";
     s.Items.Add(new BoxPlotItem(x0, 10, 14, 16, 20, 22, new[] { 23.5 }));
     s.Items.Add(new BoxPlotItem(x0 + 1, 11, 13, 14, 15, 18, new[] { 23.4 }));
     m.Series.Add(s);
     return m;
 }
        /// <summary>
        /// Function that sets up the <see cref="TimePlotModel"/>.
        /// </summary>
        public void SetUpTimePlotModel()
        {
            TimePlotModel = new PlotModel();

            var xAxis = new DateTimeAxis() { Position = AxisPosition.Bottom, IntervalLength = 40, StringFormat = "HH:mm" };
            var yAxis = new LinearAxis() { Position = AxisPosition.Left, IntervalLength = 30 };

            TimePlotModel.Axes.Add(xAxis);
            TimePlotModel.Axes.Add(yAxis);

            var lineSeries = new LineSeries { TrackerFormatString = "Time: {2:HH:mm}\n{3}: {4:0.###}" };

            TimePlotModel.Series.Add(lineSeries);

            TimePlotModel.InvalidatePlot(true);
        }
Esempio n. 54
0
        public void RunColumnChart()
        {
            chartType = Utilities.ChartType.CHART_COLUMN;

            // Get the a reference to the ShinobiChart from the ChartFragment
            ColumnSeries series = new ColumnSeries();

            Com.ShinobiControls.Charts.ChartFragment chartFragment =
                (Com.ShinobiControls.Charts.ChartFragment) _mainActivity.FragmentManager.FindFragmentById(Resource.Id.chart1);

            IShinobiChart shinobiChart = chartFragment.ShinobiChart;

            if(shinobiChart.Series.Count>0)
                shinobiChart.RemoveSeries(shinobiChart.Series[0]);

            if (shinobiChart.Series.Count > 0)
                series = (ColumnSeries) shinobiChart.Series [0];

            // TODO: replace <license_key_here> with you trial license key
            shinobiChart.SetLicenseKey(licenseKey);

            shinobiChart.RedrawChart ();
            //shinobiChart.Title ="Closing Stock Price for Google Inc. (GOOG)";

            // Create the X axis with pre-defined default range
            DateRange xAxisDefaultRange = new DateRange(new DateTime(2012, 1, 1), new DateTime(2014, 12, 31));

            DateTimeAxis xAxis = new DateTimeAxis(xAxisDefaultRange);

            xAxis.Title = "Datum";
            xAxis.GesturePanningEnabled = true;
            xAxis.GestureZoomingEnabled = true;
            xAxis.Style.InterSeriesPadding = 0;
            xAxis.Style.InterSeriesSetPadding = 0;

            shinobiChart.XAxis = xAxis;

            List<BusinessLayer.PersonUmsatz> PersonUmsatzList =  _stateClass._person.GetPersonTimeUmsatz ("36", MainActivity.User);

            List<IData> dataPoints = LoadStockPriceData(PersonUmsatzList);
            int yHighestValue = this.GetHighestYValue (PersonUmsatzList);
            // Add ten percent to get a gap at the top of the columns
            yHighestValue = (int)(yHighestValue * 1.1);


            // Create the Y axis
            NumberAxis yAxis = new NumberAxis(new NumberRange(0.0,  yHighestValue ));

            yAxis.Title =_mainActivity.Resources.GetString(Resource.String.Umsatz) + " (Euro)";

            yAxis.GesturePanningEnabled = true;
            yAxis.GestureZoomingEnabled = true;
            shinobiChart.YAxis = yAxis;

            // Create the line series
            DataAdapter dataAdapter = new SimpleDataAdapter();



            // Load and add the stock price data
            dataAdapter.AddAll(dataPoints);
            series.DataAdapter = dataAdapter;

            // Add the series to the chart
            shinobiChart.AddSeries(series);

        }
        public void UpdateStatistics()
        {
            Program.HomeGenie.ServiceCall("HomeAutomation.HomeGenie/Statistics/Parameter.StatsHour/Meter.Watts/", (data) =>
            {
                dynamic graph = JsonConvert.DeserializeObject(data);
                UiHelper.SafeInvoke(this.plot1, () => {

                    var myModel = new PlotModel();
                    // define an axis Date  
                    var dateTimeAxis = new DateTimeAxis()
                    {
                        //Title = "Hour",
                        Position = AxisPosition.Bottom,
                        IntervalType = DateTimeIntervalType.Hours,
                        MajorStep = 0.12,
                        StringFormat = "HH:mm"
                    };

                    LinearAxis yAxis = new LinearAxis()
                    {
                        Position = AxisPosition.Left,
                        MajorStep = 25
                    };

                    //dateTimeAxis.FontSize = 8D;
                    dateTimeAxis.AxislineColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.ExtraGridlineColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.MajorGridlineColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.MinorGridlineColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.TextColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.TicklineColor = OxyColor.FromRgb(255, 255, 255);
                    dateTimeAxis.TitleColor = OxyColor.FromRgb(255, 255, 255);

                    myModel.DefaultFontSize = 8D;
                    myModel.PlotAreaBorderColor = OxyColor.FromRgb(100, 100, 100);
                    myModel.TitleColor = OxyColor.FromRgb(255, 255, 255);
                    myModel.TextColor = OxyColor.FromRgb(255, 255, 255);

                    myModel.Axes.Add(dateTimeAxis);
                    myModel.Axes.Add(yAxis);

                    var linearSeries1 = new LineSeries();
                    //linearSeries1.Title = "Overall Avg";
                    linearSeries1.Selectable = false;
                    linearSeries1.Smooth = true;
                    linearSeries1.Color = OxyColor.FromArgb(200, 100, 100, 255);
                    linearSeries1.ItemsSource = GetSerie(graph[1]);
                    myModel.Series.Add(linearSeries1);

                    var linearSeries2 = new LineSeries();
                    //linearSeries2.Title = "Today";
                    linearSeries2.Selectable = false;
                    linearSeries2.Smooth = true;
                    linearSeries2.Color = OxyColor.FromArgb(200, 100, 255, 100);
                    linearSeries2.ItemsSource = GetSerie(graph[4]);
                    myModel.Series.Add(linearSeries2);

                    this.plot1.Model = myModel;

                });
            });
        }
Esempio n. 56
0
        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);
            _view = (PlotView) view;
            _view.SizeChanged += _view_SizeChanged;
            if (TrackerTemplate!=null)
                _view.Plot.DefaultTrackerTemplate = TrackerTemplate;
           
            _bw.DoWork += _bw_DoWork;
             //model = new PlotModel("Test");
            AppState.TimelineManager.TimeChanged += TimelineManager_TimeChanged;
            model.Title = Title;
            //model.IsLegendVisible = true;
            //model.LegendBackground = OxyColor.FromArgb(200, 255, 255, 255);
            //model.LegendBorder = OxyColors.Black;
            //model.LegendPlacement = LegendPlacement.Inside;
            //model.LegendPosition = LegendPosition.TopRight;

            dateAxis = new DateTimeAxis();
            dateAxis.Title = "Time Series";
            dateAxis.Minimum = DateTimeAxis.ToDouble(AppState.TimelineManager.Start);
            dateAxis.Maximum = DateTimeAxis.ToDouble(AppState.TimelineManager.End);
            dateAxis.ExtraGridlines = new double[1];            
            dateAxis.MajorGridlineThickness = 1;
            dateAxis.MajorGridlineStyle = LineStyle.Solid;
            dateAxis.MinorGridlineStyle = LineStyle.Solid;
            
            dateAxis.ExtraGridlines[0] = DateTimeAxis.ToDouble(AppState.TimelineManager.FocusTime);
            dateAxis.ExtraGridlineThickness = 2;
            dateAxis.TimeZone = TimeZoneInfo.Utc;

            if (TimeZone != null)
                dateAxis.TimeZone = TimeZone;

            firstAxis = new LinearAxis(AxisPosition.Left,"");
            firstAxis.Key = "Left";
            firstAxis.Title = "Values";
            firstAxis.MajorGridlineStyle = LineStyle.Solid;
            firstAxis.MinorGridlineStyle = LineStyle.Solid;

            model.Axes.Add(firstAxis);

            //var linearAxis2 = new LinearAxis();
            //linearAxis2.Position = AxisPosition.Right;
            //linearAxis2.Key = "Right";
            //model.Axes.Add(linearAxis2);

            model.Axes.Add(dateAxis);
            _view.Plot.Model = model;
            _view.Plot.PreviewTouchDown += Plot_PreviewTouchDown;
            _view.Plot.ActualModel.Updating += ActualModel_Updating;

            dateAxis.AxisChanged += dateAxis_AxisChanged;

            IObservable<System.Reactive.EventPattern<AxisChangedEventArgs>> eventAsObservable = Observable.FromEventPattern
                <AxisChangedEventArgs>(ev => dateAxis.AxisChanged += ev, ev => dateAxis.AxisChanged -= ev);
            eventAsObservable.Throttle(TimeSpan.FromMilliseconds(250)).Subscribe(k =>
            {
                var min = DateTimeAxis.ToDateTime(dateAxis.ActualMinimum);
                var max = DateTimeAxis.ToDateTime(dateAxis.ActualMaximum);
                if (AppState.TimelineManager.Start != min || AppState.TimelineManager.End!=max)
                {
                    //Execute.OnUIThread(() =>
                    //{
                    //    AppState.TimelineManager.Start = min;
                    //    AppState.TimelineManager.End = max;
                    //    AppState.TimelineManager.ForceTimeChanged();
                    //});
                }
            }
                );

            SurfaceDragDrop.AddDropHandler(_view, Drop);

            DataSets.CollectionChanged += DataSetsCollectionChanged;
            if (DataSets.Count() == 1 && !string.IsNullOrEmpty(DataSets[0].Title)) model.Title = DataSets[0].Title;
            foreach (DataSet ds in DataSets )
            {
                //Set the title of the axis to the unit of the dataset being shown
                if (ds.Unit != null) firstAxis.Title = ds.Unit; 
                AddDataSet(ds);
            }
            //_bw.RunWorkerAsync();
            FitDataSets();
        }
Esempio n. 57
0
        public static PlotModel MarkerTypeCircleProblem()
        {
            var plotModel = new PlotModel { LegendSymbolLength = 30, PlotType = PlotType.Cartesian, PlotAreaBorderThickness = new OxyThickness(0) };


            var xaxis = new DateTimeAxis
                            {
                                Position = AxisPosition.Bottom,
                                TickStyle = TickStyle.None,
                                AxislineStyle = LineStyle.Solid,
                                AxislineColor = OxyColor.FromRgb(153, 153, 153),
                                StringFormat = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(1) + "d HH",
                                IntervalType = DateTimeIntervalType.Hours
                            };

            var yaxis = new LinearAxis
                            {
                                Position = AxisPosition.Left,
                                Minimum = 0.001f,
                                Maximum = 3,
                                MajorGridlineStyle = LineStyle.Solid,
                                TickStyle = TickStyle.None,
                                IntervalLength = 50
                            };

            plotModel.Axes.Add(xaxis);
            plotModel.Axes.Add(yaxis);

            var series1 = new LineSeries
                              {
                                  Color = OxyColor.FromRgb(44, 169, 173),
                                  StrokeThickness = 1,
                                  MarkerType = MarkerType.Circle,
                                  MarkerStroke = OxyColors.Blue,
                                  MarkerFill = OxyColors.SkyBlue,
                                  // MarkerStrokeThickness = 5,
                                  MarkerSize = 2,
                                  DataFieldX = "Date",
                                  DataFieldY = "Value",
                                  TrackerFormatString = "Date: {2:d HH}&#x0a;Value: {4}"
                              };

            series1.Points.Add(new DataPoint(0.1, 0.7));
            series1.Points.Add(new DataPoint(0.6, 0.9));
            series1.Points.Add(new DataPoint(1.0, 0.85));
            series1.Points.Add(new DataPoint(1.4, 0.95));
            series1.Points.Add(new DataPoint(1.8, 1.2));
            series1.Points.Add(new DataPoint(2.2, 1.7));
            series1.Points.Add(new DataPoint(2.6, 1.7));
            series1.Points.Add(new DataPoint(3.0, 0.7));

            plotModel.Series.Add(series1);

            return plotModel;
        }
Esempio n. 58
0
        /// <summary>
        /// Ensure the specified X exists. Uses the 'DataType' property of the DataColumn
        /// to determine the type of axis.
        /// </summary>
        /// <param name="axisType">The axis type to check</param>
        /// <param name="dataType">The data type of the axis</param>
        private void EnsureAxisExists(Models.Graph.Axis.AxisType axisType, Type dataType)
        {
            // Make sure we have an x axis at the correct position.
            if (this.GetAxis(axisType) == null)
            {
                AxisPosition position = this.AxisTypeToPosition(axisType);
                OxyPlot.Axes.Axis axisToAdd;
                if (dataType == typeof(DateTime))
                {
                    axisToAdd = new DateTimeAxis();
                }
                else if (dataType == typeof(double))
                {
                    axisToAdd = new LinearAxis();
                }
                else
                {
                    axisToAdd = new CategoryAxis();
                }

                axisToAdd.Position = position;
                axisToAdd.Key = axisType.ToString();
                this.plot1.Model.Axes.Add(axisToAdd);
            }
        }
Esempio n. 59
0
 private void SetUp(PlotModel plot)
 {
     plot.LegendOrientation = LegendOrientation.Vertical;
     plot.LegendPlacement = LegendPlacement.Inside;
     plot.LegendPosition = LegendPosition.RightTop;
     plot.LegendBackground = OxyColor.FromAColor(100, OxyColors.Wheat);
     plot.Background = OxyColor.FromAColor(200, OxyColors.Ivory);
     var dateAxis = new DateTimeAxis
     {
         Position = AxisPosition.Bottom,
         Title = "Data",
         StringFormat = "dd/MM/yy",
         MinorIntervalType = DateTimeIntervalType.Days,
         IntervalType = DateTimeIntervalType.Days,
         MajorGridlineStyle = LineStyle.Solid,
         MinorGridlineStyle = LineStyle.None
     };
     plot.Axes.Add(dateAxis);
     var valueAxis = new LinearAxis
     {
         MajorGridlineStyle = LineStyle.Solid,
         MinorGridlineStyle = LineStyle.Dot,
         Position = AxisPosition.Left
     };
     plot.Axes.Add(valueAxis);
 }
 /// <summary>
 /// Acquires an independent axis suitable for use with the data values of the series.
 /// </summary>
 /// <returns>Axis instance.</returns>
 protected override IAxis AcquireIndependentAxis()
 {
     IAxis independentAxis = SeriesHost.Axes
         .Where(a => (a.Orientation == AxisOrientation.X) && ((a is IRangeAxis) || (a is ICategoryAxis)) && DataItems.Any() && (a.CanPlot(DataItems.First().ActualIndependentValue)))
         .FirstOrDefault();
     if (null == independentAxis)
     {
         object probeValue = DataItems.Any() ? DataItems.First().ActualIndependentValue : null;
         double convertedDouble;
         DateTime convertedDateTime;
         if ((null != probeValue) && ValueHelper.TryConvert(probeValue, out convertedDouble))
         {
             independentAxis = new LinearAxis();
         }
         else if ((null != probeValue) && ValueHelper.TryConvert(probeValue, out convertedDateTime))
         {
             independentAxis = new DateTimeAxis();
         }
         else
         {
             independentAxis = new CategoryAxis();
         }
         independentAxis.Orientation = AxisOrientation.X;
     }
     return independentAxis;
 }