示例#1
0
        Control Hours(TimeInterval m)
        {
            var model = new OxyPlot.PlotModel()
            {
                Title           = "Hours",
                Background      = OxyColors.White,
                DefaultFont     = "Arial",
                DefaultFontSize = 10.0
            };

            model.Axes.Add(new DateTimeAxis
            {
                Position           = AxisPosition.Left,
                MajorGridlineStyle = LineStyle.Solid,
                // MinorGridlineStyle = LineStyle.Dot,
                MajorStep    = 1,
                Minimum      = DateTimeAxis.ToDouble(m.Begin.AddDays(-1)),
                Maximum      = DateTimeAxis.ToDouble(m.End),
                StringFormat = "ddd dd.MM.",
            });

            model.Axes.Add(new TimeSpanAxis
            {
                Position           = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                StringFormat       = "h:mm",
            });

            var w = input.Range(m)
                    .GroupBy(x => x.TimeInterval.Begin.Date)
                    .Select(g => new
            {
                Day     = g.Key,
                Active  = g.Where(_ => _.IsActive).Sum(_ => _.TimeInterval.Duration.TotalSeconds),
                Working = Worktime(g).TotalSeconds,
                On      = g.Sum(_ => _.TimeInterval.Duration.TotalSeconds)
            })
                    .ToList();

            var activity = new OxyPlot.Series.RectangleBarSeries()
            {
                TrackerFormatString = "{2} - {3}",
                StrokeThickness     = 0
            };

            foreach (var i in w)
            {
                var refDay = i.Day;
                var y      = DateTimeAxis.ToDouble(refDay);
                activity.Items.Add(new RectangleBarItem(0, y - daySep, i.On, y + daySep)
                {
                    Color = ToOxyColor(idleColor)
                });
                activity.Items.Add(new RectangleBarItem(0, y - daySep, i.Working, y + daySep)
                {
                    Color = ToOxyColor(workingColor)
                });
                activity.Items.Add(new RectangleBarItem(0, y - daySep, i.Active, y + daySep)
                {
                    Color = ToOxyColor(activeColor)
                });
            }

            model.Series.Add(activity);

            var plotView = new OxyPlot.WindowsForms.PlotView
            {
                Model = model
            };

            return(plotView);
        }
示例#2
0
        Control Overview(TimeInterval m)
        {
            var model = new OxyPlot.PlotModel()
            {
                Title           = "Overview",
                Background      = OxyColors.White,
                DefaultFont     = "Arial",
                DefaultFontSize = 10.0
            };

            model.Axes.Add(new DateTimeAxis
            {
                Position           = AxisPosition.Left,
                MajorGridlineStyle = LineStyle.Solid,
                MajorStep          = 1,
                MinorStep          = 1.0 / 4.0,
                Minimum            = DateTimeAxis.ToDouble(m.Begin.AddDays(-1)),
                Maximum            = DateTimeAxis.ToDouble(m.End),
                StringFormat       = "ddd dd.MM.",
            });

            model.Axes.Add(new TimeSpanAxis
            {
                Position           = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                Minimum            = TimeSpan.Zero.TotalSeconds,
                Maximum            = TimeSpan.FromDays(1).TotalSeconds,
                StringFormat       = "h:mm",
            });

            var bars = Summarize(input.Range(m));

            var activity = new OxyPlot.Series.RectangleBarSeries()
            {
                TrackerFormatString = "{2} - {3}",
                StrokeThickness     = 0
            };

            foreach (var i in bars)
            {
                foreach (var t in i.TimeInterval.SplitToDays())
                {
                    var refDay = t.Begin.Date;
                    var y0     = DateTimeAxis.ToDouble(refDay);
                    var x0     = (t.Begin - refDay).TotalSeconds;
                    var x1     = (t.End - refDay).TotalSeconds;
                    activity.Items.Add(new OxyPlot.Series.RectangleBarItem(x0, y0 - daySep, x1, y0 + daySep)
                    {
                        Color = OxyPlot.OxyColor.FromUInt32((uint)(i.IsActive ? activeColor : idleColor).ToArgb())
                    });
                }
            }

            model.Series.Add(activity);

            /*
             * var keys = new OxyPlot.Series.ScatterSeries()
             * {
             *  MarkerType = MarkerType.Circle,
             *
             * };
             *
             * foreach (var i in input.Range(m))
             * {
             *  if (i.KeyDown > 0)
             *  {
             *      keys.Points.Add(new OxyPlot.Series.ScatterPoint(
             *          i.TimeInterval.Begin.ToLocalTime().TimeOfDay.TotalSeconds,
             *          i.TimeInterval.Begin.ToLocalTime().Date.ToOADate()));
             *  }
             * }
             *
             * model.Series.Add(keys);
             */

            var plotView = new OxyPlot.WindowsForms.PlotView
            {
                Model = model
            };

            return(plotView);
        }
