public void GetItemSalesChart()
 {
     try
     {
         foreach (var item in Beverages)
         {
             var dataPerDetector = OrderDetails.Where(a => a.BeverageId == item.BeverageId).OrderByDescending(m => m.SaleDate.Date).GroupBy(m => m.SaleDate.Date).
                                   Select(g => new { Total = g.Sum(p => p.Quantity), date = g.Key }).Take(100).ToList();
             var lineSerie = new OxyPlot.Series.LineSeries
             {
                 // LabelFormatString = item.ItemName,
                 StrokeThickness             = 1,
                 MarkerSize                  = 3,
                 MarkerStroke                = OxyColor.FromUInt32((UInt32)item.BeverageId),
                 MarkerType                  = MarkerType.Diamond,
                 CanTrackerInterpolatePoints = false,
                 Title   = item.Name,
                 ToolTip = item.Name
             };
             foreach (var item2 in dataPerDetector)
             {
                 lineSerie.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(item2.date), (double)item2.Total));
             }
             PlotModel.Series.Add(lineSerie);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #2
0
        public HeatMapSeries GetHeatMapPlot(int size)
        {
            var data = new double[size * 2, size * 2];

            for (int i = -size; i < size; i++)
            {
                for (int j = -size; j < size; j++)
                {
                    var x      = i * 5e-12;
                    var y      = j * 5e-12;
                    var radius = Math.Sqrt(x * x + y * y);
                    var theta  = Math.Atan2(radius, 0);
                    var phi    = Math.Atan2(y, x);
                    data[i + size, j + size] = _waveFunction.GetValue(radius, theta, phi);
                }
            }

            return(new HeatMapSeries()
            {
                X0 = -size,
                X1 = size,
                Y0 = -size,
                Y1 = size,
                Interpolate = true,
                Background = OxyColor.FromUInt32(4278192527),
                RenderMethod = HeatMapRenderMethod.Bitmap,
                Data = data
            });
        }
        //internal void LoadChart(LedgerAccount ledgerAccount, Chart chart)
        //{
        //    throw new NotImplementedException();
        //}
        internal void LoadChartForSingleAccount()
        {
            //    if (SelectedLedgerAccount != null)
            //    {
            //        var measurements = LedgerTransactionDetails
            //            .Join(LedgerTransactions,
            //            a => a.LedgerTransactionId,
            //            b => b.LedgerTransactionId,
            //            (a, b) =>
            //            new
            //            {
            //                Date = b.Date,
            //                Amount = a.Amount,
            //                Account = a.LedgerAccount.AccountName
            //            }).ToList();
            //        var k = measurements.Where(a => a.Account == SelectedLedgerAccount.AccountName)
            //       .GroupBy(s => s.Date)
            //       .Select(s => new { name = s.Key, sum = s.Sum(a => a.Amount) })
            //       .OrderBy(s => s.sum).AsEnumerable()
            //       .Select(a => new KeyValuePair<string, decimal>(a.name.Date.ToShortDateString(), (decimal)a.sum)).ToList();
            //        ChartData = k;
            //}

            try
            {
                PlotModel = new PlotModel();
                SetUpModelNew();
                var dataPerDetector = LedgerTransactionDetails.Where(a => a.LedgerAccountId == SelectedLedgerAccount.LedgerAccountId)
                                      .Take(10).OrderBy(a => a.LedgerTransaction.Date.Date)
                                      .GroupBy(m => m.LedgerTransaction.Date.Date)
                                      .Select(g => new
                {
                    Total   = g.Sum(p => p.Amount),
                    date    = g.Key,
                    Account = g.Select(a => a.LedgerAccount.AccountName).FirstOrDefault()
                })
                                      .ToList();

                //string bevname = GetBeverageName(data.Key);
                var lineSerie = new OxyPlot.Series.LineSeries
                {
                    ToolTip = string.Format(" {0} Sales", dataPerDetector.Select(a => a.Account).FirstOrDefault()),
                    // LabelFormatString = string.Format("{0} Sales", dataPerDetector.Select(a => a.Item).FirstOrDefault()),
                    StrokeThickness = 1,
                    MarkerSize      = 3,
                    MarkerStroke    = OxyColor.FromUInt32((uint)SelectedLedgerAccount.LedgerAccountId),

                    MarkerType = MarkerType.Diamond,// markerTypes[data.Key],
                    CanTrackerInterpolatePoints = false,
                    Title = string.Format("{0} Sales", dataPerDetector.Select(a => a.Account).FirstOrDefault())
                };
                dataPerDetector.ForEach(d => lineSerie.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(d.date), double.Parse(d.Total.ToString()))));
                PlotModel.Series.Add(lineSerie);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        // Implemented for IGraphRenderer
        public void Render(Canvas canvas, DateIndexLookup dil, SensorDataLogResults results)
        {
            var sensor  = results.sensor;
            var serial  = sensor.device.serialNumber;
            var indices = dil.count;
            var series  = results.AsLineSeries(dil);

            model.Subtitle = serial.ToString() + "(" + sensor.type.GetTypeString() + ")";

            xAxis.Minimum        = 0;
            xAxis.Maximum        = indices - 1;
            xAxis.MajorStep      = (xAxis.Maximum - xAxis.Minimum) / Math.Min(10, indices);
            xAxis.LabelFormatter = (arg) => {
                var date = dil.GetDateTimeFromIndex((int)arg);
                return(date.ToLongTimeString());
            };

            yAxis.Minimum   = results.minimum.amount;
            yAxis.Maximum   = results.maximum.amount;
            yAxis.MajorStep = (yAxis.Maximum - yAxis.Minimum) / 5;
            if (yAxis.MajorStep == 0)
            {
                yAxis.MajorStep = 1;
            }
            yAxis.LabelFormatter = (arg) => {
                var su = sensor.unit.standardUnit;
                return(SensorUtils.ToFormattedString(su.OfScalar(arg).ConvertTo(sensor.unit)));
            };
            yAxis.Title = sensor.unit.ToString();

            model.Series.Clear();
            foreach (var s in series)
            {
                var colors = sensor.GetColorForSensor(context);
                s.Color = OxyColor.FromUInt32((uint)colors.Item1.ToArgb());
                model.Series.Add(s);
            }

            model.InvalidatePlot(true);

            var widthSpec  = View.MeasureSpec.MakeMeasureSpec(800, MeasureSpecMode.Exactly);
            var heightSpec = View.MeasureSpec.MakeMeasureSpec(400, MeasureSpecMode.Exactly);

            plot.Measure(widthSpec, heightSpec);
            plot.Layout(0, 0, plot.MeasuredWidth, plot.MeasuredHeight);
            plot.Draw(canvas);

            if (plot.Model.GetLastPlotException() != null)
            {
                throw plot.Model.GetLastPlotException();
            }
        }
 internal void LoadChart()
 {
     try
     {
         foreach (var item in LedgerAccounts)
         {
             var dataPerDetector = LedgerTransactionDetails.Where(a => a.LedgerAccountId == item.LedgerAccountId).OrderByDescending(m => m.LedgerTransaction.Date.Date).GroupBy(m => m.LedgerTransaction.Date.Date).
                                   Select(g => new { Total = g.Sum(p => p.Amount), date = g.Key }).Take(100).ToList();
             var lineSerie = new OxyPlot.Series.LineSeries
             {
                 // LabelFormatString = item.AccountName,
                 StrokeThickness             = 1,
                 MarkerSize                  = 3,
                 MarkerStroke                = OxyColor.FromUInt32((UInt32)item.LedgerAccountId),
                 MarkerType                  = MarkerType.Diamond,
                 CanTrackerInterpolatePoints = false,
                 Title   = item.AccountName,
                 ToolTip = item.AccountName
             };
             foreach (var item2 in dataPerDetector)
             {
                 lineSerie.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(item2.date), (double)item2.Total));
             }
             PlotModel.Series.Add(lineSerie);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     //if (SelectedLedgerAccount != null)
     //{
     //    var measurements = LedgerTransactionDetails
     //        .Join(LedgerTransactions,
     //        a => a.LedgerTransactionId,
     //        b => b.LedgerTransactionId,
     //        (a, b) =>
     //        new
     //        {
     //            Date = b.Date,
     //            Amount = a.Amount,
     //            Account = a.LedgerAccount.AccountName
     //        }).ToList();
     //    var k = measurements.Where(a => a.Account == SelectedLedgerAccount.AccountName)
     //   .GroupBy(s => s.Date)
     //   .Select(s => new { name = s.Key, sum = s.Sum(a => a.Amount) })
     //   .OrderBy(s => s.sum).AsEnumerable()
     //   .Select(a => new KeyValuePair<string, decimal>(a.name.Date.ToShortDateString(), (decimal)a.sum)).ToList();
     //    ChartData = k;
     //}
 }
Beispiel #6
0
        public static OxyColor OxyColorFromString(this String color)
        {
            var value = 0u;

            if (color.Length == 7 && color[0] == '#' && UInt32.TryParse("FF" + color.Substring(1), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out value))
            {
                return(OxyColor.FromUInt32(value));
            }
            else if (color.Length >= 10 && color.StartsWith("rgb(", StringComparison.OrdinalIgnoreCase) && color[color.Length - 1] == ')')
            {
                var content = color.Substring(4, color.Length - 5);
                var commas  = 0;

                for (var i = 0; i < content.Length; i++)
                {
                    if (content[i] == ',')
                    {
                        commas++;
                    }
                }

                if (commas == 3)
                {
                    content += ",0";
                }

                try
                {
                    return(OxyColor.Parse(content));
                }
                catch
                {
                }
            }
            else
            {
                var fields = typeof(OxyColors).GetFields();

                foreach (var field in fields)
                {
                    if (field.Name.Equals(color, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return((OxyColor)field.GetValue(null));
                    }
                }
            }

            return(OxyColors.Black);
        }
Beispiel #7
0
 private static CandleStickSeries CreateCandleStickSeries(string title, IEnumerable <TickData> ticks)
 {
     return(new CandleStickSeries
     {
         //CandleWidth = 6,
         Title = title,
         Color = OxyColor.FromRgb(57, 58, 59),             //black
         IncreasingFill = OxyColor.FromUInt32(0xCC60A917), //green
         DecreasingFill = OxyColor.FromUInt32(0xCCFA6800), //orange
         DataFieldX = "Time",
         DataFieldHigh = "High",
         DataFieldLow = "Low",
         DataFieldOpen = "Open",
         DataFieldClose = "Close",
         TrackerFormatString = "{0}\n{1:MM/dd/yyyy HH:mm:ss}\nOpen: {5:N4}\nHigh: {3:N4}\nLow: {4:N4}\nClose: {6:N4}",
         ItemsSource = ticks,
     });
 }
Beispiel #8
0
        // Implemented for IGraphRenderer
        public void Render(Canvas canvas, DateIndexLookup dil, SensorDataLogResults results)
        {
            var sensor  = results.sensor;
            var serial  = sensor.device.serialNumber;
            var indices = dil.count;
            var series  = results.AsLineSeries(dil);

            model.Title    = serial.ToString();
            model.Subtitle = "(" + sensor.type.GetTypeString() + ")";

            xAxis.Minimum   = 0;
            xAxis.Maximum   = indices - 1;
            xAxis.MajorStep = (xAxis.Maximum - xAxis.Minimum) / Math.Min(10, indices);

            yAxis.Minimum   = results.minimum.amount;
            yAxis.Maximum   = results.maximum.amount;
            yAxis.MajorStep = (yAxis.Maximum - yAxis.Minimum) / 5;
            if (yAxis.MajorStep == 0)
            {
                yAxis.MajorStep = 1;
            }

            model.Series.Clear();
            foreach (var s in series)
            {
                var c = sensor.GetColorForSensor(context);
                s.Color = OxyColor.FromUInt32((uint)c.Item1.ToArgb());
                model.Series.Add(s);
            }

            model.InvalidatePlot(true);

            var widthSpec  = View.MeasureSpec.MakeMeasureSpec(800, MeasureSpecMode.Exactly);
            var heightSpec = View.MeasureSpec.MakeMeasureSpec(400, MeasureSpecMode.Exactly);

            plot.Measure(widthSpec, heightSpec);
            plot.Layout(0, 0, plot.MeasuredWidth, plot.MeasuredHeight);
            plot.Draw(canvas);

            if (plot.Model.GetLastPlotException() != null)
            {
                throw plot.Model.GetLastPlotException();
            }
        }
        public override void PlotLine(string line, int lineIndex)
        {
            String[] values = line.Split(' ');
            if (omitnext || values.Length != 2)
            {
                InitPlot("", OxyColor.FromUInt32((uint)rng.Next()));
                time     = 0;
                omitnext = !omitnext;
                return;
            }
            double[] doubles = new double[values.Length];


            for (int i = 0; i < values.Length; i++)
            {
                doubles[i] = double.Parse(values[i], culture);
            }


            double dist = Math.Sqrt(Math.Pow(doubles[0], 2) + Math.Pow(doubles[1], 2));

            //Split single walk
            //if(dist < 0.05 && time > 1000) {
            //    InitPlot("", OxyColor.FromUInt32((uint)rng.Next()));
            //    time = 0;
            //}

            if (avgdist.Count <= time)
            {
                avgdist.Add(0);
            }
            avgdist[time] += dist;

            plot.AddPoint(time, dist);
            //plot.AddPoint(doubles[0], doubles[1]);
            if (time % 10 == 0)
            {
                HistogramData(time, dist);
            }
            time += omit;
        }
Beispiel #10
0
        public void LoadSettings()
        {
            string filename = System.Windows.Forms.Application.StartupPath + "/mview.ini";

            if (System.IO.File.Exists(filename))
            {
                using (TextReader text = new StreamReader(filename))
                {
                    axisXStyle = (LineStyle)Enum.Parse(typeof(LineStyle), text.ReadLine(), true);
                    axisXWidth = Int32.Parse(text.ReadLine());
                    axisXColor = OxyColor.FromUInt32(UInt32.Parse(text.ReadLine()));

                    axisYStyle = (LineStyle)Enum.Parse(typeof(LineStyle), text.ReadLine(), true);
                    axisYWidth = Int32.Parse(text.ReadLine());
                    axisYColor = OxyColor.FromUInt32(UInt32.Parse(text.ReadLine()));

                    LegendPosition = (OxyPlot.Legends.LegendPosition)Enum.Parse(typeof(OxyPlot.Legends.LegendPosition), text.ReadLine(), true);

                    int count = Int32.Parse(text.ReadLine());

                    for (int iw = 0; iw < count; ++iw)
                    {
                        var tmpStyle = new SeriesStyle();

                        tmpStyle.name            = text.ReadLine();
                        tmpStyle.lineColor       = OxyColor.FromUInt32(UInt32.Parse(text.ReadLine()));
                        tmpStyle.markerColor     = OxyColor.FromUInt32(UInt32.Parse(text.ReadLine()));
                        tmpStyle.markerFillColor = OxyColor.FromUInt32(UInt32.Parse(text.ReadLine()));
                        tmpStyle.markerSize      = Int32.Parse(text.ReadLine());
                        tmpStyle.lineWidth       = Int32.Parse(text.ReadLine());
                        tmpStyle.lineSmooth      = Boolean.Parse(text.ReadLine());
                        tmpStyle.markerType      = (MarkerType)Enum.Parse(typeof(MarkerType), text.ReadLine(), true);
                        tmpStyle.lineStyle       = (LineStyle)Enum.Parse(typeof(LineStyle), text.ReadLine(), true);

                        listSeriesStyle.Add(tmpStyle);
                    }

                    text.Close();
                }
            }
        }
Beispiel #11
0
        public void InvalidatePlot(double[] answers, string label)
        {
            PlotStyle++;
            //Model.Series.Clear();
            int nextHalf = 0;
            //// Create two line series (markers are hidden by default)
            //if (foolSystem)
            //{
            //    var seriesDown = new LineSeries
            //    {
            //        Title = "First half of the discrete equations",
            //        MarkerType = MarkerType.Circle
            //    };
            //    for (int i = 0; i < answers.Length / 2; i++)
            //        seriesDown.Points.Add(new DataPoint(i, answers[i]));
            //    // Add the series to the plot model
            //    Model.Series.Add(seriesDown);
            //    nextHalf = answers.Length / 2;, BrokenLineColor = OxyColors.Bisque
            //}

            var seriesUp = new LineSeries {
                Title = PlotStyle % 2 == 0 ? "Numerical Solution" : "Neural Network", MarkerType = (MarkerType)PlotStyle, BrokenLineColor = OxyColor.FromUInt32((uint)new Random().Next(0, 600))
            };

            for (int i = nextHalf; i < answers.Length; i++)
            {
                seriesUp.Points.Add(new DataPoint(i - answers.Length / 2, 1 / (1 + Math.Exp(-answers[i]))));
            }

            // Add the series to the plot model
            Model.Series.Add(seriesUp);
            // Axes are created automatically if they are not defined
        }
Beispiel #12
0
 public void FromUInt32()
 {
     Assert.AreEqual(OxyColors.Red, OxyColor.FromUInt32(0xFFFF0000));
 }
Beispiel #13
0
        public static PlotModel RichterMagnitudes()
        {
            // http://en.wikipedia.org/wiki/Richter_magnitude_scale

            var model = new PlotModel
            {
                Title              = "The Richter magnitude scale",
                PlotMargins        = new OxyThickness(80, 0, 80, 40),
                LegendPlacement    = LegendPlacement.Inside,
                LegendPosition     = LegendPosition.TopCenter,
                LegendOrientation  = LegendOrientation.Horizontal,
                LegendSymbolLength = 24
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Title = "Richter magnitude scale", MajorGridlineStyle = LineStyle.None, TickStyle = TickStyle.None
            });

            var frequencyCurve = new LineSeries
            {
                Title                 = "Frequency",
                Color                 = OxyColor.FromUInt32(0xff3c6c9e),
                StrokeThickness       = 3,
                MarkerStroke          = OxyColor.FromUInt32(0xff3c6c9e),
                MarkerFill            = OxyColors.White,
                MarkerType            = MarkerType.Circle,
                MarkerSize            = 4,
                MarkerStrokeThickness = 3
            };

            frequencyCurve.Points.Add(new DataPoint(1.5, 8000 * 365 * 100));
            frequencyCurve.Points.Add(new DataPoint(2.5, 1000 * 365 * 100));
            frequencyCurve.Points.Add(new DataPoint(3.5, 49000 * 100));
            frequencyCurve.Points.Add(new DataPoint(4.5, 6200 * 100));
            frequencyCurve.Points.Add(new DataPoint(5.5, 800 * 100));
            frequencyCurve.Points.Add(new DataPoint(6.5, 120 * 100));
            frequencyCurve.Points.Add(new DataPoint(7.5, 18 * 100));
            frequencyCurve.Points.Add(new DataPoint(8.5, 1 * 100));
            frequencyCurve.Points.Add(new DataPoint(9.5, 1.0 / 20 * 100));
            model.Axes.Add(new LogarithmicAxis {
                Position = AxisPosition.Left, Title = "Frequency / 100 yr", UseSuperExponentialFormat = true, MajorGridlineStyle = LineStyle.None, TickStyle = TickStyle.Outside
            });
            model.Series.Add(frequencyCurve);

            var energyCurve = new LineSeries
            {
                Title                 = "Energy",
                Color                 = OxyColor.FromUInt32(0xff9e6c3c),
                StrokeThickness       = 3,
                MarkerStroke          = OxyColor.FromUInt32(0xff9e6c3c),
                MarkerFill            = OxyColors.White,
                MarkerType            = MarkerType.Circle,
                MarkerSize            = 4,
                MarkerStrokeThickness = 3
            };

            energyCurve.Points.Add(new DataPoint(1.5, 11e6));
            energyCurve.Points.Add(new DataPoint(2.5, 360e6));
            energyCurve.Points.Add(new DataPoint(3.5, 11e9));
            energyCurve.Points.Add(new DataPoint(4.5, 360e9));
            energyCurve.Points.Add(new DataPoint(5.5, 11e12));
            energyCurve.Points.Add(new DataPoint(6.5, 360e12));
            energyCurve.Points.Add(new DataPoint(7.5, 11e15));
            energyCurve.Points.Add(new DataPoint(8.5, 360e15));
            energyCurve.Points.Add(new DataPoint(9.5, 11e18));
            energyCurve.YAxisKey = "energyAxis";

            model.Axes.Add(new LogarithmicAxis {
                Position = AxisPosition.Right, Title = "Energy / J", Key = "energyAxis", UseSuperExponentialFormat = true, MajorGridlineStyle = LineStyle.None, TickStyle = TickStyle.Outside
            });
            model.Series.Add(energyCurve);

            return(model);
        }
Beispiel #14
0
        private void UpdatePlot(DurationEnum duration)
        {
            Plots.Clear();

            if (Ticks == null || !Ticks.Any())
            {
                return;
            }

            var candles = CreatePlot(Name, CreateCandleStickSeries(Name + " " + duration, Ticks));

            var dateValues = Ticks.ToDateValuePoints(x => x.Close).ToList();

            var ema          = MovingAverage.CalculateEma(Ticks, 22);
            var channels     = MovingAverage.CalculateEmaChannels(Ticks, 22, 60);
            var lowerChannel = channels.Select(x => new DateValue {
                Date = x.Date, Value = x.LowerValue
            }).ToList();
            var upperChannel = channels.Select(x => new DateValue {
                Date = x.Date, Value = x.UpperValue
            }).ToList();

            var plotChannels = CreatePlot("Channels",
                                          CreateLineSeries("Close Price", OxyColor.FromUInt32(0xCCF0A30A), dateValues),
                                          CreateLineSeries("EMA 22", OxyColor.FromUInt32(0xCCFA6800), ema),
                                          CreateLineSeries("Lower Channel", OxyColor.FromUInt32(0xCCA4C400), lowerChannel),
                                          CreateLineSeries("Upper Channel", OxyColor.FromUInt32(0xCC60A917), upperChannel));

            var plotMa = CreatePlot("Moving Average",
                                    CreateLineSeries("Close Price", OxyColor.FromUInt32(0xCCF0A30A), dateValues),
                                    CreateLineSeries("MA 10", OxyColor.FromUInt32(0xCCA4C400), BasicAnalysis.CalculateMovingAverage(Ticks, 10)),
                                    CreateLineSeries("MA 100", OxyColor.FromUInt32(0xCC60A917), BasicAnalysis.CalculateMovingAverage(Ticks, 100)));

            var plotMinMax = CreatePlot("Min max",
                                        CreateLineSeries("Close Price", OxyColor.FromUInt32(0xCCF0A30A), dateValues),
                                        CreateLineSeries("Max 50", OxyColor.FromUInt32(0xCCA4C400), BasicAnalysis.CalculateMax(Ticks, 50)),
                                        CreateLineSeries("Min 50", OxyColor.FromUInt32(0xCC60A917), BasicAnalysis.CalculateMin(Ticks, 50)));

            var returns = CreatePlot("Returns", "P4",
                                     CreateTwoColorLineSeries("Annualized Returns", OxyColor.FromUInt32(0xCC60A917), OxyColor.FromUInt32(0xCCFA6800), CalculateReturns(dateValues)));

            Plots.Add(new PlotViewModel(candles));
            Plots.Add(new PlotViewModel(plotChannels));
            Plots.Add(new PlotViewModel(plotMa));
            Plots.Add(new PlotViewModel(plotMinMax));
            Plots.Add(new PlotViewModel(returns));

            //analysisPlotModel.Series.Add(closePrices);

            //analysisPlotModel.Series.Add(CreateLineSeries("MA 10", OxyColor.FromUInt32(0xCCA4C400), BasicAnalysis.CalculateMovingAverage(Ticks, 10)));
            //analysisPlotModel.Series.Add(CreateLineSeries("MA 100", OxyColor.FromUInt32(0xCC60A917), BasicAnalysis.CalculateMovingAverage(Ticks, 100)));

            //analysisPlotModel.Series.Add(CreateLineSeries("Max 10", OxyColor.FromUInt32(0xCC911A0E), BasicAnalysis.CalculateMax(Ticks, 10)));
            //analysisPlotModel.Series.Add(CreateLineSeries("Max 100", OxyColor.FromUInt32(0xCC1569CE), BasicAnalysis.CalculateMax(Ticks, 100)));

            //if (dateValues.Count > 30)
            //{
            //    var anno1 = new TextAnnotation();
            //    anno1.Text = "sdkjfhsdjkfhsd";
            //    anno1.TextPosition = DateTimeAxis.CreateDataPoint(dateValues[10].Date, dateValues[10].Value);
            //    analysisPlotModel.Annotations.Add(anno1);

            //    var anno2 = new ArrowAnnotation();
            //    anno2.Text = "bla blas bla";
            //    anno2.EndPoint = DateTimeAxis.CreateDataPoint(dateValues[30].Date, dateValues[30].Value);
            //    anno2.ArrowDirection = new ScreenVector(50, anno2.EndPoint.Y * 0.3);
            //    analysisPlotModel.Annotations.Add(anno2);
            //}

            //Plots.Add(new PlotViewModel(analysisPlotModel));

            var clenow = new SimpleClenow(Ticks);
        }
Beispiel #15
0
        public override void Bind()
        {
            ItemView.LayoutParameters.Height = desiredHeight;

            var sensor = record.data.sensor;
            var colors = sensor.GetColorForSensor(context);

            // Build the model
            _model = new PlotModel()
            {
                Background              = OxyColors.Transparent,
                DefaultFontSize         = 0,
                Padding                 = new OxyThickness(0),
                PlotAreaBorderThickness = new OxyThickness(0),
            };

            // Find the bounds of the graph and build the series
            Scalar low  = sensor.unit.OfScalar(double.MaxValue);
            Scalar high = sensor.unit.OfScalar(double.MinValue);

            foreach (var session in record.data.sessionIds)
            {
                var ls = new LineSeries()
                {
                    StrokeThickness       = 1,
                    Color                 = OxyColor.FromUInt32((uint)colors.Item1.ToArgb()),
                    MarkerType            = MarkerType.Circle,
                    MarkerSize            = 0,
                    MarkerStroke          = OxyColors.Transparent,
                    MarkerStrokeThickness = 0,
                };

                var su = sensor.unit.standardUnit;
                foreach (var log in record.data[session])
                {
                    var converted = log.measurement.ConvertTo(su);

                    if (converted < low)
                    {
                        low = converted;
                    }
                    if (converted > high)
                    {
                        high = converted;
                    }
                    var dp = new DataPoint(record.dil[log.recordedDate], converted.amount);
                    ls.Points.Add(dp);
                }

                // Add the series to the model
                _model.Series.Add(ls);
            }

            var span    = high.amount - low.amount;
            var padding = span * 0.05;

            if (padding < 1)
            {
                padding = 1;
            }

            // Create the axes
            _xAxis = new LinearAxis()
            {
                Position       = AxisPosition.Bottom,
                IsAxisVisible  = false,
                IsZoomEnabled  = false,
                IsPanEnabled   = false,
                MinimumPadding = 3,
                MaximumPadding = 3,
                Minimum        = 0,
                Maximum        = record.dil.count,
            };

            _yAxis = new LinearAxis()
            {
                Position       = AxisPosition.Left,
                IsAxisVisible  = false,
                IsZoomEnabled  = false,
                IsPanEnabled   = false,
                MinimumPadding = 3,
                MaximumPadding = 3,
                Minimum        = low.amount - padding,
                Maximum        = high.amount + padding,
            };

            // Finish setting up the model
            _model.Axes.Add(_xAxis);
            _model.Axes.Add(_yAxis);

            // Register the model to the graph view
            _graphView.Model = _model;


            // Prepare the locked view content
            _titleContainer.SetBackgroundColor(colors.Item1);
            _titleView.Text = sensor.device.serialNumber.deviceModel.GetTypeString() + ": " + sensor.name;
            _typeView.Text  = sensor.type.GetSensorTypeName();
            _titleView.SetTextColor(colors.Item2);
            _typeView.SetTextColor(colors.Item2);
        }
Beispiel #16
0
        private void CreateModel()
        {
            Model = new PlotModel {
                TextColor           = OxyColor.FromUInt32(0xffffffff),
                PlotAreaBorderColor = OxyColors.Transparent,
                LegendTextColor     = OxyColor.FromUInt32(0x88ffffff),
                LegendPosition      = LegendPosition.RightBottom,

                Axes =
                {
                    new LinearAxis {
                        Key           = KeyRpm,
                        Title         = ToolsStrings.Units_RPM,
                        TextColor     = OxyColors.White,
                        TitleColor    = OxyColors.White,
                        TicklineColor = OxyColors.White,
                        AxislineColor = OxyColors.White,
                        Minimum       = 0d,
                        Position      = AxisPosition.Bottom
                    },
                    new LinearAxis {
                        Key           = KeyBhp,
                        Title         = ToolsStrings.Units_BHP,
                        TextColor     = PowerColor,
                        TitleColor    = PowerColor,
                        TicklineColor = PowerColor,
                        AxislineColor = PowerColor,
                        Minimum       = 0d,
                        Position      = AxisPosition.Right
                    },
                    new LinearAxis {
                        Key           = KeyNm,
                        Title         = ToolsStrings.Units_Nm,
                        TextColor     = TorqueColor,
                        TitleColor    = TorqueColor,
                        TicklineColor = TorqueColor,
                        AxislineColor = TorqueColor,
                        Minimum       = 0d,
                        Position      = AxisPosition.Left
                    }
                },

                Series =
                {
                    new CatmulLineSeries {
                        Color               = PowerColor,
                        Title               = ToolsStrings.Common_Power,
                        XAxisKey            = KeyRpm,
                        YAxisKey            = KeyBhp,
                        TrackerKey          = KeyBhp,
                        TrackerFormatString = $"[b]{{4:F0}}[/b] {ToolsStrings.Units_BHP} at [b]{{2:F0}}[/b] {ToolsStrings.Units_RPM}"
                    },
                    new CatmulLineSeries {
                        Color               = TorqueColor,
                        Title               = ToolsStrings.Common_Torque,
                        XAxisKey            = KeyRpm,
                        YAxisKey            = KeyNm,
                        TrackerKey          = KeyNm,
                        TrackerFormatString = $"[b]{{4:F0}}[/b] {ToolsStrings.Units_Nm} at [b]{{2:F0}}[/b] {ToolsStrings.Units_RPM}"
                    }
                }
            };

            WeakEventManager <INotifyPropertyChanged, PropertyChangedEventArgs> .AddHandler(SettingsHolder.Content, nameof(INotifyPropertyChanged.PropertyChanged),
                                                                                            ContentSettings_Changed);
        }