protected void Page_Load(object sender, System.EventArgs e)
        {
            // Populate chart with random data
            Random	random = new Random();
            double	xValue = 2;
            for(int pointIndex = 0; pointIndex < 50; pointIndex++)
            {
                Chart1.Series["Series Input"].Points.AddXY(xValue, random.Next(2, 47));
                xValue += 2;
            }

            // Create strip lines which cover the areas with filtered values
            StripLine stripLine = new StripLine();
            stripLine.BackColor = Color.FromArgb(120, 241,185,168);
            stripLine.IntervalOffset = double.Parse(IntervalOffsetList.SelectedItem.Value);
            stripLine.Interval = double.Parse(StripWidthList.SelectedItem.Value) * 2.0;
            stripLine.StripWidth = double.Parse(StripWidthList.SelectedItem.Value);
            Chart1.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripLine);

            // Filter series data using custom filtering criteria
            Chart1.DataManipulator.Filter(new CustomFilter(stripLine.IntervalOffset, stripLine.StripWidth), "Series Input", "Series Output");

            // Show data points using point's index
            if(ShowAsIndexedList.SelectedItem.Text == "True")
            {
                Chart1.Series["Series Output"].IsXValueIndexed = true;
                Chart1.ChartAreas["FilteredData"].AxisX.Minimum = double.NaN;
                Chart1.ChartAreas["FilteredData"].AxisX.Maximum = double.NaN;
                Chart1.ChartAreas["FilteredData"].AxisX.LabelStyle.Interval = 2;
                Chart1.ChartAreas["FilteredData"].AxisX.MajorTickMark.Interval = 2;
                Chart1.ChartAreas["FilteredData"].AxisX.MajorGrid.Interval = 2;
            }
        }
Ejemplo n.º 2
0
Archivo: Model.cs Proyecto: Ring-r/opt
 public static double Calc(StripLine strip_line_i, StripLine strip_line_j)
 {
     if (strip_line_i.VX * strip_line_j.VY - strip_line_i.VY * strip_line_j.VX != 0)
         return (strip_line_i.PX - strip_line_j.PX) * strip_line_i.VY - (strip_line_i.PY - strip_line_j.PY) * strip_line_i.VX;
     else
         return double.PositiveInfinity; // !!!Надо проверять направленны ли они в одну сторону или в разные!!!
 }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Populate chart with random sales data
            Random		random = new Random();
            DateTime	xTime = new DateTime(2000, 8, 1, 0, 0, 0);
            for(int pointIndex = 0; pointIndex < int.Parse(DayNumberLst.SelectedItem.Value); pointIndex++)
            {
                // Simulate lower sales on the weekends
                double	yValue = random.Next(600, 950);
                if(xTime.DayOfWeek == DayOfWeek.Sunday || xTime.DayOfWeek == DayOfWeek.Saturday)
                {
                    yValue = random.Next(100, 400);
                }
                Chart1.Series["Series Input"].Points.AddXY(xTime, yValue);
                xTime = xTime.AddDays(1);
            }

            // Show data points using point's index
            if(ShowAsIndexedList.SelectedItem.Text == "True")
            {
                Chart1.Series["Series Output"].IsXValueIndexed = true;
                Chart1.ChartAreas["FilteredData"].AxisX.Minimum = double.NaN;
                Chart1.ChartAreas["FilteredData"].AxisX.Maximum = double.NaN;
            }
            else
            {
                Chart1.DataManipulator.FilterSetEmptyPoints = true;
            }

            // Filter series data
            if(FilterValuesList.SelectedItem.Value == "Weekends")
            {
                Chart1.DataManipulator.Filter(DateRangeType.DayOfWeek, "0,6", "Series Input", "Series Output");
            }
            else if(FilterValuesList.SelectedItem.Value == "Weekdays")
            {
                Chart1.DataManipulator.Filter(DateRangeType.DayOfWeek, "1-5", "Series Input", "Series Output");
            }
            else if(FilterValuesList.SelectedItem.Value == "Except 15")
            {
                Chart1.DataManipulator.Filter(DateRangeType.DayOfMonth, "1-14,16-31", "Series Input", "Series Output");
            }
            else if(FilterValuesList.SelectedItem.Value == "Except 1-15")
            {
                Chart1.DataManipulator.Filter(DateRangeType.DayOfMonth, "16-31", "Series Input", "Series Output");
            }

            // Create strip lines on the weekends
            StripLine stripLine = new StripLine();
            stripLine.BackColor = Color.FromArgb(120, Color.Gray);
            stripLine.IntervalOffset = -1.5;
            stripLine.IntervalOffsetType = DateTimeIntervalType.Days;
            stripLine.Interval = 1;
            stripLine.IntervalType = DateTimeIntervalType.Weeks;
            stripLine.StripWidth = 2;
            stripLine.StripWidthType =  DateTimeIntervalType.Days;
            Chart1.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripLine);
        }
Ejemplo n.º 4
0
Archivo: Model.cs Proyecto: Ring-r/opt
 } // !!!Дописать!!!
 public static Point2d Calc(StripLine strip_line_i, StripLine strip_line_j)
 {
     Vector2d vector_i = strip_line_i.Vector;
     Vector2d vector_j_ = new Vector2d() { X = -strip_line_j.VY, Y = strip_line_j.VX };
     double d = vector_i * vector_j_;
     if (d == 0)
         return null;
     else
         return strip_line_i.Point + vector_i * ((strip_line_j.Point - strip_line_i.Point) * vector_j_ / d);
 } // !!Проверить!!
Ejemplo n.º 5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Disable legend item for the first series
            Chart1.Series[0].IsVisibleInLegend = false;

            // Add simple custom legend item
            Chart1.Legends["Default"].CustomItems.Add(Color.FromArgb(32, 120,147,190), "Critical Values");

            // Add custom legend item with line style
            LegendItem legendItem = new LegendItem();
            legendItem.Name = "Line Style Item";
            legendItem.ImageStyle = LegendImageStyle.Line;
            legendItem.ShadowOffset = 1;
            legendItem.Color = Color.LightBlue;
            legendItem.MarkerStyle = MarkerStyle.Circle;
            Chart1.Legends["Default"].CustomItems.Add(legendItem);

            // Add custom legend item with marker style
            legendItem = new LegendItem();
            legendItem.Name = "Marker Style Item";
            legendItem.ImageStyle = LegendImageStyle.Marker;
            legendItem.ShadowOffset = 1;
            legendItem.Color = Color.Yellow;
            legendItem.MarkerStyle = MarkerStyle.Cross;
            legendItem.MarkerSize = 10;
            legendItem.MarkerBorderColor = Color.Black;
            Chart1.Legends["Default"].CustomItems.Add(legendItem);

            legendItem = new LegendItem();
            legendItem.Name = "Image Style Item";
            legendItem.Image = "Flag.gif";
            legendItem.BackImageTransparentColor = Color.White;
            Chart1.Legends["Default"].CustomItems.Add(legendItem);

            // Add a strip line
            StripLine stripLine = new StripLine();
            stripLine.BackColor = Chart1.Legends["Default"].CustomItems[0].Color;
            stripLine.IntervalOffset = 500;
            stripLine.StripWidth = 300;
            Chart1.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripLine);
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Populate chart with random data
            Random random = new Random();
            for(int pointIndex = 0; pointIndex < 100; pointIndex++)
            {
                Chart1.Series["Series Input"].Points.AddXY(random.Next(50,950), random.Next(50,950));
            }

            // Get filtering criteria constant
            double criteriaValue = double.Parse(MoreValuesList.SelectedItem.Value);

            // Create strip line which covers the area with filtered values
            StripLine stripLine = new StripLine();

            stripLine.BackColor = Color.FromArgb(120, 241,185,168);
            stripLine.IntervalOffset = criteriaValue;
            stripLine.StripWidth = 1000;
            if(PointValueList.SelectedItem.Value == "Y")
            {
                Chart1.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripLine);
            }
            else
            {
                Chart1.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripLine);
            }

            // Points that do not match the criteria will be removed
            if(MatchCriteriaList.SelectedItem.Value == "False")
            {
                Chart1.DataManipulator.FilterMatchedPoints = false;

                // Update the strip line which covers filtered area
                stripLine.IntervalOffset = 0;
                stripLine.StripWidth = criteriaValue;
            }

            // Filter series data by point's values
            Chart1.DataManipulator.Filter(CompareMethod.MoreThan, criteriaValue, "Series Input", "Series Output", PointValueList.SelectedItem.Value);
        }
Ejemplo n.º 7
0
Archivo: Model.cs Proyecto: Ring-r/opt
 public static double Calc(StripLine strip_line, Circle circle)
 {
     return (strip_line.PX - circle.X) * strip_line.VY - (strip_line.PY - circle.Y) * strip_line.VX - circle.R;
 }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Populate chart with random sales data
            Random		random = new Random();
            DateTime	xTime = DateTime.Today;
            for(int pointIndex = 0; pointIndex < 21; pointIndex++)
            {
                // Simulate lower sales on the weekends
                double	yValue = random.Next(600, 950);
                if(xTime.DayOfWeek == DayOfWeek.Sunday || xTime.DayOfWeek == DayOfWeek.Saturday)
                {
                    yValue = random.Next(100, 400);
                }
                Chart1.Series["Default"].Points.AddXY(xTime, yValue);
                xTime = xTime.AddDays(1);
            }

            double offset = -1.5;
            double width = 2;

            if(HighlightValuesList.SelectedItem.Text == "Weekends")
            {
                offset = -1.5;
                width = 2;
            }
            else if(HighlightValuesList.SelectedItem.Text == "Weekdays")
            {
                offset = 0.5;
                width = 5;
            }
            else if(HighlightValuesList.SelectedItem.Text == "Mondays")
            {
                offset = 0.5;
                width = 1;
            }
            else if(HighlightValuesList.SelectedItem.Text == "Wednesdays")
            {
                offset = 2.5;
                width = 1;
            }
            else if(HighlightValuesList.SelectedItem.Text == "Fridays")
            {
                offset = 4.5;
                width = 1;
            }
            else if(HighlightValuesList.SelectedItem.Text == "Mondays and Fridays")
            {
                // Create a re-occurring strip line for the monday
                StripLine strip = new StripLine();
                strip.BackColor = Color.FromArgb(120, Color.Gray);
                strip.IntervalOffset = 0.5;
                strip.IntervalOffsetType = DateTimeIntervalType.Days;
                strip.Interval = 1;
                strip.IntervalType = DateTimeIntervalType.Weeks;
                strip.StripWidth = 1;
                strip.StripWidthType =  DateTimeIntervalType.Days;
                Chart1.ChartAreas["ChartArea1"].AxisX.StripLines.Add(strip);

                offset = 4.5;
                width = 1;
            }

            // Create a re-occurring strip line for the selected range or
            // just the firday if monday and friday is the selection
            StripLine stripLine = new StripLine();
            stripLine.BackColor = Color.FromArgb(120, Color.Gray);
            stripLine.IntervalOffset = offset;
            stripLine.IntervalOffsetType = DateTimeIntervalType.Days;
            stripLine.Interval = 1;
            stripLine.IntervalType = DateTimeIntervalType.Weeks;
            stripLine.StripWidth = width;
            stripLine.StripWidthType =  DateTimeIntervalType.Days;
            Chart1.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripLine);
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            double dStartDate = DateTime.Today.ToOADate();
            Chart1.ChartAreas["ChartArea1"].AxisY.Minimum = dStartDate-1;
            Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.Interval = 3;
            Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.IntervalType = DateTimeIntervalType.Days;

            string [] task = { "Task 1",
                                 "Task 2", "Task 2",
                                 "Task 3",
                                 "Task 4",
                                 "Task 5", "Task 5",
                                 "Task 6",
                                 "Task 7" };

            double [] start = {3, 1, 6, 0, 3, 2, 5.5, 2, 4 };
            double [] end = {5, 3.5, 8, 5.5, 4, 3.5, 8, 5, 5 };

            Series ser = Chart1.Series[0];
            int pos = 1;
            string lastValue = "";
            for(int i = 0; i < start.Length-1; i++)
            {

                string xValue = task[i];
                if(lastValue != xValue)
                    pos++;

                string yValues = (dStartDate+start[i]).ToString()+","+(dStartDate+end[i]).ToString();
                DataPoint pt = new DataPoint(pos, yValues);
                pt.AxisLabel = xValue;
                ser.Points.Add(pt);

                lastValue = xValue;
            }

            double [] actualStart = {3, 1, 6, 0, 3, 2, 5.5, 2, 4 };
            double [] actualEnd = {4.5, 4.5, 6, 4.5, 4, 3.5, 5.5, 4.5, 4.5 };
            ser = Chart1.Series[1];
            pos = 1;
            lastValue = "";
            for(int i = 0; i < start.Length-1; i++)
            {
                string xValue = task[i];
                if(lastValue != xValue)
                    pos++;

                string yValues = (dStartDate+actualStart[i]).ToString()+","+(dStartDate+actualEnd[i]).ToString();
                DataPoint pt = new DataPoint(pos, yValues);
                pt.AxisLabel = xValue;
                ser.Points.Add(pt);

                if(dStartDate+dToday > actualStart[i])
                {
                    if(start[i] < actualStart[i] || end[i] < actualEnd[i])
                        pt.Color = Color.Red;
                    else if(dStartDate+dToday < end[i])
                        pt.Color = Color.Lime;
                    else if(end[i] == actualEnd[i])
                        pt.Color = Color.Gray;
                }

                lastValue = xValue;
            }

            StripLine stripLine = new StripLine();
            stripLine.StripWidth = 1;
            stripLine.Font = new Font("Arial", 8.25F, FontStyle.Bold);
            stripLine.ForeColor = Color.Gray;
            stripLine.Text = "Today";
            stripLine.TextOrientation = TextOrientation.Rotated90;
            stripLine.BorderColor = Color.Black;
            stripLine.BackColor = Color.PaleTurquoise;
            stripLine.IntervalOffset = dStartDate+dToday;
            stripLine.TextAlignment = StringAlignment.Center;
            stripLine.TextLineAlignment = StringAlignment.Near;

            Chart1.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripLine);

            LegendItem legendItem = new LegendItem();
            legendItem.Color = Color.Red;
            legendItem.Name = "Late";
            Chart1.Legends[0].CustomItems.Add(legendItem);

            foreach(DataPoint pt in Chart1.Series["Actual"].Points)
            {
                if(pt.YValues[0] == pt.YValues[1])
                    pt.Color = Color.Transparent;
            }

            // Set chart area 3D rotation
            if(RotateX.SelectedItem.Text != "")
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.Inclination = int.Parse(RotateX.SelectedItem.Text);

            if(RotateY.SelectedItem.Text != "")
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.Rotation = int.Parse(RotateY.SelectedItem.Text);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates the strip line representing the normal range on the graph
        /// </summary>
        /// <param name="normalRange">Point that contains the low (X) and high (Y) of the users personal settings normal range.</param>
        /// <returns>Strip line representing the normal range on the graph</returns>
        private StripLine HighlightNormalRange(System.Drawing.Point normalRange)
        {
            StripLine sl = new StripLine();
            double low = normalRange.X;
            double high = normalRange.Y;

            sl.Interval = 10000; //set the interval high enough that only one strip line will show
            sl.BackColor = System.Drawing.Color.FromArgb(60, 16, 150, 24);
            sl.StripWidth = high - low; //set width of strip to width of normal range
            sl.IntervalOffset = low; //start the first strip line at the bottom of range

            return sl;
        }