示例#3
0
        /// <summary>
        /// <c>VelocitiesViewModel()</c> provides the model-histogram for the PatientProfileChart
        /// </summary>
        public VelocitiesViewModel()
        {
            /***** Retrieve the measurements from a particular Date *****/

            DataAccess db = new DataAccess();

            measurementID = db.GetMeasurementIDs(Index.AMKADateIndex); //get the info about this particular study
            diagnosis1    = db.GetDiagnosisHistogram(1);
            diagnosis9    = db.GetDiagnosisHistogram(9);
            if (measurementID.Count != 0)
            {
                measurement = db.GetMeasurements(measurementID[Index.DateIndex].PK); //get the measurements from dbo.Measurements according to the PK from dbo.MeasurementsID
            }


            /***** Create the Patient's Histogram Bins *****/
            int minHist  = 0;
            int maxHist  = 84;
            int minYaxis = 0;
            int maxYaxis = 100;

            var    fcvHistogram = Histogram.CreateEmpty(minHist, maxHist);
            double count        = 0;
            float  xmin         = 10000;
            float  xmax         = 0;

            foreach (var x in measurement)
            {
                if (x.FCV < xmin)
                {
                    xmin = x.FCV;
                }
                if (x.FCV > xmax)
                {
                    xmax = x.FCV;
                }
                if (x.FCV != 0)
                {
                    fcvHistogram.Increment((int)x.FCV); //(int)1.5 = 1. I want to increment
                    count++;                            // add individual data points
                }
            }

            /***** Create the visual part of the Histogram ******/

            this.Title = "Conduction Velocities";

            OxyPlot.Axes.LinearAxis xaxis = new OxyPlot.Axes.LinearAxis();
            xaxis.Title                  = "FCV(m/s)";
            xaxis.Minimum                = 30;
            xaxis.Maximum                = maxHist;
            xaxis.MajorStep              = 2;
            xaxis.MinimumMinorStep       = 2;
            xaxis.TitleFontWeight        = 700;
            xaxis.Position               = AxisPosition.Bottom;
            xaxis.MajorGridlineStyle     = LineStyle.Solid;
            xaxis.MinorGridlineStyle     = LineStyle.Solid;
            xaxis.MinorGridlineThickness = 1.5;

            OxyPlot.Axes.LinearAxis yaxis = new OxyPlot.Axes.LinearAxis();
            yaxis.Title              = "%";
            yaxis.Minimum            = minYaxis;
            yaxis.Maximum            = maxYaxis;
            yaxis.MajorStep          = 20;
            yaxis.MajorTickSize      = 10;
            yaxis.TitleFontWeight    = 700;
            yaxis.Position           = AxisPosition.Left;
            yaxis.MajorGridlineStyle = LineStyle.Solid;
            yaxis.MinorGridlineStyle = LineStyle.Solid;

            OxyPlot.Axes.LinearAxis xaxis2 = new OxyPlot.Axes.LinearAxis();
            xaxis2.Title                  = "FCV(m/s)";
            xaxis2.Minimum                = 30;
            xaxis2.Maximum                = maxHist;
            xaxis2.MajorStep              = 2;
            xaxis2.MinimumMinorStep       = 2;
            xaxis2.TitleFontWeight        = 700;
            xaxis2.Position               = AxisPosition.Bottom;
            xaxis2.MajorGridlineStyle     = LineStyle.Solid;
            xaxis2.MinorGridlineStyle     = LineStyle.Solid;
            xaxis2.MinorGridlineThickness = 1.5;

            OxyPlot.Axes.LinearAxis yaxis2 = new OxyPlot.Axes.LinearAxis();
            yaxis2.Title           = "%";
            yaxis2.TitleFontWeight = 700;
            yaxis2.MajorStep       = 5;
            yaxis2.MajorTickSize   = 10;
            //yaxis2.StringFormat = "0.00%";
            yaxis2.Minimum            = minYaxis;
            yaxis2.Maximum            = 25;
            yaxis2.Position           = AxisPosition.Left;
            yaxis2.MajorGridlineStyle = LineStyle.Solid;
            yaxis2.MinorGridlineStyle = LineStyle.Solid;

            OxyPlot.Axes.LinearAxis xaxis3 = new OxyPlot.Axes.LinearAxis();
            xaxis3.Title                  = "FCV(m/s)";
            xaxis3.Minimum                = 30;
            xaxis3.Maximum                = maxHist;
            xaxis3.MajorStep              = 2;
            xaxis3.MinimumMinorStep       = 2;
            xaxis3.TitleFontWeight        = 700;
            xaxis3.Position               = AxisPosition.Bottom;
            xaxis3.MajorGridlineStyle     = LineStyle.Solid;
            xaxis3.MinorGridlineStyle     = LineStyle.Solid;
            xaxis3.MinorGridlineThickness = 1.5;

            OxyPlot.Axes.LinearAxis yaxis3 = new OxyPlot.Axes.LinearAxis();
            yaxis3.Title              = "%";
            yaxis3.TitleFontWeight    = 700;
            yaxis3.MajorStep          = 5;
            yaxis3.MajorTickSize      = 10;
            yaxis3.Minimum            = minYaxis;
            yaxis3.Maximum            = 25;
            yaxis3.Position           = AxisPosition.Left;
            yaxis3.MajorGridlineStyle = LineStyle.Solid;
            yaxis3.MinorGridlineStyle = LineStyle.Solid;

            /* Searched Patients' Bars */

            OxyPlot.Series.RectangleBarSeries bars = new OxyPlot.Series.RectangleBarSeries();
            bars.FillColor       = OxyColors.Gray;
            bars.StrokeColor     = OxyColors.Black;
            bars.StrokeThickness = 1;
            bars.Title           = "Patient";

            count = 100.0 / count;
            double x0 = 0, temp = 0;

            foreach (var x in fcvHistogram.BinsAndValues)
            {
                if (x.Key % 2 != 0)
                {
                    bars.Items.Add(new RectangleBarItem(x0, 0.0, x0 + 2, (x.Value + temp) * count));
                    x0 = x0 + 2;
                }
                temp = x.Value;
            }


            /* ALS Patients' Bars */

            OxyPlot.Series.RectangleBarSeries bars2 = new OxyPlot.Series.RectangleBarSeries();
            bars2.StrokeColor     = OxyColors.Black;
            bars2.StrokeThickness = 1;
            bars2.FillColor       = OxyColors.Maroon;
            bars2.Title           = "ALS";

            foreach (var x in diagnosis1)
            {
                if (x.Percentage != 0)
                {
                    bars2.Items.Add(new RectangleBarItem(x.Interval, 0.0, x.Interval + 2, x.Percentage * 100));
                }
            }

            /* Normal Patients' Bars */

            OxyPlot.Series.RectangleBarSeries bars3 = new OxyPlot.Series.RectangleBarSeries();
            bars3.StrokeColor     = OxyColors.Black;
            bars3.StrokeThickness = 1;
            bars3.FillColor       = OxyColors.MidnightBlue;
            bars3.Title           = "Normal";

            foreach (var x in diagnosis9)
            {
                bars3.Items.Add(new RectangleBarItem(x.Interval, 0.0, x.Interval + 2, x.Percentage * 100));
            }

            /* View Model's assemblage */

            Model            = new PlotModel();
            Model.Title      = "Conduction Velocities";
            Model.Background = OxyColors.White;
            Model.Axes.Add(xaxis);
            Model.Axes.Add(yaxis);
            Model.Series.Add(bars);

            ModelALS            = new PlotModel();
            ModelALS.Background = OxyColors.White;
            ModelALS.Axes.Add(xaxis2);
            ModelALS.Axes.Add(yaxis2);
            ModelALS.Series.Add(bars2);


            ModelNormal            = new PlotModel();
            ModelNormal.Background = OxyColors.White;
            ModelNormal.Axes.Add(xaxis3);
            ModelNormal.Axes.Add(yaxis3);
            ModelNormal.Series.Add(bars3);
        }