Ejemplo n.º 11
0
        private void comboBoxPointsHighlight_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            double offset = -1.5;
            double width  = 2;

            chart1.ChartAreas["Default"].AxisX.StripLines.Clear();

            string SelectedText = comboBoxPointsHighlight.SelectedItem.ToString();

            if (SelectedText == "Weekends")
            {
                offset = -1.5;
                width  = 2;
            }
            else if (SelectedText == "Weekdays")
            {
                offset = 0.5;
                width  = 5;
            }
            else if (SelectedText == "Mondays")
            {
                offset = 0.5;
                width  = 1;
            }
            else if (SelectedText == "Wednesdays")
            {
                offset = 2.5;
                width  = 1;
            }
            else if (SelectedText == "Fridays")
            {
                offset = 4.5;
                width  = 1;
            }
            else if (SelectedText == "Mondays and Fridays")
            {
                // Create a re-occurring strip line for the monday
                StripLine strip = new StripLine();
                strip.BackColor          = Color.FromArgb(120, Color.Gray);
                strip.IntervalOffset     = 0.5;
                strip.IntervalOffsetType = DateTimeIntervalType.Days;
                strip.Interval           = 1;
                strip.IntervalType       = DateTimeIntervalType.Weeks;
                strip.StripWidth         = 1;
                strip.StripWidthType     = DateTimeIntervalType.Days;
                chart1.ChartAreas["Default"].AxisX.StripLines.Add(strip);

                offset = 4.5;
                width  = 1;
            }


            // Create a re-occurring strip line for the selected range or
            // just the firday if monday and friday is the selection
            StripLine stripLine = new StripLine();

            stripLine.BackColor          = Color.FromArgb(120, Color.Gray);
            stripLine.IntervalOffset     = offset;
            stripLine.IntervalOffsetType = DateTimeIntervalType.Days;
            stripLine.Interval           = 1;
            stripLine.IntervalType       = DateTimeIntervalType.Weeks;
            stripLine.StripWidth         = width;
            stripLine.StripWidthType     = DateTimeIntervalType.Days;
            chart1.ChartAreas["Default"].AxisX.StripLines.Add(stripLine);
        }
Ejemplo n.º 12
0
        /// <summary>
        ///     Adds plan strips to the chart
        /// </summary>
        /// <param name="planCollection"></param>
        /// <param name="chart"></param>
        /// <param name="graphStartDate"></param>
        protected void SetPlanStrips(List <PlanPcd> planCollection, Chart chart, DateTime graphStartDate)
        {
            var backGroundColor = 1;

            foreach (var plan in planCollection)
            {
                var stripline = new StripLine();
                //Creates alternating backcolor to distinguish the plans
                if (backGroundColor % 2 == 0)
                {
                    stripline.BackColor = Color.FromArgb(120, Color.LightGray);
                }
                else
                {
                    stripline.BackColor = Color.FromArgb(120, Color.LightBlue);
                }

                //Set the stripline properties
                stripline.IntervalOffset     = (plan.StartTime - graphStartDate).TotalHours;
                stripline.IntervalOffsetType = DateTimeIntervalType.Hours;
                stripline.Interval           = 1;
                stripline.IntervalType       = DateTimeIntervalType.Days;
                stripline.StripWidth         = (plan.EndTime - plan.StartTime).TotalHours;
                stripline.StripWidthType     = DateTimeIntervalType.Hours;

                chart.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripline);

                //Add a corrisponding custom label for each strip
                var Plannumberlabel = new CustomLabel();
                Plannumberlabel.FromPosition = plan.StartTime.ToOADate();
                Plannumberlabel.ToPosition   = plan.EndTime.ToOADate();
                switch (plan.PlanNumber)
                {
                case 254:
                    Plannumberlabel.Text = "Free";
                    break;

                case 255:
                    Plannumberlabel.Text = "Flash";
                    break;

                case 0:
                    Plannumberlabel.Text = "Unknown";
                    break;

                default:
                    Plannumberlabel.Text = "Plan " + plan.PlanNumber;

                    break;
                }

                Plannumberlabel.ForeColor = Color.Black;
                Plannumberlabel.RowIndex  = 3;
                chart.ChartAreas["ChartArea1"].AxisX2.CustomLabels.Add(Plannumberlabel);

                var aogLabel = new CustomLabel();
                aogLabel.FromPosition = plan.StartTime.ToOADate();
                aogLabel.ToPosition   = plan.EndTime.ToOADate();
                aogLabel.Text         = plan.PercentArrivalOnGreen + "% AoG\n" +
                                        plan.PercentGreenTime + "% GT";

                aogLabel.LabelMark = LabelMarkStyle.LineSideMark;
                aogLabel.ForeColor = Color.Blue;
                aogLabel.RowIndex  = 2;
                chart.ChartAreas["ChartArea1"].AxisX2.CustomLabels.Add(aogLabel);

                var statisticlabel = new CustomLabel();
                statisticlabel.FromPosition = plan.StartTime.ToOADate();
                statisticlabel.ToPosition   = plan.EndTime.ToOADate();
                statisticlabel.Text         =
                    plan.PlatoonRatio + " PR";
                statisticlabel.ForeColor = Color.Maroon;
                statisticlabel.RowIndex  = 1;
                chart.ChartAreas["ChartArea1"].AxisX2.CustomLabels.Add(statisticlabel);

                //CustomLabel PlatoonRatiolabel = new CustomLabel();
                //PercentGreenlabel.FromPosition = plan.StartTime.ToOADate();
                //PercentGreenlabel.ToPosition = plan.EndTime.ToOADate();
                //PercentGreenlabel.Text = plan.PlatoonRatio.ToString() + " PR";
                //PercentGreenlabel.ForeColor = Color.Black;
                //PercentGreenlabel.RowIndex = 1;
                //chart.ChartAreas["ChartArea1"].AxisX2.CustomLabels.Add(PercentGreenlabel);

                //Change the background color counter for alternating color
                backGroundColor++;
            }
        }
        /// <summary>
        /// This method calculates a different indicator if corresponding 
        /// item in the combo box is selected.
        /// </summary>
        private void Calculations()
        {
            // Set Formula Name
            string formulaName = FormulaName.SelectedItem.Value;
            FinancialFormula formula = (FinancialFormula)Enum.Parse(typeof(FinancialFormula),formulaName,true);
            // Formulas with one input value
            if( formulaName == "DetrendedPriceOscillator" || formulaName == "MovingAverageConvergenceDivergence" || formulaName == "Performance" || formulaName == "RateOfChange"
                || formulaName == "TripleExponentialMovingAverage")
            {
                Chart1.DataManipulator.FinancialFormula(formula,"10","Input:Y4","Indicators");
            }

            // Relative Strength Index
            else if( formulaName == "RelativeStrengthIndex" )
            {
                Chart1.DataManipulator.FinancialFormula(formula,"10","Input:Y4","Indicators");

                // Set minimum and maximum for Y axis
                Chart1.ChartAreas["Indicator"].AxisY.Minimum = 0;
                Chart1.ChartAreas["Indicator"].AxisY.Maximum = 100;

                // Create strip lines used with Relative strength index.
                StripLine stripLine = new StripLine();
                Chart1.ChartAreas["Indicator"].AxisY.StripLines.Add(stripLine);
                stripLine.Interval = 70;
                stripLine.StripWidth = 30;
                stripLine.BackColor = Color.FromArgb(64, 165, 191, 228);

            }
            // Williams %R
            else if( formulaName == "WilliamsR" )
            {
                Chart1.DataManipulator.FinancialFormula(formula,"Input:Y,Input:Y2,Input:Y4","Indicators");

                // Set minimum and maximum for Y axis
                Chart1.ChartAreas["Indicator"].AxisY.Minimum = -100;
                Chart1.ChartAreas["Indicator"].AxisY.Maximum = 0;

                // Create strip lines used with Williams %R index.
                StripLine stripLine = new StripLine();
                Chart1.ChartAreas["Indicator"].AxisY.StripLines.Add(stripLine);
                stripLine.Interval = 80;
                stripLine.StripWidth = 20;
                stripLine.BackColor = Color.FromArgb(64, 165, 191, 228);
            }
            // Formulas with two input value
            else if( formulaName == "MassIndex" || formulaName == "VolatilityChaikins" || formulaName == "Performance" )
            {
                Chart1.DataManipulator.FinancialFormula(formula,"20","Input:Y,Input:Y2","Indicators");
            }
            // Standard deviation
            else if( formulaName == "StandardDeviation" )
            {
                Chart1.DataManipulator.FinancialFormula(formula,"15","Input:Y4","Indicators");
            }
            // StochasticIndicator
            else if( formulaName == "StochasticIndicator" )
            {
                Chart1.DataManipulator.FinancialFormula(formula,"15","Input:Y,Input:Y2,Input:Y4","Indicators,SMA");

                // Set attributes for Simple moving average series.
                Chart1.Series["SMA"].ChartType = SeriesChartType.Line;
                Chart1.Series["SMA"].Color = Color.FromArgb(252,180,65);
                Chart1.Series["SMA"].ChartArea = "Indicator";
                Chart1.Series["SMA"].BorderWidth = 2;
            }
            // All other formulas.
            else
            {
                Chart1.DataManipulator.FinancialFormula(formula,"Input:Y,Input:Y2,Input:Y4","Indicators");
            }

            // Set minimum for X axis
            Chart1.ChartAreas["Indicator"].AxisX.Minimum = DateTime.Parse("1/1/2002").ToOADate();
        }
Ejemplo n.º 14
0
            public static List<Point2d> Точки_плотного_размещения(Triple<Circle, DeloneCircle> triple, Circle data)
            {
                List<Point2d> points = new List<Point2d>();

                if (double.IsInfinity(triple.Delone_Circle.R))
                {
                    Vertex<Circle, DeloneCircle> vertex = triple.Vertex;
                    while (vertex.Data != null)
                        vertex = vertex.Next;
                    if (CircleExt.Расширенное_расстояние(vertex.Next.Data, vertex.Prev.Data) <= 2 * data.R)
                        points.Add(CircleExt.Точка_пересечения_границ(new Circle() { R = vertex.Next.Data.R + data.R, X = vertex.Next.Data.X, Y = vertex.Next.Data.Y }, new Circle() { R = vertex.Prev.Data.R + data.R, X = vertex.Prev.Data.X, Y = vertex.Prev.Data.Y }));
                }
                else
                {
                    if (triple.Delone_Circle.R >= data.R)
                    {
                        Vertex<Circle, DeloneCircle> vertex = triple.Vertex;
                        do
                        {

                            if (CircleExt.Расширенное_расстояние(vertex.Next.Data, vertex.Prev.Data) <= 2 * data.R)
                            {
                                if (double.IsInfinity(vertex.Cros.Delone_Circle.R))
                                {
                                    StripLine strip_line = new StripLine() { PX = vertex.Next.Data.X, PY = vertex.Next.Data.Y, VX = vertex.Prev.Data.X - vertex.Next.Data.X, VY = vertex.Prev.Data.Y - vertex.Next.Data.Y };
                                    if (PlaneExt.Расширенное_расстояние(strip_line, vertex.Delone_Circle.Center) < 0)
                                        points.Add(CircleExt.Точка_пересечения_границ(new Circle() { R = vertex.Next.Data.R + data.R, X = vertex.Next.Data.X, Y = vertex.Next.Data.Y }, new Circle() { R = vertex.Prev.Data.R + data.R, X = vertex.Prev.Data.X, Y = vertex.Prev.Data.Y }));
                                }
                                else
                                {
                                    StripLine strip_line = new StripLine() { PX = vertex.Next.Data.X, PY = vertex.Next.Data.Y, VX = vertex.Prev.Data.X - vertex.Next.Data.X, VY = vertex.Prev.Data.Y - vertex.Next.Data.Y };
                                    double r = PlaneExt.Расширенное_расстояние(strip_line, vertex.Delone_Circle.Center);
                                    double rr = PlaneExt.Расширенное_расстояние(strip_line, vertex.Cros.Delone_Circle.Center);

                                    if (r * rr < 0)
                                        points.Add(CircleExt.Точка_пересечения_границ(new Circle() { R = vertex.Next.Data.R + data.R, X = vertex.Next.Data.X, Y = vertex.Next.Data.Y }, new Circle() { R = vertex.Prev.Data.R + data.R, X = vertex.Prev.Data.X, Y = vertex.Prev.Data.Y }));
                                    else
                                        if (vertex.Cros.Delone_Circle.R < data.R)
                                            points.Add(CircleExt.Точка_пересечения_границ(new Circle() { R = vertex.Next.Data.R + data.R, X = vertex.Next.Data.X, Y = vertex.Next.Data.Y }, new Circle() { R = vertex.Prev.Data.R + data.R, X = vertex.Prev.Data.X, Y = vertex.Prev.Data.Y }));
                                }
                            }
                            vertex = vertex.Next;
                        } while (vertex != triple.Vertex);
                    }
                }

                return points;
            }
Ejemplo n.º 15
0
        private void loadData()
        {
            comm_list[] send_comm     = new comm_list[6];
            Series[]    DataSeries    = new Series[6];
            Series[]    DataSeries2   = new Series[6];
            Series[]    series3       = new Series[6];
            Series[]    series4       = new Series[6];
            DataPoint[] dataPoint1_1  = new DataPoint[6];
            DataPoint[] dataPoint2_1  = new DataPoint[6];
            DataPoint[] dataPoint3_1  = new DataPoint[6];
            DataPoint[] dataPoint4_1  = new DataPoint[6];
            DataPoint[] dataPoint5_1  = new DataPoint[6];
            DataPoint[] dataPoint6_1  = new DataPoint[6];
            DataPoint[] dataPoint7_1  = new DataPoint[6];
            DataPoint[] dataPoint8_1  = new DataPoint[6];
            StripLine[] s02           = new StripLine[6];
            Series      BoxPlotSeries = new Series();

            Series[] BoxPlotSeries2 = new Series[6];
            //Series BoxPlotSeries3 = new Series();
            //Series BoxPlotSeries4 = new Series();
            //Series BoxPlotSeries5 = new Series();
            //Series BoxPlotSeries6 = new Series();
            //Series BoxPlotSeries7 = new Series();


            ChartArea[] chart2_3 = new ChartArea[6];

            ChartArea[]          chart2_2 = new ChartArea[6];
            System.Data.DataView dv, dv1;

            chart1.ChartAreas.Clear();
            chart2.ChartAreas.Clear();
            chart3.ChartAreas.Clear();
            chart4.ChartAreas.Clear();
            chart5.ChartAreas.Clear();
            chart6.ChartAreas.Clear();
            chart7.ChartAreas.Clear();
            chart1.Series.Clear();
            chart2.Series.Clear();
            chart3.Series.Clear();
            chart4.Series.Clear();
            chart5.Series.Clear();
            chart6.Series.Clear();
            chart7.Series.Clear();

            //dv = MainModule.AccessDatabasesel("SELECT    format(gl.TestTime, 'YYYY-MM-DD') AS TestT, MAX(iif(isnull(a.GD0), 0,  CDBL(a.GD0))) AS Expr1, MAX(iif(isnull(a_1.GD1), 0, CDBL(a_1.GD1))) AS Expr2, " +
            //             " MAX(iif(isnull(a_2.GD2), 0, CDBL(a_2.GD2))) AS Expr3, MAX(iif(isnull(a_3.GD3),  0, CDBL(a_3.GD3))) AS Expr4, MAX(iif(isnull(a_4.GD4), 0, CDBL(a_4.GD4))) " +
            //            "  AS Expr5, MAX(iif(isnull(a_5.GD5), 0, CDBL(a_5.GD5))) AS Expr6,      MAX(iif(isnull(a_6.GD6), 0, CDBL(a_6.GD6))) AS Expr7, MAX(iif(isnull(a_7.GD7), " +
            //            "  0, CDBL(a_7.GD7))) AS Expr8, MAX(iif(isnull(a_8.GD8), 0, CDBL(a_8.GD8))) " +
            //            "  AS Expr9 FROM             (((((((((glucose gl LEFT OUTER JOIN " +
            //                "  (SELECT         GlucoseData AS GD0, format(TestTime, 'YYYY-MM-DD')   AS TT0    FROM           glucose gl_1 " +
            //                 "   WHERE          (TIME_IDX = 1)) a ON a.TT0 = format(gl.TestTime, 'YYYY-MM-DD'))   LEFT OUTER JOIN " +
            //                "  (SELECT         GlucoseData AS GD1, format(TestTime, 'YYYY-MM-DD')    AS TT1    FROM              glucose gl_2 " +
            //                  "  WHERE          (TIME_IDX = 2)) a_1 ON a_1.TT1 = format(gl.TestTime,      'YYYY-MM-DD')) LEFT OUTER JOIN " +
            //                 " (SELECT         GlucoseData AS GD2, format(TestTime, 'YYYY-MM-DD')      AS TT2        FROM              glucose gl_3 " +
            //                  "  WHERE          (TIME_IDX = 3)) a_2 ON a_2.TT2 = format(gl.TestTime,    'YYYY-MM-DD')) LEFT OUTER JOIN " +
            //                "  (SELECT         GlucoseData AS GD3, format(TestTime, 'YYYY-MM-DD')          AS TT3        FROM              glucose gl_4 " +
            //                 "   WHERE          (TIME_IDX = 4)) a_3 ON a_3.TT3 = format(gl.TestTime,          'YYYY-MM-DD')) LEFT OUTER JOIN " +
            //                 " (SELECT         GlucoseData AS GD4, format(TestTime, 'YYYY-MM-DD')         AS TT4       FROM              glucose gl_5 " +
            //                 "   WHERE          (TIME_IDX = 5)) a_4 ON a_4.TT4 = format(gl.TestTime,       'YYYY-MM-DD')) LEFT OUTER JOIN " +
            //                 " (SELECT         GlucoseData AS GD5, format(TestTime, 'YYYY-MM-DD')          AS TT5           FROM              glucose gl_6 " +
            //                  "  WHERE          (TIME_IDX = 6)) a_5 ON a_5.TT5 = format(gl.TestTime,         'YYYY-MM-DD')) LEFT OUTER JOIN " +
            //                 " (SELECT         GlucoseData AS GD6, format(TestTime, 'YYYY-MM-DD')     AS TT6       FROM              glucose gl_7 " +
            //                 "   WHERE          (TIME_IDX = 7)) a_6 ON a_6.TT6 = format(gl.TestTime,  'YYYY-MM-DD')) LEFT OUTER JOIN         (SELECT         GlucoseData AS GD7, format(TestTime, 'YYYY-MM-DD')  " +
            //                  "    AS TT7    FROM    glucose gl_8    WHERE  (TIME_IDX = 8)) a_7 ON a_7.TT7 = format(gl.TestTime,   'YYYY-MM-DD')) LEFT OUTER JOIN " +
            //                 " (SELECT         GlucoseData AS GD8, format(TestTime, 'YYYY-MM-DD')     AS TT8           FROM              glucose gl_9 " +
            //                  "  WHERE          (TIME_IDX = 9)) a_8 ON a_8.TT8 = format(gl.TestTime,    'YYYY-MM-DD')) " +
            //                  "  GROUP BY  format(gl.TestTime, 'YYYY-MM-DD') " +
            //                  "  ORDER BY  format(gl.TestTime, 'YYYY-MM-DD') DESC ");



            dv  = MainModule.SetGlucoseToTimeSet();
            dv1 = MainModule.AccessDatabasesel("SELECT  format(TestTime, 'YYYY-MM-DD') AS TestT, GlucoseData,m_Event,time_IDX    FROM  glucose where  MeterID='" + alu_tp.main_1.MeterIDNo + "' ORDER BY TestTime DESC");



            int TTT1 = dv1.Count;

            int[] count1 = new int[6];
            for (int ii = 0; ii < 6; ii++)
            {
                DataSeries[ii]     = new Series();
                DataSeries2[ii]    = new Series();
                series3[ii]        = new Series();
                series4[ii]        = new Series();
                s02[ii]            = new StripLine();
                send_comm[ii]      = new comm_list();
                count1[ii]         = 0;
                BoxPlotSeries2[ii] = new Series();
                chart2_3[ii]       = new ChartArea();
                chart2_2[ii]       = new ChartArea();
            }
            for (int jj = 0; jj < dv.Count; jj++)
            {
                for (int ii = 0; ii < 6; ii++)
                {
                    string eestr = "Expr" + (ii + 1);
                    //   send_comm[ii].yValues[count1[ii]] = rand.Next(45, 95);

                    if (Convert.ToInt16(dv[jj].Row[eestr]) == 0)
                    {
                    }
                    else
                    {
                        count1[ii]++;
                    }
                    dv1.RowFilter = "TestT= '" + Convert.ToString(dv[jj].Row[0]) + "' and time_IDX='" + Convert.ToString(ii + 1) + "' and GlucoseData <> '" + Convert.ToInt16(dv[jj].Row[eestr]) + "' and GlucoseData <> '0'";
                    if (dv1.Count > 0)
                    {
                        for (int t1 = 0; t1 < dv1.Count; t1++)
                        {
                            count1[ii]++;
                        }
                    }
                }
            }
            for (int jj = 0; jj < 6; jj++)
            {
                send_comm[jj].yValues = new double[count1[jj]];
            }
            int[] count2 = new int[6];
            for (int jj = 0; jj < dv.Count; jj++)
            {
                for (int ii = 0; ii < 6; ii++)
                {
                    string eestr = "Expr" + (ii + 1);
                    //   send_comm[ii].yValues[count1[ii]] = rand.Next(45, 95);
                    if (Convert.ToInt16(dv[jj].Row[eestr]) == 0)
                    {
                    }
                    else
                    {
                        send_comm[ii].yValues[count2[ii]] = Convert.ToInt16(dv[jj].Row[eestr]);
                        count2[ii]++;
                    }

                    //  send_comm[jj].yValues[ii] = rand.Next(45, 95);

                    dv1.RowFilter = "TestT= '" + Convert.ToString(dv[jj].Row[0]) + "' and time_IDX='" + Convert.ToString(ii + 1) + "' and GlucoseData <> '" + Convert.ToInt16(dv[jj].Row[eestr]) + "' and GlucoseData <> '0'";
                    if (dv1.Count > 0)
                    {
                        for (int t1 = 0; t1 < dv1.Count; t1++)
                        {
                            send_comm[ii].yValues[count2[ii]] = Convert.ToUInt16(dv1[t1].Row["GlucoseData"]);
                            count2[ii]++;
                        }
                    }
                }
            }


            ChartArea ChartArea3 = new ChartArea();
            ChartArea ChartArea2 = new ChartArea();

            //ChartArea chart2_3 = new ChartArea();
            //ChartArea chart2_2 = new ChartArea();



            //Add the charting areas to the chart

            chart1.ChartAreas.Add(ChartArea2);
            chart1.ChartAreas.Add(ChartArea3);


            ChartArea2.Name = "Data Chart Area";
            ChartArea3.Name = "Box Plot Area";
            //ChartArea3.AlignWithChartArea = "Data Chart Area"
            ChartArea2.Position.X = 2;
            ChartArea2.Position.Y = 70;

            //     ChartArea2.AxisX.ScaleBreakStyle.Spacing = .5;
            //    ChartArea3.AxisX.ScaleBreakStyle.StartFromZero = StartFromZero.No
            //ChartArea2.AxisX.Minimum = 0.5;
            //         ChartArea2.AxisX.Maximum = 7;
            ChartArea3.Position.X = 2;
            ChartArea3.Position.Y = 3;

            //    ChartArea2.Position.Height = 92f;
            //      ChartArea2.Position.Width = 90f;
            //  ChartArea3.Position.Height = 92f;
            //   ChartArea3.Position.Width = 90f;
            //     ChartArea2.BackImageTransparentColor = System.Drawing.Color.White;
            ChartArea3.Position.Height = 92f;
            ChartArea3.Position.Width  = 90f;
            ChartArea3.AxisX.ScaleBreakStyle.Spacing = .5;
            //    ChartArea3.AxisX.ScaleBreakStyle.StartFromZero = StartFromZero.No
            ChartArea3.AxisX.Minimum = 0.5;
            ChartArea3.AxisX.Maximum = 7;


            //  BackGradientStyle = "VerticalCenter"
            //   ChartArea3.ShadowColor = Drawing.Color.Cyan
            //  ChartArea3.BackSecondaryColor = Drawing.Color.FromArgb(128, 255, 255)
            //  ChartArea3.BorderColor = Drawing.Color.Black

            for (int ii = 0; ii < 6; ii++)
            {
                if (ii == 0)
                {
                    chart2.ChartAreas.Add(chart2_2[ii]); chart2.ChartAreas.Add(chart2_3[ii]);
                }
                else if (ii == 1)
                {
                    chart3.ChartAreas.Add(chart2_2[ii]); chart3.ChartAreas.Add(chart2_3[ii]);
                }
                else if (ii == 2)
                {
                    chart4.ChartAreas.Add(chart2_2[ii]); chart4.ChartAreas.Add(chart2_3[ii]);
                }
                else if (ii == 3)
                {
                    chart5.ChartAreas.Add(chart2_2[ii]); chart5.ChartAreas.Add(chart2_3[ii]);
                }
                else if (ii == 4)
                {
                    chart6.ChartAreas.Add(chart2_2[ii]); chart6.ChartAreas.Add(chart2_3[ii]);
                }
                else if (ii == 5)
                {
                    chart7.ChartAreas.Add(chart2_2[ii]); chart7.ChartAreas.Add(chart2_3[ii]);
                }

                //  chart2.ChartAreas.Add(chart2_2);
                //   chart2.ChartAreas.Add(chart2_3);

                chart2_2[ii].Name            = "Data Chart Area" + (ii + 1);
                chart2_3[ii].Name            = "Box Plot Area" + (ii + 1);
                chart2_2[ii].Position.X      = 2;
                chart2_2[ii].Position.Y      = 4;
                chart2_3[ii].Position.X      = 60;
                chart2_3[ii].Position.Y      = 4;
                chart2_2[ii].Position.Height = 92f;
                chart2_2[ii].Position.Width  = 55f;
                chart2_3[ii].Position.Height = 92f;
                chart2_3[ii].Position.Width  = 30f;
                chart2_3[ii].AxisX.ScaleBreakStyle.Spacing = .5;
                chart2_3[ii].AxisX.Minimum = 0.5;
                chart2_3[ii].AxisX.Maximum = 1.5;
                chart2_2[ii].AxisY.Maximum = 600;
                chart2_3[ii].AxisY.Maximum = 600;
            }



            for (int jj = 0; jj < 6; jj++)
            {
                series3[jj].Name             = "BoxPlotLabels" + jj;
                series3[jj].ChartArea        = "Box Plot Area";
                series3[jj].ChartType        = SeriesChartType.Point;
                series3[jj].CustomProperties = "LabelStyle=Right";
                series3[jj].Font             = new System.Drawing.Font("Microsoft Sans Serif", 7F);
                series3[jj].Legend           = "Default";

                series4[jj].Name             = "BoxPlotLabel" + jj;
                series4[jj].ChartArea        = "Box Plot Area" + (jj + 1);
                series4[jj].ChartType        = SeriesChartType.Point;
                series4[jj].CustomProperties = "LabelStyle=Right";
                series4[jj].Font             = new System.Drawing.Font("Microsoft Sans Serif", 7F);
                series4[jj].Legend           = "Default";
            }
            for (int jj = 0; jj < 6; jj++)
            {
                DataPoint dataPoint1 = new DataPoint(1 + jj, 0);
                DataPoint dataPoint2 = new DataPoint(1 + jj, 0);
                DataPoint dataPoint3 = new DataPoint(1 + jj, 0);
                DataPoint dataPoint4 = new DataPoint(1 + jj, 0);
                DataPoint dataPoint5 = new DataPoint(1 + jj, 0);
                DataPoint dataPoint6 = new DataPoint(1 + jj, 0);
                DataPoint dataPoint7 = new DataPoint(1 + jj, 0);
                DataPoint dataPoint8 = new DataPoint(1 + jj, 0);
                dataPoint1.Color = System.Drawing.Color.Transparent;
                dataPoint2.Color = System.Drawing.Color.Transparent;
                dataPoint3.Color = System.Drawing.Color.Transparent;
                dataPoint4.Color = System.Drawing.Color.Transparent;
                dataPoint5.Color = System.Drawing.Color.Transparent;
                dataPoint6.Color = System.Drawing.Color.Transparent;
                dataPoint7.Color = System.Drawing.Color.Transparent;
                dataPoint8.Color = System.Drawing.Color.Transparent;

                series3[jj].Points.Add(dataPoint1);
                series3[jj].Points.Add(dataPoint2);
                series3[jj].Points.Add(dataPoint3);
                series3[jj].Points.Add(dataPoint4);
                series3[jj].Points.Add(dataPoint5);
                series3[jj].Points.Add(dataPoint6);
                series3[jj].Points.Add(dataPoint7);
                series3[jj].Points.Add(dataPoint8);
                series3[jj].SmartLabelStyle.Enabled = false;


                dataPoint1_1[jj] = new DataPoint(1.1, 0);//位置1,0
                dataPoint2_1[jj] = new DataPoint(1.1, 0);
                dataPoint3_1[jj] = new DataPoint(1.1, 0);
                dataPoint4_1[jj] = new DataPoint(1.1, 0);
                dataPoint5_1[jj] = new DataPoint(1.1, 0);
                dataPoint6_1[jj] = new DataPoint(1.1, 0);
                dataPoint7_1[jj] = new DataPoint(1.1, 0);
                dataPoint8_1[jj] = new DataPoint(1.1, 0);

                dataPoint1_1[jj].Color = System.Drawing.Color.Transparent;
                dataPoint2_1[jj].Color = System.Drawing.Color.Transparent;
                dataPoint3_1[jj].Color = System.Drawing.Color.Transparent;
                dataPoint4_1[jj].Color = System.Drawing.Color.Transparent;
                dataPoint5_1[jj].Color = System.Drawing.Color.Transparent;
                dataPoint6_1[jj].Color = System.Drawing.Color.Transparent;
                dataPoint7_1[jj].Color = System.Drawing.Color.Transparent;
                dataPoint8_1[jj].Color = System.Drawing.Color.Transparent;

                series4[jj].Points.Add(dataPoint1_1[jj]);
                series4[jj].Points.Add(dataPoint2_1[jj]);
                series4[jj].Points.Add(dataPoint3_1[jj]);
                series4[jj].Points.Add(dataPoint4_1[jj]);
                series4[jj].Points.Add(dataPoint5_1[jj]);
                series4[jj].Points.Add(dataPoint6_1[jj]);
                series4[jj].Points.Add(dataPoint7_1[jj]);
                series4[jj].Points.Add(dataPoint8_1[jj]);
                series4[jj].SmartLabelStyle.Enabled = false;
            }

            for (int jj = 0; jj < 6; jj++)
            {
                DataSeries[jj].Name      = "DataSeries" + jj;
                DataSeries[jj].ChartType = SeriesChartType.Point;
                DataSeries[jj].ChartArea = "Data Chart Area";
                //   DataSeries[jj].ChartArea = "Box Plot Area";
                ////   DataSeries[jj].IsValueShownAsLabel = false;
                //  DataSeries[jj].IsVisibleInLegend = false;
                DataSeries2[jj].Name      = "DataSeries" + jj;
                DataSeries2[jj].ChartType = SeriesChartType.Point;
                DataSeries2[jj].ChartArea = "Data Chart Area" + (jj + 1);
            }
            BoxPlotSeries.Name      = "BoxPlotSeries";
            BoxPlotSeries.ChartType = SeriesChartType.BoxPlot;
            BoxPlotSeries.ChartArea = "Box Plot Area";
            //   BoxPlotSeries.IsValueShownAsLabel = true;
            BoxPlotSeries.IsVisibleInLegend  = true;
            BoxPlotSeries.BackGradientStyle  = GradientStyle.VerticalCenter;
            BoxPlotSeries.Color              = System.Drawing.Color.Cyan;
            BoxPlotSeries.BackSecondaryColor = System.Drawing.Color.FromArgb(128, 255, 255);
            BoxPlotSeries.BorderColor        = System.Drawing.Color.Black;


            chart1.Series.Add(BoxPlotSeries);

            // Add data to Box Plot Source series.
            string datastr = "";

            for (int jj = 0; jj < 6; jj++)
            {
                chart1.Series.Add(series3[jj]);
                chart1.Series.Add(DataSeries[jj]);
                chart1.Series[DataSeries[jj].Name].Points.DataBindY(send_comm[jj].yValues);
                if (jj > 0)
                {
                    datastr = datastr + ";" + DataSeries[jj].Name;
                }
                else
                {
                    datastr = DataSeries[jj].Name;
                }
            }
            chart1.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "0";
            chart1.Series["BoxPlotSeries"]["BoxPlotSeries"]            = datastr;
            // Set whiskers 15th percentile.
            chart1.Series["BoxPlotSeries"]["BoxPlotWhiskerPerc entile"] = "10";
            // Show/Hide Average line.
            chart1.Series["BoxPlotSeries"]["BoxPlotShowAverage "] = "true";
            // Show/Hide Median line.
            chart1.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";

            // Show/Hide Unusual points.
            chart1.Series["BoxPlotSeries"]["BoxPlotShowUnusual Values"] = "true";
            //  chart1.Series("BoxPlotSeries")("PointWidth") = "0.25"
            chart1.Series["BoxPlotSeries"]["PointWidth"] = "0.25";
            chart1.Series["BoxPlotSeries"].XValueMember  = "day of week";

            //    ChartArea3.AxisX.CustomLabels.Add(0, 2, "Before breakfast");
            //  ChartArea3.AxisX.CustomLabels.Add(0, 4, "After breakfast");
            //   ChartArea3.AxisX.CustomLabels.Add(0, 6, "Before lunch");
            //   ChartArea3.AxisX.CustomLabels.Add(0, 8, "After lunch");
            //   ChartArea3.AxisX.CustomLabels.Add(0, 10, "Before dinner");
            //   ChartArea3.AxisX.CustomLabels.Add(0, 12, "After dinner");


            ChartArea3.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
            ChartArea3.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;

            //  alu_tp.main_1.TargetMaxOption = int.Parse(alu_tp.main_1.DataTargetMax[i]);
            //  alu_tp.main_1.TargetMinOption = int.Parse(alu_tp.main_1.DataTargetMin[i]);
            //   alu_tp.main_1.TargetMaxOptionp = int.Parse(alu_tp.main_1.DataTargetMaxp[i]);
            //   alu_tp.main_1.TargetMinOptionp = int.Parse(alu_tp.main_1.DataTargetMinp[i]);


            StripLine s01;

            if (alu_tp.main_1.TargetMaxOptionp.ToString().Length > 0 || alu_tp.main_1.TargetMinOptionp.ToString().Length > 0)
            {
                s01                = new StripLine();
                s01.BackColor      = Color.FromArgb(248, 199, 213);
                s01.IntervalOffset = 0;

                s01.StripWidth = 600;
                ChartArea3.AxisY.StripLines.Add(s01);

                for (int jj = 0; jj < 6; jj++)
                {
                    s01                = new StripLine();
                    s01.BackColor      = Color.FromArgb(248, 199, 213);
                    s01.IntervalOffset = 0;
                    s01.StripWidth     = 600;

                    s02[jj]                = new StripLine();
                    s02[jj].BackColor      = Color.FromArgb(248, 199, 213);
                    s02[jj].IntervalOffset = 0;
                    s02[jj].StripWidth     = 600;

                    chart2_2[jj].AxisY.StripLines.Add(s02[jj]);
                    chart2_3[jj].AxisY.StripLines.Add(s01);
                }


                s01                = new StripLine();
                s01.BackColor      = Color.FromArgb(245, 250, 189);
                s01.IntervalOffset = Convert.ToInt16(alu_tp.main_1.TargetMinOptionp);

                s01.StripWidth = Convert.ToInt16(alu_tp.main_1.TargetMaxOptionp) - s01.IntervalOffset;
                ChartArea3.AxisY.StripLines.Add(s01);

                for (int jj = 0; jj < 6; jj++)
                {
                    s01                = new StripLine();
                    s01.BackColor      = Color.FromArgb(245, 250, 189);
                    s01.IntervalOffset = Convert.ToInt16(alu_tp.main_1.TargetMinOptionp);
                    s01.StripWidth     = Convert.ToInt16(alu_tp.main_1.TargetMaxOptionp) - s01.IntervalOffset;

                    s02[jj]                = new StripLine();
                    s02[jj].BackColor      = Color.FromArgb(245, 250, 189);
                    s02[jj].IntervalOffset = Convert.ToInt16(alu_tp.main_1.TargetMinOptionp);

                    s02[jj].StripWidth = Convert.ToInt16(alu_tp.main_1.TargetMaxOptionp) - s02[jj].IntervalOffset;
                    chart2_2[jj].AxisY.StripLines.Add(s02[jj]);
                    chart2_3[jj].AxisY.StripLines.Add(s01);
                }
            }

            if (alu_tp.main_1.TargetMaxOption.ToString().Length > 0 || alu_tp.main_1.TargetMinOption.ToString().Length > 0)
            {
                s01 = new StripLine();

                s01.BackColor      = Color.FromArgb(190, 251, 210);
                s01.IntervalOffset = Convert.ToInt16(alu_tp.main_1.TargetMinOption);

                s01.StripWidth = Convert.ToInt16(alu_tp.main_1.TargetMaxOption) - s01.IntervalOffset;
                ChartArea3.AxisY.StripLines.Add(s01);
                for (int jj = 0; jj < 6; jj++)
                {
                    s01 = new StripLine();

                    s01.BackColor      = Color.FromArgb(190, 251, 210);
                    s01.IntervalOffset = Convert.ToInt16(alu_tp.main_1.TargetMinOption);
                    s01.StripWidth     = Convert.ToInt16(alu_tp.main_1.TargetMaxOption) - s01.IntervalOffset;

                    s02[jj]                = new StripLine();
                    s02[jj].BackColor      = Color.FromArgb(190, 251, 210);
                    s02[jj].IntervalOffset = Convert.ToInt16(alu_tp.main_1.TargetMinOption);

                    s02[jj].StripWidth = Convert.ToInt16(alu_tp.main_1.TargetMaxOption) - s02[jj].IntervalOffset;
                    chart2_2[jj].AxisY.StripLines.Add(s02[jj]);
                    chart2_3[jj].AxisY.StripLines.Add(s01);
                }
            }
            for (int jj = 0; jj < 6; jj++)
            {
                chart1.Series[DataSeries[jj].Name].Enabled = false;
            }

            ////////////////////////
            for (int jj = 0; jj < 6; jj++)
            {
                BoxPlotSeries2[jj].Name      = "BoxPlotSeries";
                BoxPlotSeries2[jj].ChartType = SeriesChartType.BoxPlot;
                BoxPlotSeries2[jj].ChartArea = "Box Plot Area" + (jj + 1);
                //   BoxPlotSeries.IsValueShownAsLabel = true;
                BoxPlotSeries2[jj].IsVisibleInLegend  = true;
                BoxPlotSeries2[jj].BackGradientStyle  = GradientStyle.VerticalCenter;
                BoxPlotSeries2[jj].Color              = System.Drawing.Color.Cyan;
                BoxPlotSeries2[jj].BackSecondaryColor = System.Drawing.Color.FromArgb(128, 255, 255);
                BoxPlotSeries2[jj].BorderColor        = System.Drawing.Color.Black;
                if (jj == 0)
                {
                    chart2.Series.Add(BoxPlotSeries2[jj]);
                }
                else if (jj == 1)
                {
                    chart3.Series.Add(BoxPlotSeries2[jj]);
                }
                else if (jj == 2)
                {
                    chart4.Series.Add(BoxPlotSeries2[jj]);
                }
                else if (jj == 3)
                {
                    chart5.Series.Add(BoxPlotSeries2[jj]);
                }
                else if (jj == 4)
                {
                    chart6.Series.Add(BoxPlotSeries2[jj]);
                }
                else if (jj == 5)
                {
                    chart7.Series.Add(BoxPlotSeries2[jj]);
                }
            }

            datastr = "";
            for (int jj = 0; jj < 1; jj++)
            {
                chart2.Series.Add(series4[jj]);
                chart2.Series.Add(DataSeries2[jj]);
                chart2.Series[DataSeries2[jj].Name].Points.DataBindY(send_comm[jj].yValues);
                datastr = DataSeries2[jj].Name;
            }
            chart2.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "0";
            chart2.Series["BoxPlotSeries"]["BoxPlotSeries"]            = datastr;
            // Set whiskers 15th percentile.
            chart2.Series["BoxPlotSeries"]["BoxPlotWhiskerPerc entile"] = "10";
            // Show/Hide Average line.
            chart2.Series["BoxPlotSeries"]["BoxPlotShowAverage "] = "true";
            // Show/Hide Median line.
            chart2.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";

            // Show/Hide Unusual points.
            chart2.Series["BoxPlotSeries"]["BoxPlotShowUnusual Values"] = "true";
            //  chart1.Series("BoxPlotSeries")("PointWidth") = "0.25"
            chart2.Series["BoxPlotSeries"]["PointWidth"] = "0.15";
            chart2.Series["BoxPlotSeries"].XValueMember  = "day of week";


            datastr = "";
            for (int jj = 1; jj < 2; jj++)
            {
                chart3.Series.Add(series4[jj]);
                chart3.Series.Add(DataSeries2[jj]);
                chart3.Series[DataSeries2[jj].Name].Points.DataBindY(send_comm[jj].yValues);
                datastr = DataSeries2[jj].Name;
            }
            chart3.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "0";
            chart3.Series["BoxPlotSeries"]["BoxPlotSeries"]            = datastr;
            // Se3t whiskers 15th percentile.
            chart3.Series["BoxPlotSeries"]["BoxPlotWhiskerPerc entile"] = "10";
            // Show/Hide Average line.
            chart3.Series["BoxPlotSeries"]["BoxPlotShowAverage "] = "true";
            // Show/Hide Median line.
            chart3.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";

            // Show/Hide Unusual points.
            chart3.Series["BoxPlotSeries"]["BoxPlotShowUnusual Values"] = "true";
            //  chart1.Series("BoxPlotSeries")("PointWidth") = "0.25"
            chart3.Series["BoxPlotSeries"]["PointWidth"] = "0.15";
            chart3.Series["BoxPlotSeries"].XValueMember  = "day of week";


            datastr = "";
            for (int jj = 2; jj < 3; jj++)
            {
                chart4.Series.Add(series4[jj]);
                chart4.Series.Add(DataSeries2[jj]);
                chart4.Series[DataSeries2[jj].Name].Points.DataBindY(send_comm[jj].yValues);
                datastr = DataSeries2[jj].Name;
            }
            chart4.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "0";
            chart4.Series["BoxPlotSeries"]["BoxPlotSeries"]            = datastr;
            // Se3t whiskers 15th percentile.
            chart4.Series["BoxPlotSeries"]["BoxPlotWhiskerPerc entile"] = "10";
            // Show/Hide Average line.
            chart4.Series["BoxPlotSeries"]["BoxPlotShowAverage "] = "true";
            // Show/Hide Median line.
            chart4.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";

            // Show/Hide Unusual points.
            chart4.Series["BoxPlotSeries"]["BoxPlotShowUnusual Values"] = "true";
            //  chart1.Series("BoxPlotSeries")("PointWidth") = "0.25"
            chart4.Series["BoxPlotSeries"]["PointWidth"] = "0.15";
            chart4.Series["BoxPlotSeries"].XValueMember  = "day of week";

            datastr = "";
            for (int jj = 3; jj < 4; jj++)
            {
                chart5.Series.Add(series4[jj]);
                chart5.Series.Add(DataSeries2[jj]);
                chart5.Series[DataSeries2[jj].Name].Points.DataBindY(send_comm[jj].yValues);
                datastr = DataSeries2[jj].Name;
            }
            chart5.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "0";
            chart5.Series["BoxPlotSeries"]["BoxPlotSeries"]            = datastr;
            // Se3t whiskers 15th percentile.
            chart5.Series["BoxPlotSeries"]["BoxPlotWhiskerPerc entile"] = "10";
            // Show/Hide Average line.
            chart5.Series["BoxPlotSeries"]["BoxPlotShowAverage "] = "true";
            // Show/Hide Median line.
            chart5.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";

            // Show/Hide Unusual points.
            chart5.Series["BoxPlotSeries"]["BoxPlotShowUnusual Values"] = "true";
            //  chart1.Series("BoxPlotSeries")("PointWidth") = "0.25"
            chart5.Series["BoxPlotSeries"]["PointWidth"] = "0.15";
            chart5.Series["BoxPlotSeries"].XValueMember  = "day of week";

            datastr = "";
            for (int jj = 4; jj < 5; jj++)
            {
                chart6.Series.Add(series4[jj]);
                chart6.Series.Add(DataSeries2[jj]);
                chart6.Series[DataSeries2[jj].Name].Points.DataBindY(send_comm[jj].yValues);
                datastr = DataSeries2[jj].Name;
            }
            chart6.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "0";
            chart6.Series["BoxPlotSeries"]["BoxPlotSeries"]            = datastr;
            // Se3t whiskers 15th percentile.
            chart6.Series["BoxPlotSeries"]["BoxPlotWhiskerPerc entile"] = "10";
            // Show/Hide Average line.
            chart6.Series["BoxPlotSeries"]["BoxPlotShowAverage "] = "true";
            // Show/Hide Median line.
            chart6.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";

            // Show/Hide Unusual points.
            chart6.Series["BoxPlotSeries"]["BoxPlotShowUnusual Values"] = "true";
            //  chart1.Series("BoxPlotSeries")("PointWidth") = "0.25"
            chart6.Series["BoxPlotSeries"]["PointWidth"] = "0.15";
            chart6.Series["BoxPlotSeries"].XValueMember  = "day of week";

            datastr = "";
            for (int jj = 5; jj < 6; jj++)
            {
                chart7.Series.Add(series4[jj]);
                chart7.Series.Add(DataSeries2[jj]);
                chart7.Series[DataSeries2[jj].Name].Points.DataBindY(send_comm[jj].yValues);
                datastr = DataSeries2[jj].Name;
            }
            chart7.Series["BoxPlotSeries"]["BoxPlotWhiskerPercentile"] = "0";
            chart7.Series["BoxPlotSeries"]["BoxPlotSeries"]            = datastr;
            // Se7t whiskers 15th percentile.
            chart7.Series["BoxPlotSeries"]["BoxPlotWhiskerPerc entile"] = "10";
            // Show/Hide Average line.
            chart7.Series["BoxPlotSeries"]["BoxPlotShowAverage "] = "true";
            // Show/Hide Median line.
            chart7.Series["BoxPlotSeries"]["BoxPlotShowMedian"] = "true";

            // Show/Hide Unusual points.
            chart7.Series["BoxPlotSeries"]["BoxPlotShowUnusual Values"] = "true";
            //  chart1.Series("BoxPlotSeries")("PointWidth") = "0.25"
            chart7.Series["BoxPlotSeries"]["PointWidth"] = "0.15";
            chart7.Series["BoxPlotSeries"].XValueMember  = "day of week";


            chart2_3[0].AxisX.CustomLabels.Add(0, 2, "Before breakfast");
            chart2_3[1].AxisX.CustomLabels.Add(0, 2, "After breakfast");
            chart2_3[2].AxisX.CustomLabels.Add(0, 2, "Before lunch");
            chart2_3[3].AxisX.CustomLabels.Add(0, 2, "After lunch");
            chart2_3[4].AxisX.CustomLabels.Add(0, 2, "Before dinner");
            chart2_3[5].AxisX.CustomLabels.Add(0, 2, "After dinner");

            ////////////////////////////
        }
        private void InitializeChart()
        {
            chtType = ChtRefreshType.RefreshAll;

            IniFile iniFile = new IniFile();

            iniFile.Load(IniData.SettingIniFile);
            IniSection dbSection = iniFile[DBConnect.IniSectionName];

            DBConnect  connect = new DBConnect();
            SqlCommand command = new SqlCommand();

            command.CommandText = $@"Select {dbSection["QMasTB_Code"]}, {dbSection["QMasTB_Name"]}, {dbSection["QMasTB_Min"]}, {dbSection["QMasTB_Max"]}
                                       from {dbSection["QMasTB"]}";

            DataSet       datas;
            bool          result     = connect.Search(command, out datas);
            ControlLayout ctrlLayout = new ControlLayout();

            if (!result)
            {
                Tim_Per3Sec.Enabled = false;
                return;
            }

            foreach (DataRow row in datas.Tables[0].Rows)
            {
                Tab_Data.TabPages.Add(row[0].ToString(), row[1].ToString());

                Chart cht = new Chart();
                cht.ChartAreas.Add($"{row[0].ToString()}Area");
                cht.Legends.Add(row[0].ToString());
                cht.Series.Add(row[0].ToString());
                cht.Series[row[0].ToString()].ChartType   = SeriesChartType.Line;
                cht.Series[row[0].ToString()].BorderWidth = 4;
                cht.Series[row[0].ToString()].ChartArea   = $"{row[0].ToString()}Area";
                cht.Series[row[0].ToString()].Legend      = row[0].ToString();
                cht.Series[row[0].ToString()].LegendText  = row[0].ToString();
                cht.Series[row[0].ToString()].XValueType  = ChartValueType.DateTime;
                cht.ChartAreas[$"{row[0].ToString()}Area"].AxisX.LabelStyle.Format = "HH시 mm분";

                // 품질 경계를 표시하기 위한 코드
                double min       = double.Parse(row[2].ToString());
                double max       = double.Parse(row[3].ToString());
                double minborder = (min * 1.5) - (max * 0.5);
                double maxborder = (max * 1.5) - (min * 0.5);
                cht.ChartAreas[$"{row[0].ToString()}Area"].AxisY.Minimum  = minborder;
                cht.ChartAreas[$"{row[0].ToString()}Area"].AxisY.Maximum  = maxborder;
                cht.ChartAreas[$"{row[0].ToString()}Area"].AxisY.Interval = (max - min) * 0.5;
                StripLine line = new StripLine();
                line.Interval       = 0;
                line.StripWidth     = (max - min) * 0.5;
                line.BackColor      = Color.Salmon;
                line.IntervalOffset = minborder;
                StripLine line2 = new StripLine();
                line2.Interval       = 0;
                line2.StripWidth     = (max - min) * 0.5;
                line2.BackColor      = Color.Salmon;
                line2.IntervalOffset = max;
                cht.ChartAreas[$"{row[0].ToString()}Area"].AxisY.StripLines.Add(line);
                cht.ChartAreas[$"{row[0].ToString()}Area"].AxisY.StripLines.Add(line2);

                //cht.ChartAreas[$"{row[0].ToString()}Area"].AxisX.IntervalType = DateTimeIntervalType.Seconds;
                //cht.ChartAreas[$"{row[0].ToString()}Area"].AxisX.Interval = 3;
                ctrlLayout.Control_Sizing(cht, this.Size, 0.5f, 0.3f);
                Tab_Data.TabPages[row[0].ToString()].Controls.Add(cht);
            }
        }