示例#4
0
        public void Redraw()
        {
            Plot = new PlotModel();
            Plot.DefaultFontSize = Model.DefaultFontSize;
            Plot.LegendFontSize  = Model.LegendFontSize;
            Plot.Title           = Model.Title;
            if (Model.ShowLegend)
            {
                switch (Model.LegendPosition)
                {
                case OpenFMSL.Contracts.Infrastructure.Reporting.LegendPosition.TopRight:
                    Plot.LegendPosition = OxyPlot.LegendPosition.RightTop;
                    break;

                case OpenFMSL.Contracts.Infrastructure.Reporting.LegendPosition.TopLeft:
                    Plot.LegendPosition = OxyPlot.LegendPosition.TopLeft;
                    break;

                case OpenFMSL.Contracts.Infrastructure.Reporting.LegendPosition.BottomLeft:
                    Plot.LegendPosition = OxyPlot.LegendPosition.BottomLeft;
                    break;

                case OpenFMSL.Contracts.Infrastructure.Reporting.LegendPosition.BottomRight:
                    Plot.LegendPosition = OxyPlot.LegendPosition.BottomRight;
                    break;

                default:
                    Plot.LegendPosition = OxyPlot.LegendPosition.RightTop;
                    break;
                }

                Plot.IsLegendVisible = true;
            }

            Plot.Axes.Clear();

            LinearAxis yAxis = new LinearAxis {
                Position = AxisPosition.Left, Title = Model.YAxisTitle, AxisTitleDistance = 10
            };

            if (Model.IsReversedYAxis)
            {
                yAxis.StartPosition = 1;
                yAxis.EndPosition   = 0;
            }

            Plot.Axes.Add(yAxis);

            LinearAxis xAxis = new LinearAxis {
                Position = AxisPosition.Bottom, Title = Model.XAxisTitle, AxisTitleDistance = 10
            };

            Plot.Axes.Add(xAxis);

            if (!Model.AutoScaleX)
            {
                xAxis.Minimum = Model.XMin;
                xAxis.Maximum = Model.XMax;
            }

            if (!Model.AutoScaleY)
            {
                yAxis.Minimum = Model.YMin;
                yAxis.Maximum = Model.YMax;
            }

            Plot.Series.Clear();

            foreach (var series in Model.Series)
            {
                switch (series.Type)
                {
                case SeriesType.StackedBar100:
                {
                    var line = new BarSeries();
                    line.IsStacked = true;
                    line.Title     = series.Name;
                    for (int i = 0; i < series.X.Count; i++)
                    {
                        var item = new BarItem(series.X[i]);

                        line.Items.Add(item);
                    }
                    if (series.ShowInLegend)
                    {
                        line.RenderInLegend = true;
                    }
                    else
                    {
                        line.RenderInLegend = false;
                    }

                    Plot.Series.Add(line);
                    break;
                }

                case SeriesType.Line:
                {
                    var line = new LineSeries();
                    line.MarkerType      = OxyPlot.MarkerType.Circle;
                    line.Title           = series.Name;
                    line.StrokeThickness = series.Thickness;

                    if (series.Color != "Auto")
                    {
                        var seriesColor = System.Drawing.Color.FromName(series.Color);
                        line.Color = OxyColor.FromArgb(seriesColor.A, seriesColor.R, seriesColor.G, seriesColor.B);
                    }


                    switch (series.DashPattern)
                    {
                    case DashPattern.Dash:
                        //line.BrokenLineStyle = LineStyle.Dash;
                        line.LineStyle = LineStyle.Dash;
                        //line.BrokenLineColor = OxyColors.Transparent;
                        //line.BrokenLineThickness = series.Thickness;
                        break;

                    case DashPattern.AlternatingDash:
                        //line.BrokenLineStyle = LineStyle.LongDash;
                        //line.BrokenLineColor = OxyColors.Transparent;
                        //line.BrokenLineThickness = series.Thickness;
                        line.LineStyle = LineStyle.LongDashDot;
                        break;

                    case DashPattern.DashDot:
                        //line.BrokenLineStyle = LineStyle.DashDot;
                        //line.BrokenLineColor = OxyColors.Transparent;
                        //line.BrokenLineThickness = series.Thickness;
                        line.LineStyle = LineStyle.DashDot;
                        break;

                    case DashPattern.Dotted:
                        //line.BrokenLineStyle = LineStyle.Dot;
                        //line.BrokenLineColor = OxyColors.Transparent;
                        //line.BrokenLineThickness = series.Thickness;
                        line.LineStyle = LineStyle.Dot;
                        break;

                    default:
                        line.LineStyle = LineStyle.Solid;
                        //line.BrokenLineStyle = LineStyle.Solid;
                        //line.BrokenLineThickness = 0;
                        break;
                    }


                    for (int i = 0; i < series.X.Count; i++)
                    {
                        var item = new DataPoint(series.X[i], series.Y[i]);

                        line.Points.Add(item);
                    }
                    if (series.ShowMarker)
                    {
                        line.MarkerSize = 2 * series.Thickness;
                        line.MarkerFill = line.Color;
                    }

                    if (series.ShowInLegend)
                    {
                        line.RenderInLegend = true;
                    }
                    else
                    {
                        line.RenderInLegend = false;
                    }

                    Plot.Series.Add(line);
                    break;
                }

                case SeriesType.Scatter:
                {
                    var line = new ScatterSeries();
                    line.Title = series.Name;
                    switch (series.Marker)
                    {
                    case OpenFMSL.Contracts.Infrastructure.Reporting.MarkerType.Circle:
                        line.MarkerType = OxyPlot.MarkerType.Circle;
                        break;

                    case OpenFMSL.Contracts.Infrastructure.Reporting.MarkerType.Diamond:
                        line.MarkerType = OxyPlot.MarkerType.Diamond;
                        break;

                    case OpenFMSL.Contracts.Infrastructure.Reporting.MarkerType.Square:
                        line.MarkerType = OxyPlot.MarkerType.Square;
                        break;

                    default:
                        line.MarkerType = OxyPlot.MarkerType.Cross;
                        break;
                    }

                    if (series.Color != "Auto")
                    {
                        var seriesColor = System.Drawing.Color.FromName(series.Color);
                        line.MarkerFill = OxyColor.FromArgb(seriesColor.A, seriesColor.R, seriesColor.G, seriesColor.B);
                    }

                    for (int i = 0; i < series.X.Count; i++)
                    {
                        var item = new ScatterPoint(series.X[i], series.Y[i]);

                        line.Points.Add(item);
                    }

                    if (series.ShowInLegend)
                    {
                        line.RenderInLegend = true;
                    }
                    else
                    {
                        line.RenderInLegend = false;
                    }

                    Plot.Series.Add(line);
                    break;
                }

                case SeriesType.JacobianStructure:
                {
                    var line = new OxyPlot.Series.RectangleBarSeries();

                    LinearAxis XAxisReversed = new LinearAxis {
                        Position = AxisPosition.Bottom, Title = "Variables", IntervalLength = 15, StartPosition = 0, EndPosition = 1
                    };
                    Plot.Axes.Add(XAxisReversed);

                    // Y2 Axis
                    LinearAxis YAxisReversed = new LinearAxis {
                        Position = AxisPosition.Left, Title = "Equations", IntervalLength = 15, StartPosition = 1, EndPosition = 0
                    };
                    Plot.Axes.Add(YAxisReversed);


                    double currentX = 0;
                    double currentY = 0;
                    line.Title = "Jacobian Structure";
                    //line.TrackerFormatString = "{0}\n{1}: {2} {3}\n{4}: {5} {6}";

                    for (int i = 0; i < series.X.Count; i++)
                    {
                        var item = new RectangleBarItem {
                            X0 = currentX, X1 = currentX + series.X[i], Y0 = currentY, Y1 = currentY + series.Y[i]
                        };
                        line.Items.Add(item);
                        currentX += series.X[i];
                        currentY += series.Y[i];


                        if (series.X[i] != series.Y[i])
                        {
                            item.Color = OxyColors.OrangeRed;
                        }
                        else
                        {
                            item.Color = OxyColors.DodgerBlue;
                        }
                    }
                    Plot.Series.Add(line);
                }
                break;

                default:
                {
                    var line = new LineSeries();
                }
                break;
                }
            }
        }