Ejemplo n.º 17
0
        protected void PreparePlot()
        {
            string[] specArray = this.specArray;
            double   specRound = Math.Round(2 * Double.Parse(this.specArray[1]), 2);

            var chart = new Chart
            {
                Size               = new System.Drawing.Size(this.plotSizeX, this.plotSizeY),
                BackColor          = Color.Gray,
                BackSecondaryColor = Color.WhiteSmoke,
                BackGradientStyle  = GradientStyle.DiagonalRight,
                BorderSkin         = { SkinStyle = BorderSkinStyle.Emboss }
            };

            var area = new ChartArea();

            chart.ChartAreas.Add(area);

            chart.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
            chart.ChartAreas[0].AxisY.MajorGrid.Enabled = true;

            chart.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.LightGray;
            chart.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.LightGray;

            chart.ChartAreas[0].BackColor = Color.GhostWhite;

            // strip for upper limit
            var limitUpperStrip = new StripLine
            {
                Interval        = 0,
                IntervalOffset  = double.Parse(specArray[1]),
                StripWidth      = 0.00005,
                BorderDashStyle = ChartDashStyle.Dash,
                BackColor       = Color.FromArgb(150, Color.Red),
                //Text = "Spec limit"
            };

            chart.ChartAreas[0].AxisY.StripLines.Add(limitUpperStrip);

            // strip for lower limit
            var limitLowerStrip = new StripLine
            {
                Interval        = 0,
                IntervalOffset  = -double.Parse(specArray[1]),
                StripWidth      = 0.00005,
                BorderDashStyle = ChartDashStyle.Dash,
                BackColor       = Color.FromArgb(150, Color.Red),
                //Text = "Spec limit"
            };

            chart.ChartAreas[0].AxisY.StripLines.Add(limitLowerStrip);

            //chart.ChartAreas[0].AxisX.MajorGrid.Interval = 1;

            chart.ChartAreas[0].AxisY.Minimum = -specRound;
            chart.ChartAreas[0].AxisY.Maximum = specRound;

            chart.ChartAreas[0].AxisX.Title = "Temperature, C";
            chart.ChartAreas[0].AxisY.Title = "Frequency, ppm";

            this.chartImage = chart;
        }
Ejemplo n.º 18
0
        private void InitialChart()
        {
            chart1.ChartAreas.Add("Base");
            chart1.Series.Add("DepthD");
            chart1.Series.Add("FlowU");
            chart1.Series.Add("FlowV");

            ChartArea myArea    = chart1.ChartAreas["Base"];
            Series    mySeriesD = chart1.Series["DepthD"];
            Series    mySeriesU = chart1.Series["FlowU"];
            Series    mySeriesV = chart1.Series["FlowV"];

            mySeriesD.LegendText = "水深d誤差";
            mySeriesU.LegendText = "流速u誤差";
            mySeriesV.LegendText = "流速v誤差";

            myArea.AxisX.MajorGrid.LineColor = Color.Transparent; // X軸的刻度 縱線
            myArea.AxisY.MajorGrid.LineColor = Color.LightGray;   // Y軸的刻度 橫線
            myArea.AxisY.IntervalAutoMode    = IntervalAutoMode.VariableCount;
            myArea.AxisY.IsLabelAutoFit      = false;

            myArea.AxisY.IsLogarithmic = true;
            myArea.AxisY.LogarithmBase = 10.0;
            myArea.AxisY.Minimum       = 1.0E-6;
            myArea.AxisY.Maximum       = 1000.0;

            myArea.AxisY.Title = "error";
            myArea.AxisX.Title = "疊代次數";

            myArea.AxisX.IntervalAutoMode   = IntervalAutoMode.VariableCount;
            myArea.AxisX.IntervalOffsetType = DateTimeIntervalType.Auto;
            myArea.AxisX.Minimum            = 0.0;
            myArea.AxisX.Maximum            = 500.0;

            // 設定平均值的 Line
            if (RiverSimulationProfile.profile.waterModelingConvergenceCriteria2d != 0.0)
            {
                StripLine lineMean = new StripLine();

                lineMean.Text               = "收斂值 : " + RiverSimulationProfile.profile.waterModelingConvergenceCriteria2d.ToString();
                lineMean.BorderColor        = Color.Red; // 線條的顏色
                lineMean.BorderDashStyle    = ChartDashStyle.Dash;
                lineMean.BorderWidth        = 1;
                lineMean.IntervalOffsetType = DateTimeIntervalType.Auto;
                //lineMean.Interval = RiverSimulationProfile.profile.convergenceCriteria2d;
                lineMean.IntervalOffset = Math.Log10(RiverSimulationProfile.profile.waterModelingConvergenceCriteria2d);
                myArea.AxisY.StripLines.Add(lineMean);
            }

            // mySeriesD.ChartType = SeriesChartType.Spline;        // 曲線圖
            mySeriesD.ChartType           = SeriesChartType.Line;   // 曲線圖
            mySeriesD.Color               = Color.Blue;             // 在圖型上的顏色
            mySeriesD.BorderWidth         = 1;                      // 線型的寬度
            mySeriesD.ShadowColor         = Color.Transparent;      // 陰影的顏色
            mySeriesD.ShadowOffset        = 2;                      // 陰影位置的角度
            mySeriesD.MarkerStyle         = MarkerStyle.None;       // 標記的樣式 (Circle, Diamond ...)
            mySeriesD.IsValueShownAsLabel = false;                  // 將 Y 值顯示在標記符號旁邊

            mySeriesU.ChartType           = SeriesChartType.Spline; // 曲線圖
            mySeriesU.Color               = Color.Orange;           // 在圖型上的顏色
            mySeriesU.BorderWidth         = 1;                      // 線型的寬度
            mySeriesU.ShadowColor         = Color.Transparent;      // 陰影的顏色
            mySeriesU.ShadowOffset        = 2;                      // 陰影位置的角度
            mySeriesU.MarkerStyle         = MarkerStyle.None;       // 標記的樣式 (Circle, Diamond ...)
            mySeriesU.IsValueShownAsLabel = false;                  // 將 Y 值顯示在標記符號旁邊

            mySeriesV.ChartType           = SeriesChartType.Spline; // 曲線圖
            mySeriesV.Color               = Color.Green;            // 在圖型上的顏色
            mySeriesV.BorderWidth         = 1;                      // 線型的寬度
            mySeriesV.ShadowColor         = Color.Transparent;      // 陰影的顏色
            mySeriesV.ShadowOffset        = 2;                      // 陰影位置的角度
            mySeriesV.MarkerStyle         = MarkerStyle.None;       // 標記的樣式 (Circle, Diamond ...)
            mySeriesV.IsValueShownAsLabel = false;                  // 將 Y 值顯示在標記符號旁邊
        }
        private void chart1_PrePaint(object sender, System.Windows.Forms.DataVisualization.Charting.ChartPaintEventArgs e)
        {
            if (e.ChartElement is Chart)
            {
                // Position point chart type series on the points of the box plot to display labels
                chart1.Series["BoxPlotLabels"].Points[0].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[0];
                chart1.Series["BoxPlotLabels"].Points[1].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[1];
                chart1.Series["BoxPlotLabels"].Points[2].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[2];
                chart1.Series["BoxPlotLabels"].Points[3].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[3];
                chart1.Series["BoxPlotLabels"].Points[4].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[4];
                chart1.Series["BoxPlotLabels"].Points[5].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[5];

                chart1.Series["BoxPlotLabels"].Points[6].Label = "";
                chart1.Series["BoxPlotLabels"].Points[7].Label = "";
                if (checkBoxShowUnusual.Checked)
                {
                    if (chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 6)
                    {
                        chart1.Series["BoxPlotLabels"].Points[6].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[6] - 3;
                        chart1.Series["BoxPlotLabels"].Points[6].Label      = "Unusual data point";
                    }
                    if (chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 8)
                    {
                        chart1.Series["BoxPlotLabels"].Points[7].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[8] + 3;
                        chart1.Series["BoxPlotLabels"].Points[7].Label      = "Unusual data point";
                    }
                    else if (chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 7)
                    {
                        chart1.Series["BoxPlotLabels"].Points[7].YValues[0] = chart1.Series["BoxPlotSeries"].Points[0].YValues[7] + 3;
                        chart1.Series["BoxPlotLabels"].Points[7].Label      = "Unusual data point";
                    }
                }


                // Define labels
                int whiskerPercentile = (3 - comboBoxPercentiles.SelectedIndex) * 5;
                chart1.Series["BoxPlotLabels"].Points[0].Label = whiskerPercentile.ToString() + "th Percentile";
                chart1.Series["BoxPlotLabels"].Points[1].Label = (100 - whiskerPercentile).ToString() + "th Percentile";
                if (whiskerPercentile == 0)
                {
                    chart1.Series["BoxPlotLabels"].Points[0].Label = "Minimum";
                    chart1.Series["BoxPlotLabels"].Points[1].Label = "Maximum";
                }
                chart1.Series["BoxPlotLabels"].Points[2].Label = "25th Percentile (LQ)";
                chart1.Series["BoxPlotLabels"].Points[3].Label = "75th Percentile (UQ)";
                chart1.Series["BoxPlotLabels"].Points[4].Label = (checkBoxShowAverage.Checked) ? "Average/Mean" : "";
                chart1.Series["BoxPlotLabels"].Points[5].Label = (checkBoxShowMedian.Checked) ? "Median" : "";

                // Add strip lines
                chart1.ChartAreas["Data Chart Area"].AxisY.StripLines.Clear();
                StripLine stripLine = new StripLine();
                stripLine.BackColor         = Color.FromArgb(60, 252, 180, 65);
                stripLine.IntervalOffset    = chart1.Series["BoxPlotLabels"].Points[2].YValues[0];
                stripLine.StripWidth        = chart1.Series["BoxPlotLabels"].Points[3].YValues[0] - stripLine.IntervalOffset;
                stripLine.Text              = "data points\n50% of";
                stripLine.Font              = new Font("Microsoft Sans Serif", 7);
                stripLine.TextOrientation   = TextOrientation.Rotated270;
                stripLine.TextLineAlignment = StringAlignment.Center;
                stripLine.TextAlignment     = StringAlignment.Near;
                chart1.ChartAreas["Data Chart Area"].AxisY.StripLines.Add(stripLine);

                stripLine                   = new StripLine();
                stripLine.BackColor         = Color.FromArgb(60, 252, 180, 65);
                stripLine.IntervalOffset    = chart1.Series["BoxPlotLabels"].Points[0].YValues[0];
                stripLine.StripWidth        = chart1.Series["BoxPlotLabels"].Points[1].YValues[0] - stripLine.IntervalOffset;
                stripLine.ForeColor         = Color.FromArgb(120, Color.Black);
                stripLine.Text              = (100 - whiskerPercentile * 2).ToString() + "% of data points";
                stripLine.Font              = new Font("Microsoft Sans Serif", 7);
                stripLine.TextOrientation   = TextOrientation.Rotated270;
                stripLine.TextLineAlignment = StringAlignment.Center;
                chart1.ChartAreas["Data Chart Area"].AxisY.StripLines.Add(stripLine);
            }
        }