示例#5
0
        private void MakeModels(long PK)
        {
            DataAccess db = new DataAccess();

            measurement = db.GetMeasurements(PK);

            /***** Create the Histogram Bins *****/

            var    fcvHistogram = Histogram.CreateEmpty(0, 80, 80);
            double count        = 0;
            float  xmin         = 10000;
            float  xmax         = 0;

            foreach (var x in measurement)
            {
                if (x.FCV < xmin)
                {
                    xmin = x.FCV;
                }
                if (x.FCV > xmax)
                {
                    xmax = x.FCV;
                }
                if (x.FCV != 0)
                {
                    fcvHistogram.Increment((int)x.FCV); //(int)1.5 = 1. I want to inceremen
                    count++;                            // add individual data points
                }
            }

            /***** Create the visual part of the Histogram ******/

            //this.Title = "Conduction Velocities";

            OxyPlot.Axes.LinearAxis xaxis = new OxyPlot.Axes.LinearAxis();

            xaxis.Title              = "FCV(m/s)";
            xaxis.Minimum            = (int)xmin - 5;
            xaxis.Maximum            = (int)xmax + 5;
            xaxis.TitleFontWeight    = 700;
            xaxis.Position           = AxisPosition.Bottom;
            xaxis.MajorGridlineStyle = LineStyle.Solid;
            xaxis.MinorGridlineStyle = LineStyle.Solid;

            OxyPlot.Axes.LinearAxis yaxis = new OxyPlot.Axes.LinearAxis();
            yaxis.Title              = "%";
            yaxis.TitleFontWeight    = 700;
            yaxis.Position           = AxisPosition.Left;
            yaxis.MajorGridlineStyle = LineStyle.Solid;
            yaxis.MinorGridlineStyle = LineStyle.Solid;

            OxyPlot.Series.RectangleBarSeries bars = new OxyPlot.Series.RectangleBarSeries();
            //s1.IsStacked = true;
            bars.StrokeColor = OxyColors.Black;
            bars.FillColor   = OxyColors.DarkOliveGreen;
            bars.Background  = OxyColors.GhostWhite;
            count            = 100.0 / count;


            double x0 = 0, x1 = 1;

            foreach (var x in fcvHistogram.BinsAndValues)
            {
                //s1.Items.Add(new ColumnItem(x.Value*count));
                bars.Items.Add(new RectangleBarItem(x0, 0.0, x1, x.Value * count));
                //xaxis.Labels.Add(x.Key.ToString().Substring(0, 3));
                x0++;
                x1++;
            }

            var Model = new PlotModel();

            Model.Title      = "Conduction Velocities";
            Model.Background = OxyColors.GhostWhite;
            Model.Axes.Add(xaxis);
            Model.Axes.Add(yaxis);
            Model.Series.Add(bars);
            model.Add(Model);
        }