Ejemplo n.º 20
0
        public frmMain()
        {
            InitializeComponent();
            Connected         = false;
            this.FormClosing += new FormClosingEventHandler(Form_Closing);
            TestDataEvent    += BQConn.QueueData;
            Directory.CreateDirectory("logs");
            Directory.CreateDirectory("backupData");
            _commWorker.DoWork += RunCommMachine;
            _commWorker.WorkerReportsProgress = true;
            _commWorker.ProgressChanged      += UpdateUi;
            _commWorker.RunWorkerAsync();

            _TDKWorker.DoWork             += RunCurrentCycling;
            _TDKWorker.RunWorkerCompleted += CyclingComplete;

            _arduinoWorker.DoWork += RunArduinoLoop;
            _arduinoWorker.WorkerReportsProgress = true;
            _arduinoWorker.ProgressChanged      += UpdateHeartBeat;
            _arduinoWorker.RunWorkerAsync();

            _connectionWorker.DoWork             += CheckConnect;
            _connectionWorker.RunWorkerCompleted += ConnectComplete;

            _cycling.NewCoreCommand += NewCoreCommand;
            _arduino.NewCoreCommand += NewCoreCommand;


            _refSmokes = new List <double> {
                10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000
            };
            _smokeLevel = new List <double> {
                0, 0, 0, 0, 0, 0, 0, 0
            };
            _TDKconnection = new List <bool> {
                false, false, false, false, false, false,
                false, false, false, false, false, false,
            };
            _samples = new List <Label> {
                lblSample1, lblSample2, lblSample3, lblSample4,
                lblSample5, lblSample6, lblSample7, lblSample8, lblSample9, lblSample10, lblSample11, lblSample12
            };
            _checkBoxes = new List <CheckBox> {
                chkbxPort1, chkbxPort2, chkbxPort3,
                chkbxPort4, chkbxPort5, chkbxPort6, chkbxPort7, chkbxPort8, chkbxPort9,
                chkbxPort10, chkbxPort11, chkbxPort12
            };
            _setCurrents = new List <TextBox> {
                txtSetCurr1, txtSetCurr2, txtSetCurr3,
                txtSetCurr4, txtSetCurr5, txtSetCurr6, txtSetCurr7, txtSetCurr8, txtSetCurr9,
                txtSetCurr10, txtSetCurr11, txtSetCurr12
            };
            _tempSensors = new List <TextBox> {
                txtTempSensSample1, txtTempSensSample2,
                txtTempSensSample3, txtTempSensSample4, txtTempSensSample5, txtTempSensSample6,
                txtTempSensSample7, txtTempSensSample8, txtTempSensSample9,
                txtTempSensSample10, txtTempSensSample11, txtTempSensSample12
            };
            //_tempLabels = new List<Label> { labelTemp1, labelTemp2,
            //labelTemp3,labelTemp4,labelTemp5,labelTemp6,
            //labelTemp7,labelTemp8,labelTemp9,labelTemp10,
            //labelTemp11,labelTemp12, labelTemp13, labelTemp14, labelTemp15, labelTemp16};
            //_smokeLabels = new List<Label> { labelSmoke1, labelSmoke2,
            //labelSmoke3,labelSmoke4,labelSmoke5,labelSmoke6,
            //labelSmoke7,labelSmoke8};
            _voltageLabels = new List <Label> {
                lblVoltage1, lblVoltage2, lblVoltage3,
                lblVoltage4, lblVoltage5, lblVoltage6, lblVoltage7, lblVoltage8, lblVoltage9,
                lblVoltage10, lblVoltage11, lblVoltage12
            };
            _currentLabels = new List <Label> {
                lblCurrent1, lblCurrent2, lblCurrent3,
                lblCurrent4, lblCurrent5, lblCurrent6, lblCurrent7, lblCurrent8, lblCurrent9,
                lblCurrent10, lblCurrent11, lblCurrent12
            };
            _cycleLabels = new List <Label> {
                lblCycle1, lblCycle2, lblCycle3,
                lblCycle4, lblCycle5, lblCycle6, lblCycle7, lblCycle8, lblCycle9,
                lblCycle10, lblCycle11, lblCycle12
            };
            _connectedLabels = new List <Label> {
                lblPSStatus1, lblPSStatus2, lblPSStatus3,
                lblPSStatus4, lblPSStatus5, lblPSStatus6, lblPSStatus7, lblPSStatus8, lblPSStatus9,
                lblPSStatus10, lblPSStatus11, lblPSStatus12
            };
            _loadButtons = new List <Button> {
                btnLoad1, btnLoad2, btnLoad3, btnLoad4,
                btnLoad5, btnLoad6, btnLoad7, btnLoad8, btnLoad9, btnLoad10, btnLoad11, btnLoad12
            };
            //_newButtons = new List<Button> { btnNew1, btnNew2, btnNew3 , btnNew4 ,
            //btnNew5,btnNew6,btnNew7,btnNew8,btnNew9,btnNew10,btnNew11,btnNew12};
            _voc = new List <TextBox> {
                txtVoc1, txtVoc2, txtVoc3, txtVoc4, txtVoc5,
                txtVoc6, txtVoc7, txtVoc8, txtVoc9, txtVoc10, txtVoc11, txtVoc12
            };
            _numCells = new List <TextBox> {
                txtNumCells1, txtNumCells2, txtNumCells3,
                txtNumCells4, txtNumCells5, txtNumCells6, txtNumCells7, txtNumCells8, txtNumCells9
                , txtNumCells10, txtNumCells11, txtNumCells12
            };

            // reload default settings to GUI
            txtOperator.Text       = Properties.Settings.Default.Operator;
            txtBiasOn.Text         = Properties.Settings.Default.BiasON;
            txtBiasOff.Text        = Properties.Settings.Default.BiasOFF;
            txtCurrOnTempSet.Text  = Properties.Settings.Default.BiasONTempSet;
            txtCurrOffTempSet.Text = Properties.Settings.Default.BiasOFFTempSet;
            txtOverTempSet.Text    = Properties.Settings.Default.OverTempSet;
            txtSmokeOverSet.Text   = Properties.Settings.Default.OverSmokeSet;
            txtPauseFans.Text      = Properties.Settings.Default.PauseFanTime;
            if (Properties.Settings.Default.CheckBoxes != null)
            {
                var iii  = 0;
                var chks = Properties.Settings.Default.CheckBoxes;
                foreach (var chk in _checkBoxes)
                {
                    chk.Checked = chks[iii];
                    iii++;
                }
            }
            else
            {
                Properties.Settings.Default.CheckBoxes = new List <bool> {
                    false, false, false, false, false, false, false, false, false, false, false, false
                };
            }
            if (Properties.Settings.Default.ActiveTemps != null)
            {
                var temps = chkTemp.Items;
                var ii    = 0;
                foreach (var temp in Properties.Settings.Default.ActiveTemps)
                {
                    chkTemp.SetItemChecked(temps.IndexOf(temps[ii]), temp);
                    ii++;
                }
            }
            else
            {
                Properties.Settings.Default.ActiveTemps = new List <bool> {
                    false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
                };
            }
            if (Properties.Settings.Default.ActiveSmokes != null)
            {
                var smokes = chkSmoke.Items;
                var ii     = 0;
                foreach (var smoke in Properties.Settings.Default.ActiveSmokes)
                {
                    chkSmoke.SetItemChecked(smokes.IndexOf(smokes[ii]), smoke);
                    ii++;
                }
            }
            else
            {
                Properties.Settings.Default.ActiveSmokes = new List <bool> {
                    false, false, false, false, false, false, false, false
                };
            }
            if (Properties.Settings.Default.Samples == null)
            {
                Properties.Settings.Default.Samples = new List <string> {
                    null, null, null, null, null, null, null, null, null, null, null, null
                };
                btnLoadSamples.Enabled = false;
            }
            Properties.Settings.Default.Save();

            // set TDK rows to disabled until the connnection is good
            EnableTDKRows();

            // initialize TDK objects
            _TDKS = new List <TDK> {
            };
            for (int j = 1; j < 13; j++)
            {
                _TDKS.Add(new TDK("0" + j, j));
            }

            // initialize heartbeatpacket before arduino declarations
            string tempBin = "";

            foreach (object chk in chkTemp.Items)
            {
                tempBin += GetBinary(chkTemp.GetItemChecked(chkTemp.Items.IndexOf(chk)));
            }
            string smokeBin = "";

            foreach (object chk in chkSmoke.Items)
            {
                smokeBin += GetBinary(chkTemp.GetItemChecked(chkTemp.Items.IndexOf(chk)));
            }
            _heartBeatPacket = new TransmitPacket(txtOverTempSet.Text, txtSmokeOverSet.Text,
                                                  txtCurrOnTempSet.Text, txtCurrOffTempSet.Text, "0", "0", tempBin, smokeBin, "0");

            // initialize temp/smoke graphs
            chartTemp.ChartAreas["ChartArea1"].AxisY.Maximum = double.Parse(txtOverTempSet.Text) + 30;
            chartTemp.ChartAreas["ChartArea1"].AxisY.StripLines.Clear();
            StripLine stripline = new StripLine();

            stripline.Interval       = 0;
            stripline.IntervalOffset = double.Parse(txtOverTempSet.Text);
            stripline.StripWidth     = 3;
            stripline.BackColor      = Color.Red;
            chartTemp.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripline);
            var i = 1;

            foreach (object chk in chkTemp.Items)
            {
                if (chkTemp.GetItemChecked(chkTemp.Items.IndexOf(chk)))
                {
                    var y = 25;
                    chartTemp.Series["Temp"].Points.AddXY(i, y);
                    i++;
                }
            }
            chartSmoke.ChartAreas["ChartArea1"].AxisY.Maximum = double.Parse(txtSmokeOverSet.Text) + 1;
            chartSmoke.ChartAreas["ChartArea1"].AxisY.StripLines.Clear();
            stripline                = new StripLine();
            stripline.Interval       = 0;
            stripline.IntervalOffset = double.Parse(txtSmokeOverSet.Text);
            stripline.StripWidth     = 3;
            stripline.BackColor      = Color.Red;
            chartSmoke.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripline);
            i = 1;
            foreach (object chk in chkSmoke.Items)
            {
                if (chkSmoke.GetItemChecked(chkSmoke.Items.IndexOf(chk)))
                {
                    var y = 25;
                    chartSmoke.Series["Smoke Level"].Points.AddXY(i, y);
                    i++;
                }
            }

            // wait until arduino is connected to start connecting TDKs
            //#if !DEBUG
            //while (!Connected) { }
            Thread.Sleep(6000);
            //#endif
            _arduinoWorker.ReportProgress(1);
            _connectionWorker.RunWorkerAsync();
            U.Logger.WriteLine($"Checking TDK connections");
            btnStart.Enabled           = false;
            btnCheckConnection.Enabled = false;

#if DEBUG
            var timer = new System.Timers.Timer();
            timer.Elapsed += OnTimedEvent;
            timer.Interval = 1000;
            timer.Start();
#endif
        }
Ejemplo n.º 21
0
        private void UpdateUi(object sender, ProgressChangedEventArgs e)
        {
            try {
                // update TDK readings during Cycling
                if (e.ProgressPercentage == 5)
                {
                    var args = _cycling._args;
                    if (args.Closing)
                    {
                        labelCount.Text    = $@"00:00";
                        lblBiasStatus.Text = _cycling.BIASON ? "BIAS ON" : "BIAS OFF";
                    }
                    else
                    {
                        var ts = (args.CycleTime - DateTime.Now);
                        labelCount.Text    = $@"{ts.Minutes:D2}:{ts.Seconds:D2}";
                        lblBiasStatus.Text = _cycling.BIASON ? "BIAS ON" : "BIAS OFF";
                    }
                    _voltageLabels[args.Port - 1].Text = args.Volt;
                    _currentLabels[args.Port - 1].Text = args.Current;
                    _cycleLabels[args.Port - 1].Text   = args.Cycle;
                    return;
                }
                // re-enable GUI buttons
                else if (e.ProgressPercentage == 1)
                {
                    EnableTDKRows();
                    btnStart.Enabled           = true;
                    chkTemp.Enabled            = true;
                    chkSmoke.Enabled           = true;
                    btnCheckConnection.Enabled = true;
                    btnLoadSamples.Enabled     = true;
                    btnClearSamples.Enabled    = true;
                    buttonClearAlarms.Enabled  = true;
                    return;
                }
                // update temp/smoke/alarm readings
                else if (e.ProgressPercentage == 2)
                {
                    var ardArgs = _arduino._recievedPacket;

                    var i = 0;
                    chartTemp.ChartAreas["ChartArea1"].AxisY.Maximum = double.Parse(txtOverTempSet.Text) + double.Parse(txtOverTempSet.Text) / 10;
                    chartTemp.ChartAreas["ChartArea1"].AxisY.StripLines.Clear();
                    StripLine stripline = new StripLine();
                    stripline.Interval       = 0;
                    stripline.IntervalOffset = double.Parse(txtOverTempSet.Text);
                    stripline.StripWidth     = stripline.IntervalOffset / 70;
                    stripline.BackColor      = Color.Red;
                    chartTemp.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripline);
                    chartTemp.Series["Temp"].Points.Clear();
                    foreach (object chk in chkTemp.Items)
                    {
                        if (chkTemp.GetItemChecked(chkTemp.Items.IndexOf(chk)))
                        {
                            var y = ardArgs.TempList[i];
                            chartTemp.Series["Temp"].Points.AddXY(chkTemp.Items.IndexOf(chk) + 1, y);
                            i++;
                        }
                    }
                    i = 0;
                    chartSmoke.ChartAreas["ChartArea1"].AxisY.Maximum = double.Parse(txtSmokeOverSet.Text) + double.Parse(txtSmokeOverSet.Text) / 10;
                    chartSmoke.ChartAreas["ChartArea1"].AxisY.StripLines.Clear();
                    stripline                = new StripLine();
                    stripline.Interval       = 0;
                    stripline.IntervalOffset = double.Parse(txtSmokeOverSet.Text);
                    stripline.StripWidth     = stripline.IntervalOffset / 70;
                    stripline.BackColor      = Color.Red;
                    chartSmoke.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripline);
                    chartSmoke.Series["Smoke Level"].Points.Clear();
                    foreach (object chk in chkSmoke.Items)
                    {
                        if (chkSmoke.GetItemChecked(chkSmoke.Items.IndexOf(chk)))
                        {
                            //var y = ardArgs.SmokeList[i];
                            var y = _smokeLevel[i];
                            chartSmoke.Series["Smoke Level"].Points.AddXY(chkSmoke.Items.IndexOf(chk) + 1, y);
                            i++;
                        }
                    }

                    labelTempAlarm.BackColor  = ardArgs.TempAlarm ? Color.Red : Color.Empty;
                    labelSmokeAlarm.BackColor = SMOKEALARM ? Color.Red : Color.Empty;
                    labelEMSStop.BackColor    = ardArgs.EMSSTOP ? Color.Red : Color.Empty;
                }
                // send event to arduino thread to update serial transmit packet
                else if (e.ProgressPercentage == 3)
                {
                    string tempBin = "";
                    foreach (object chk in chkTemp.Items)
                    {
                        tempBin += GetBinary(chkTemp.GetItemChecked(chkTemp.Items.IndexOf(chk)));
                    }
                    string smokeBin = "";
                    foreach (object chk in chkSmoke.Items)
                    {
                        smokeBin += GetBinary(chkSmoke.GetItemChecked(chkSmoke.Items.IndexOf(chk)));
                    }
                    string biasON = _cycling.BIASON ? "1" : "0";
                    if (_TDKWorker.IsBusy)
                    {
                        Cycling = "1";
                    }
                    _heartBeatPacket = new TransmitPacket(txtOverTempSet.Text, txtSmokeOverSet.Text,
                                                          txtCurrOnTempSet.Text, txtCurrOffTempSet.Text, biasON, "0", tempBin, smokeBin, Cycling);
                    _arduinoWorker.ReportProgress(1);
                }
                // update connection strings from connection worker
                else if (e.ProgressPercentage == 4)
                {
                    var res = (List <string>)e.UserState;
                    int i   = 0;
                    foreach (string str in res)
                    {
                        _connectedLabels[i].Text = str;
                        i++;
                    }
                    EnableTDKRows();
                    btnCheckConnection.Enabled = true;
                    btnStart.Enabled           = true;
                }
                // update smoke/temp charts TESTING
                else if (e.ProgressPercentage == 6)
                {
                    chartTemp.ChartAreas["ChartArea1"].AxisY.Maximum = double.Parse(txtOverTempSet.Text) + double.Parse(txtOverTempSet.Text) / 10;
                    chartTemp.ChartAreas["ChartArea1"].AxisY.StripLines.Clear();
                    StripLine stripline = new StripLine();
                    stripline.Interval       = 0;
                    stripline.IntervalOffset = double.Parse(txtOverTempSet.Text);
                    stripline.StripWidth     = stripline.IntervalOffset / 70;
                    stripline.BackColor      = Color.Red;
                    chartTemp.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripline);
                    var i = 1;
                    chartTemp.Series["Temp"].Points.Clear();
                    foreach (object chk in chkTemp.Items)
                    {
                        if (chkTemp.GetItemChecked(chkTemp.Items.IndexOf(chk)))
                        {
                            chartTemp.Series["Temp"].Points.AddXY(chkTemp.Items.IndexOf(chk) + 1, yy);
                            i++;
                        }
                    }
                    chartSmoke.ChartAreas["ChartArea1"].AxisY.Maximum = double.Parse(txtSmokeOverSet.Text) + double.Parse(txtSmokeOverSet.Text) / 10;
                    chartSmoke.ChartAreas["ChartArea1"].AxisY.StripLines.Clear();
                    stripline                = new StripLine();
                    stripline.Interval       = 0;
                    stripline.IntervalOffset = double.Parse(txtSmokeOverSet.Text);
                    stripline.StripWidth     = stripline.IntervalOffset / 70;
                    stripline.BackColor      = Color.Red;
                    chartSmoke.ChartAreas["ChartArea1"].AxisY.StripLines.Add(stripline);
                    chartSmoke.Series["Smoke Level"].Points.Clear();
                    i = 1;
                    foreach (object chk in chkSmoke.Items)
                    {
                        if (chkSmoke.GetItemChecked(chkSmoke.Items.IndexOf(chk)))
                        {
                            chartSmoke.Series["Smoke Level"].Points.AddXY(chkSmoke.Items.IndexOf(chk) + 1, yy);
                            i++;
                        }
                    }
                }
            }
            catch { }
        }
Ejemplo n.º 22
0
Archivo: Model.cs Proyecto: Ring-r/opt
 } // !!!Дописать!!!
 public static Point2d Calc(StripLine strip_line, Circle circle)
 {
     return null;
 } // !!!Дописать!!!
Ejemplo n.º 23
0
        public static void SetSimplePlanStrips(List <Plan> plans, Chart Chart, DateTime StartDate,
                                               ControllerEventLogs EventLog)
        {
            var backGroundColor = 1;

            foreach (var plan in plans)
            {
                var stripline = new StripLine();
                //Creates alternating backcolor to distinguish the plans
                if (backGroundColor % 2 == 0)
                {
                    stripline.BackColor = Color.FromArgb(120, Color.LightGray);
                }
                else
                {
                    stripline.BackColor = Color.FromArgb(120, Color.LightBlue);
                }

                //Set the stripline properties
                stripline.IntervalOffsetType = DateTimeIntervalType.Hours;
                stripline.Interval           = 1;
                stripline.IntervalOffset     = (plan.StartTime - StartDate).TotalHours;
                stripline.StripWidth         = (plan.EndTime - plan.StartTime).TotalHours;
                stripline.StripWidthType     = DateTimeIntervalType.Hours;

                Chart.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripline);

                //Add a corrisponding custom label for each strip
                var Plannumberlabel = new CustomLabel();
                Plannumberlabel.FromPosition = plan.StartTime.ToOADate();
                Plannumberlabel.ToPosition   = plan.EndTime.ToOADate();
                switch (plan.PlanNumber)
                {
                case 254:
                    Plannumberlabel.Text = "Free";
                    break;

                case 255:
                    Plannumberlabel.Text = "Flash";
                    break;

                case 0:
                    Plannumberlabel.Text = "Unknown";
                    break;

                default:
                    Plannumberlabel.Text = "Plan " + plan.PlanNumber;

                    break;
                }
                Plannumberlabel.LabelMark = LabelMarkStyle.LineSideMark;
                Plannumberlabel.ForeColor = Color.Black;
                Plannumberlabel.RowIndex  = 0;

                var planPreemptsLabel = new CustomLabel();
                planPreemptsLabel.FromPosition = plan.StartTime.ToOADate();
                planPreemptsLabel.ToPosition   = plan.EndTime.ToOADate();

                var c = from Controller_Event_Log r in EventLog.Events
                        where r.EventCode == 107 && r.Timestamp > plan.StartTime && r.Timestamp < plan.EndTime
                        select r;

                var premptCount = c.Count().ToString();
                planPreemptsLabel.Text      = "Preempts Serviced During Plan: " + premptCount;
                planPreemptsLabel.LabelMark = LabelMarkStyle.LineSideMark;
                planPreemptsLabel.ForeColor = Color.Red;
                planPreemptsLabel.RowIndex  = 1;
                backGroundColor++;
            }
        }
Ejemplo n.º 24
0
Archivo: Model.cs Proyecto: Ring-r/opt
 public static Circle Calc(StripLine strip_Line_i, StripLine strip_line_j, StripLine strip_line_k)
 {
     return null;
 }
Ejemplo n.º 25
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!this.IsPostBack)
            {
                // Add String Alignments styles to control.
                foreach (string item in Enum.GetNames(typeof(StringAlignment)))
                {
                    TextAlignment.Items.Add(item);
                    TextLineAlignment.Items.Add(item);
                }

                // Add Colors to controls.
                foreach (String colorName in KnownColor.GetNames(typeof(KnownColor)))
                {
                    Color1.Items.Add(colorName);
                }

                Color1.Items.FindByText("Black").Selected = true;

                // Add Font Family styles to control.
                foreach (FontFamily fontName in FontFamily.Families)
                {
                    Font1.Items.Add(fontName.Name);
                }
            }

            StripLine stripLine = Chart1.ChartAreas["ChartArea1"].AxisX.StripLines[0];


            // Set Strip Lines Title Alignment
            stripLine.TextAlignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), TextAlignment.SelectedItem.Text);

            // Set Strip Lines Title Line Alignment
            stripLine.TextLineAlignment = (StringAlignment)StringAlignment.Parse(typeof(StringAlignment), TextLineAlignment.SelectedItem.Text);

            // Set Strip Lines Title text
            stripLine.Text = Title.Text;

            // Set Strip Lines Title Angle
            stripLine.TextOrientation = (System.Web.UI.DataVisualization.Charting.TextOrientation)
                                        System.Web.UI.DataVisualization.Charting.TextOrientation.Parse(
                typeof(System.Web.UI.DataVisualization.Charting.TextOrientation),
                TextOrientation.SelectedItem.Value);

            // Set Strip Lines Title Color
            stripLine.ForeColor = Color.FromName(Color1.SelectedItem.Value);

            // Set Font style.
            FontStyle fontStyle = FontStyle.Regular;

            if (Italic.Checked)
            {
                fontStyle = (FontStyle)FontStyle.Italic;
            }
            if (Bold.Checked)
            {
                fontStyle |= (FontStyle)FontStyle.Bold;
            }
            if (Underline.Checked)
            {
                fontStyle |= (FontStyle)FontStyle.Underline;
            }
            if (Strikeout.Checked)
            {
                fontStyle |= (FontStyle)FontStyle.Strikeout;
            }

            // Set Strip Lines Title Font
            try
            {
                stripLine.Font = new Font(Font1.SelectedItem.Text, float.Parse(TitleSize.SelectedItem.Text), fontStyle);
            }
            catch
            {
                stripLine.Font = new Font("Arial", float.Parse(TitleSize.SelectedItem.Text), fontStyle);
            }
        }
Ejemplo n.º 26
0
        private void Chart1_PrePaint(object sender, EventArgs e)
        {
            if(sender is Chart)
            {
                // Position point chart type series on the points of the box plot to display labels
                Chart1.Series["BoxPlotLabels"].Points[0].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[0];
                Chart1.Series["BoxPlotLabels"].Points[1].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[1];
                Chart1.Series["BoxPlotLabels"].Points[2].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[2];
                Chart1.Series["BoxPlotLabels"].Points[3].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[3];
                Chart1.Series["BoxPlotLabels"].Points[4].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[4];
                Chart1.Series["BoxPlotLabels"].Points[5].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[5];

                Chart1.Series["BoxPlotLabels"].Points[6].Label = "";
                Chart1.Series["BoxPlotLabels"].Points[7].Label = "";
                if(CheckboxShowUnusual.Checked)
                {
                    if(Chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 6)
                    {
                        Chart1.Series["BoxPlotLabels"].Points[6].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[6] - 3;
                        Chart1.Series["BoxPlotLabels"].Points[6].Label = "Unusual data point";
                        }
                    if(Chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 8)
                    {
                        Chart1.Series["BoxPlotLabels"].Points[7].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[8] + 3;
                        Chart1.Series["BoxPlotLabels"].Points[7].Label = "Unusual data point";
                    }
                    else if(Chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 7)
                    {
                        Chart1.Series["BoxPlotLabels"].Points[7].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[7] + 3;
                        Chart1.Series["BoxPlotLabels"].Points[7].Label = "Unusual data point";
                    }
                }

                // Define labels
                int	whiskerPercentile = int.Parse(WhiskerPercentileList.SelectedItem.Value);
                Chart1.Series["BoxPlotLabels"].Points[0].Label = whiskerPercentile.ToString() + "th Percentile";
                Chart1.Series["BoxPlotLabels"].Points[1].Label = (100 - whiskerPercentile).ToString() + "th Percentile";
                if(whiskerPercentile == 0)
                {
                    Chart1.Series["BoxPlotLabels"].Points[0].Label = "Minimum";
                    Chart1.Series["BoxPlotLabels"].Points[1].Label = "Maximum";
                }
                Chart1.Series["BoxPlotLabels"].Points[2].Label = "25th Percentile (LQ)";
                Chart1.Series["BoxPlotLabels"].Points[3].Label = "75th Percentile (UQ)";
                Chart1.Series["BoxPlotLabels"].Points[4].Label = (CheckBoxShowAverage.Checked) ? "Average/Mean" : "";
                Chart1.Series["BoxPlotLabels"].Points[5].Label = (CheckboxShowMedian.Checked) ? "Median" : "";

                // Add strip lines
                StripLine stripLine = new StripLine();
                stripLine.BackColor = Color.FromArgb(220, Color.DarkKhaki);
                stripLine.IntervalOffset = Chart1.Series["BoxPlotLabels"].Points[2].YValues[0];
                stripLine.StripWidth = Chart1.Series["BoxPlotLabels"].Points[3].YValues[0] - stripLine.IntervalOffset;
                stripLine.Text = "data points\n50% of";
                stripLine.Font = new Font("Microsoft Sans Serif", 7);
                stripLine.TextOrientation = TextOrientation.Rotated270;
                stripLine.TextLineAlignment = StringAlignment.Center;
                stripLine.TextAlignment = StringAlignment.Near;
                Chart1.ChartAreas["Data Chart Area"].AxisY.StripLines.Add(stripLine);

                stripLine = new StripLine();
                stripLine.BackColor = Color.FromArgb(100, Color.DarkKhaki);
                stripLine.IntervalOffset = Chart1.Series["BoxPlotLabels"].Points[0].YValues[0];
                stripLine.StripWidth = Chart1.Series["BoxPlotLabels"].Points[1].YValues[0] - stripLine.IntervalOffset;
                stripLine.ForeColor = Color.FromArgb(120, Color.Black);
                stripLine.Text = (100 - whiskerPercentile * 2).ToString() + "% of data points";
                stripLine.Font = new Font("Microsoft Sans Serif", 7);
                stripLine.TextOrientation = TextOrientation.Rotated270;
                stripLine.TextLineAlignment = StringAlignment.Center;
                Chart1.ChartAreas["Data Chart Area"].AxisY.StripLines.Add(stripLine);

            }
        }
Ejemplo n.º 27
0
        public BarChart(ChartData chartData, int width, int height, double axisYMax, double axisYMin, double? axisYInterval, string axisYLabelFormat,
            bool displayLegend, SeriesChartType chartType, bool eachSeriesInNewChartArea, List<CustomLabels.CustomLabel> axisYCustomLabels = null)
        {
            ChartData = chartData;
            Width = width;// 740;
            Height = height;// 200;
            YMax = axisYMax;// 1;
            YMin = axisYMin;// 0;
            AxisYInterval = (axisYInterval ?? .25);
            AxisYLabelFormat = !string.IsNullOrEmpty(axisYLabelFormat) ? axisYLabelFormat : "{P0}";
            DisplayLegend = displayLegend;
            AxisXTitle = chartData.AxisXTitle;
            AxisYTitle = chartData.AxisYTitle;
            ChartType = chartType;
            EachSeriesInNewChartArea = eachSeriesInNewChartArea;
            AxisYCustomLabels = axisYCustomLabels;
            ChartId = chartData.ChartId;

            //setup control
            SetYMax();

            if (DisplayLegend)
                chartAreaWidth = 65;

            if (EachSeriesInNewChartArea)
            {
                horizontalOffset = 10;
                //chartAreaWidth = 85; chartAreaWidth - horizontalOffset;
                if (ChartData.SeriesCollection.Count > 0)
                    chartAreaWidth = chartAreaWidth / ChartData.SeriesCollection.Count;
            }

            Chart chart = SetupChart(String.Format(chartControlIdFormat, 0, ChartId));

            if (ChartData.StripLines != null)
            {
                foreach (var stripLine in ChartData.StripLines)
                {
                    if (stripLine == null)
                        continue;

                    //Adding a strip line.
                    var sl = new StripLine
                                 {
                                     Interval = -1,
                                     BorderColor = ColorTranslator.FromHtml(stripLine.Color),
                                     IntervalOffset = stripLine.Value,
                                     ToolTip = stripLine.Tooltip
                                 };

                    chart.ChartAreas[0].AxisY.StripLines.Add(sl);
                }
            }

            if (ChartData.SeriesCollection == null || ChartData.SeriesCollection.Count == 0 ||
                ChartData.SeriesCollection.First().Points.Count == 0)
            {
                var series =
                    CreateSeries(new ChartData.Series { Name = defaultSeries, Style = ChartSeriesStyle.White, ShowInLegend = false });
                int i = series.Points.AddY(0);
                series.Points[i].ToolTip = String.Empty;
                series.Points[i].Label = String.Empty;
                series.Points[i].AxisLabel = String.Empty;
                series.Points[i].Color = ColorTranslator.FromHtml(ChartColors.White);
                chart.ChartAreas[0].AxisX.MajorTickMark.Size = 0;
                chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = ColorTranslator.FromHtml(ChartColors.White);

                chart.Series.Add(series);
                Chart = chart;
                return;
            }

            if (!EachSeriesInNewChartArea)
                PlotPoints(chart);
            else
                PlotPointsInMultipleChartAreas(chart);

            Chart = chart;
        }
Ejemplo n.º 28
0
        private void PlotPointsInMultipleChartAreas(Chart chart)
        {
            int chartAreaCount = 0;
            var chartArea = chart.ChartAreas[0];
            chartArea.AxisY.LabelAutoFitMinFontSize = 8;
            chartArea.AxisY.LabelAutoFitMaxFontSize = 8;
            foreach (var stripLine in ChartData.StripLines)
            {
                chartArea.AxisY.CustomLabels.Add(new CustomLabel(stripLine.Value, stripLine.Value + 1, stripLine.Label,
                                                                 0, LabelMarkStyle.None) { ForeColor = ColorTranslator.FromHtml(stripLine.Color) });
            }

            foreach (var seriesData in ChartData.SeriesCollection)
            {
                chartAreaCount++;
                var chartAreaName = String.Format("CA{0}", chartAreaCount);
                if (chartAreaCount != 1)
                {
                    chartArea =
                        CreateChartArea(new ElementPosition(horizontalOffset + chartAreaWidth * (chartAreaCount - 1),
                                                            verticalOffset, chartAreaWidth, chartAreaHeight));
                    chart.ChartAreas.Add(chartArea);

                    foreach (var stripLine in ChartData.StripLines)
                    {
                        //Adding a strip line.
                        var sl = new StripLine
                        {
                            Interval = -1,
                            BorderColor = ColorTranslator.FromHtml(stripLine.Color),
                            IntervalOffset = stripLine.Value,
                            ToolTip = stripLine.Tooltip,
                        };

                        chartArea.AxisY.StripLines.Add(sl);
                    }
                }

                chartArea.Name = chartAreaName;
                chartArea.AxisX.MajorTickMark.LineColor = Color.White;
                chartArea.AxisX.MajorTickMark.Size = 0.0f;
                chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.None;
                chartArea.AxisX.Title = seriesData.Name;
                chartArea.AxisX.TitleFont = (Font)axisTitleFont.Clone();
                if (ChartData.SeriesCollection.Count > 3)
                    chartArea.AxisX.TitleFont = new Font("Verdana", 7, FontStyle.Bold);
                if (ChartData.SeriesCollection.Count > 5)
                    chartArea.AxisX.TitleFont = new Font("Verdana", 6, FontStyle.Bold);
                chartArea.AxisY.LineColor = Color.White;
                chartArea.AxisY.MajorGrid.LineColor = Color.White;
                chartArea.AxisY.MajorTickMark.LineColor = Color.White;
                chartArea.AxisY.MajorTickMark.Size = 0.0f;
                chartArea.AxisY.LabelStyle.ForeColor = Color.White;
                // this is here b/c of weird behavior with adding a Y-axis custom label and the position of X-axis labels
                chartArea.AxisY.CustomLabels.Add(new CustomLabel(0, 1, " ", 0, LabelMarkStyle.None));

                var series = CreateSeries(seriesData);
                series.ChartArea = chartAreaName;
                chart.Series.Add(series);
                foreach (var point in seriesData.Points)
                {
                    int i = series.Points.AddY(point.Value);
	                DataPoint currentDataPoint = series.Points[i];
	                if (!String.IsNullOrEmpty(point.Tooltip))
                        currentDataPoint.ToolTip = point.Tooltip;
                    if (!String.IsNullOrEmpty(point.AxisLabel))
                        currentDataPoint.AxisLabel = point.AxisLabel;
                    currentDataPoint.IsValueShownAsLabel = point.IsValueShownAsLabel;
                    if (point.IsValueShownAsLabel && !String.IsNullOrEmpty(point.Label))
                        currentDataPoint.Label = point.Label;

                    if (point.State != MetricStateType.None)
                    {
						var style = (point.State == MetricStateType.Good || point.State == MetricStateType.VeryGood)
							? ChartSeriesStyle.Green : ChartSeriesStyle.Red;

                        currentDataPoint.Color = (point.State == MetricStateType.Good ||
                                                  point.State == MetricStateType.VeryGood)
                                                     ? ColorTranslator.FromHtml(ChartColors.Green)
                                                     : ColorTranslator.FromHtml(ChartColors.Red);
						currentDataPoint.LabelForeColor = ColorTranslator.FromHtml(style.BackgroundColor);
						currentDataPoint.BackHatchStyle = GetHatchStyle(style);
						currentDataPoint.BackSecondaryColor = ColorTranslator.FromHtml(style.ForegroundColor);
                    }

                    if (point.Trend != TrendEvaluation.None)
                        currentDataPoint.MarkerImage = GetImagePathBasedOnTrend(point.Trend);
                }
            }
        }
Ejemplo n.º 29
0
        private void Chart1_PrePaint(object sender, EventArgs e)
        {
            if (sender is Chart)
            {
                // Position point chart type series on the points of the box plot to display labels
                Chart1.Series["BoxPlotLabels"].Points[0].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[0];
                Chart1.Series["BoxPlotLabels"].Points[1].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[1];
                Chart1.Series["BoxPlotLabels"].Points[2].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[2];
                Chart1.Series["BoxPlotLabels"].Points[3].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[3];
                Chart1.Series["BoxPlotLabels"].Points[4].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[4];
                Chart1.Series["BoxPlotLabels"].Points[5].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[5];

                Chart1.Series["BoxPlotLabels"].Points[6].Label = "";
                Chart1.Series["BoxPlotLabels"].Points[7].Label = "";
                if (CheckboxShowUnusual.Checked)
                {
                    if (Chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 6)
                    {
                        Chart1.Series["BoxPlotLabels"].Points[6].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[6] - 3;
                        Chart1.Series["BoxPlotLabels"].Points[6].Label      = "Unusual data point";
                    }
                    if (Chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 8)
                    {
                        Chart1.Series["BoxPlotLabels"].Points[7].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[8] + 3;
                        Chart1.Series["BoxPlotLabels"].Points[7].Label      = "Unusual data point";
                    }
                    else if (Chart1.Series["BoxPlotSeries"].Points[0].YValues.Length > 7)
                    {
                        Chart1.Series["BoxPlotLabels"].Points[7].YValues[0] = Chart1.Series["BoxPlotSeries"].Points[0].YValues[7] + 3;
                        Chart1.Series["BoxPlotLabels"].Points[7].Label      = "Unusual data point";
                    }
                }


                // Define labels
                int whiskerPercentile = int.Parse(WhiskerPercentileList.SelectedItem.Value);
                Chart1.Series["BoxPlotLabels"].Points[0].Label = whiskerPercentile.ToString() + "th Percentile";
                Chart1.Series["BoxPlotLabels"].Points[1].Label = (100 - whiskerPercentile).ToString() + "th Percentile";
                if (whiskerPercentile == 0)
                {
                    Chart1.Series["BoxPlotLabels"].Points[0].Label = "Minimum";
                    Chart1.Series["BoxPlotLabels"].Points[1].Label = "Maximum";
                }
                Chart1.Series["BoxPlotLabels"].Points[2].Label = "25th Percentile (LQ)";
                Chart1.Series["BoxPlotLabels"].Points[3].Label = "75th Percentile (UQ)";
                Chart1.Series["BoxPlotLabels"].Points[4].Label = (CheckBoxShowAverage.Checked) ? "Average/Mean" : "";
                Chart1.Series["BoxPlotLabels"].Points[5].Label = (CheckboxShowMedian.Checked) ? "Median" : "";

                // Add strip lines
                StripLine stripLine = new StripLine();
                stripLine.BackColor         = Color.FromArgb(220, Color.DarkKhaki);
                stripLine.IntervalOffset    = Chart1.Series["BoxPlotLabels"].Points[2].YValues[0];
                stripLine.StripWidth        = Chart1.Series["BoxPlotLabels"].Points[3].YValues[0] - stripLine.IntervalOffset;
                stripLine.Text              = "data points\n50% of";
                stripLine.Font              = new Font("Microsoft Sans Serif", 7);
                stripLine.TextOrientation   = TextOrientation.Rotated270;
                stripLine.TextLineAlignment = StringAlignment.Center;
                stripLine.TextAlignment     = StringAlignment.Near;
                Chart1.ChartAreas["Data Chart Area"].AxisY.StripLines.Add(stripLine);

                stripLine                   = new StripLine();
                stripLine.BackColor         = Color.FromArgb(100, Color.DarkKhaki);
                stripLine.IntervalOffset    = Chart1.Series["BoxPlotLabels"].Points[0].YValues[0];
                stripLine.StripWidth        = Chart1.Series["BoxPlotLabels"].Points[1].YValues[0] - stripLine.IntervalOffset;
                stripLine.ForeColor         = Color.FromArgb(120, Color.Black);
                stripLine.Text              = (100 - whiskerPercentile * 2).ToString() + "% of data points";
                stripLine.Font              = new Font("Microsoft Sans Serif", 7);
                stripLine.TextOrientation   = TextOrientation.Rotated270;
                stripLine.TextLineAlignment = StringAlignment.Center;
                Chart1.ChartAreas["Data Chart Area"].AxisY.StripLines.Add(stripLine);
            }
        }