コード例 #1
0
        public void plotBox(int colorIndex)
        {
            GraphPane myPane = zedGraphControl1.GraphPane;

            int index = 0;

            foreach (SummaryData summary in m_data.SummaryData)
            {
                //Plot the items, first the median values
                CurveItem meadian = myPane.AddCurve("", masterList[index][0], Color.Black, SymbolType.HDash);
                LineItem  myLine  = (LineItem)meadian;
                myLine.Line.IsVisible   = false;
                myLine.Symbol.Size      = 25;
                myLine.Symbol.Fill.Type = FillType.Solid;

                //Box
                HiLowBarItem myCurve = myPane.AddHiLowBar(summary.SeriesName, masterList[index][1], GetNextColor());
                myCurve.Bar.Fill.Type = FillType.Solid;

                //Wiskers
                ErrorBarItem myerror = myPane.AddErrorBar("", masterList[index][2], Color.Black);
                //Outliers
                CurveItem upper = myPane.AddCurve("", masterList[index][3], Color.Black, SymbolType.Circle);
                LineItem  bLine = (LineItem)upper;
                bLine.Symbol.Size    = 3;
                bLine.Line.IsVisible = false;

                index++;
            }
        }
コード例 #2
0
ファイル: GraphingBase.cs プロジェクト: diehard2/stochfit
        protected virtual void AddCurvetoGraph(PointPairList list, PointPairList elist, string DataName, Color linecolor, SymbolType type, int symbolsize, string tag)
        {
            LineItem myCurve = m_cMyPane.AddCurve(DataName, list, linecolor, type);

            myCurve.Symbol.Fill          = new Fill(Color.DeepSkyBlue, Color.Red);
            myCurve.Symbol.Fill.Type     = FillType.GradientByZ;
            myCurve.Symbol.Fill.RangeMin = 0;
            myCurve.Symbol.Fill.RangeMax = 1;
            myCurve.Symbol.Size          = symbolsize;
            myCurve.Line.IsAntiAlias     = true;
            myCurve.Line.IsSmooth        = true;
            myCurve.Tag = tag;

            if (elist != null)
            {
                ErrorBarItem myECurve;
                myECurve = m_cMyPane.AddErrorBar("", elist, Color.Black);
                myECurve.Bar.PenWidth = 1f;
                // Use the HDash symbol so that the error bars look like I-beams

                myECurve.Bar.Symbol.Type = SymbolType.HDash;
                /// myECurve.Bar.Symbol.Border.Width = .1f;
                myECurve.Bar.Symbol.IsVisible = true;
                myECurve.Bar.Symbol.Size      = 2;
            }

            AxisChange();
            Invalidate();
        }
コード例 #3
0
        private void DrawGraph()
        {
            GraphPane pane = zedGraph.GraphPane;

            // Очистим список кривых
            pane.CurveList.Clear();

            // Создадим список точек
            PointPairList dataList = new PointPairList();

            // !!! Создадим список допусков
            PointPairList errorList = new PointPairList();

            double xmin = 0;
            double xmax = 4 * Math.PI;

            // Величина допуска для всех точек
            double error = 0.1;

            // Заполняем список точек
            for (double x = xmin; x <= xmax; x += 0.3)
            {
                double curry = f(x);

                // Добавим в список точку
                dataList.Add(x, curry);

                // !!! Добавим допуск для этой же точки
                // Первый параметр - координата X,
                // Второй параметр - минимальное значение интервала
                // Третий параметр - максимальное значение интервала
                errorList.Add(x, curry - error, curry + error);
            }

            // Создадим кривую с данными
            LineItem myCurve = pane.AddCurve("Data", dataList, Color.Blue, SymbolType.Circle);

            myCurve.Symbol.Size = 5.0f;

            // !!! Создадим кривую, отображающую допуски
            ErrorBarItem errorCurve = pane.AddErrorBar("Error", errorList, Color.Black);

            // Вызываем метод AxisChange (), чтобы обновить данные об осях.
            zedGraph.AxisChange();

            // Обновляем график
            zedGraph.Invalidate();
        }
コード例 #4
0
        public ErrorBarDemo() : base("An Error Bar Chart",
                                     "Error Bar Demo", DemoType.Bar)
        {
            GraphPane myPane = base.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text       = "Error Bar Demo Chart";
            myPane.XAxis.Title.Text = "Label";
            myPane.YAxis.Title.Text = "My Y Axis";

            // Make up some data points based on the Sine function
            PointPairList list = new PointPairList();

            for (int i = 0; i < 44; i++)
            {
                double x     = i / 44.0;
                double y     = Math.Sin((double)i * Math.PI / 15.0);
                double yBase = y - 0.4;
                list.Add(x, y, yBase);
            }

            // Generate a red bar with "Curve 1" in the legend
            ErrorBarItem myCurve = myPane.AddErrorBar("Curve 1", list, Color.Red);

            // Make the X axis the base for this curve (this is the default)
            myPane.BarSettings.Base = BarBase.X;
            myCurve.Bar.PenWidth    = 1f;
            // Use the HDash symbol so that the error bars look like I-beams
            myCurve.Bar.Symbol.Type            = SymbolType.HDash;
            myCurve.Bar.Symbol.Border.PenWidth = .1f;
            myCurve.Bar.Symbol.IsVisible       = true;
            myCurve.Bar.Symbol.Size            = 4;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.LightGoldenrodYellow, 45.0F);

            base.ZedGraphControl.AxisChange();
        }
コード例 #5
0
        public HiLowCloseDemo() : base("A demo demonstrating HiLowClose",
                                       "Hi-Low-Close", DemoType.Bar, DemoType.Special)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text       = "ZedgroSoft, International\nHi-Low-Close Daily Stock Chart";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "Trading Price, $US";

            // Set the title font characteristics
            myPane.Title.FontSpec.Family   = "Arial";
            myPane.Title.FontSpec.IsItalic = true;
            myPane.Title.FontSpec.Size     = 18;


            // Generate some random stock price data
            PointPairList hList = new PointPairList();
            PointPairList cList = new PointPairList();
            Random        rand  = new Random();
            // initialize the starting close price
            double close = 45;

            for (int i = 45; i < 65; i++)
            {
                double x = (double)new XDate(2004, 12, i - 30);
                close = close + 2.0 * rand.NextDouble() - 0.5;
                double hi  = close + 2.0 * rand.NextDouble();
                double low = close - 2.0 * rand.NextDouble();
                hList.Add(x, hi, low);
                cList.Add(x, close);
            }


            // Make a new curve with a "Closing Price" label
            LineItem curve;

            curve = myPane.AddCurve("Closing Price", cList, Color.Black,
                                    SymbolType.Diamond);
            // Turn off the line display, symbols only
            curve.Line.IsVisible = false;
            // Fill the symbols with solid red color
            curve.Symbol.Fill = new Fill(Color.Red);
            curve.Symbol.Size = 7;

            // Add a blue error bar to the graph
            ErrorBarItem myCurve = myPane.AddErrorBar("Price Range", hList,
                                                      Color.Blue);

            myCurve.Bar.PenWidth         = 3;
            myCurve.Bar.Symbol.IsVisible = false;

            // Set the XAxis to date type
            myPane.XAxis.Type = AxisType.Date;
            // X axis step size is 1 day
            myPane.XAxis.Scale.MajorStep = 1;
            myPane.XAxis.Scale.MajorUnit = DateUnit.Day;
            myPane.XAxis.Scale.MinorStep = 0.5;
            myPane.XAxis.Scale.MajorUnit = DateUnit.Day;
            // tilt the x axis labels to an angle of 65 degrees
            myPane.XAxis.Scale.FontSpec.Angle  = 65;
            myPane.XAxis.Scale.FontSpec.IsBold = true;
            myPane.XAxis.Scale.FontSpec.Size   = 12;
            myPane.XAxis.Scale.Format          = "d MMM";
            // make the x axis scale minimum 1 step less than the minimum data value
            myPane.XAxis.Scale.Min = hList[0].X - 1;

            // Display the Y axis grid
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.Scale.MinorStep     = 0.5;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.FromArgb(255, 255, 166), 90F);

            base.ZedGraphControl.AxisChange();
        }
コード例 #6
0
ファイル: frmPlot.cs プロジェクト: ninalinzhiyun/VB3
        /// <summary>
        /// a hacked mess to show box-wisker plot for outlier manipulation
        /// </summary>
        /// <param name="iv">double array of independent variable values</param>
        /// <param name="tags">string array of what should be date/time tags</param>
        /// <returns>a graph pane to display in the master</returns>
        private GraphPane addPlotBW(double[] iv, string[] tags)
        {
            //http://www.sharpstatistics.co.uk/index.php?option=com_content&view=article&id=12&Itemid=13
            //and hacked by mog 4/1/11

            //For each set of data for the boxplot calculate the median and the inter quartile (IQR) range
            //which is just the value of the 75th percentile minus the 25th percentile. The median is where
            //the horizontal bar goes. Using the 25th and 75th percentile a HiLowBarIten can be set which is
            //just a bar where the top and base are specified.

            //An error bar that has upper and lower values of the 25th percentile minus 1.5 times the IQR and
            //the 75th percentile plus 1.5 times the IQR is set to give the whiskers. As with the HiLowItem
            //barList is a PointPairList with the high and low values.

            //All that is left to do is add any points that are above or below the end of the whiskers.
            SortedList <string, double> datevalue = getlist(tags, iv);

            GraphPane gp = new GraphPane();

            //    "Median designated within box.\n" +
            //    "Whiskers are +- 1.5 * IQR (IQR = 75th percentile - 25th percentile)\n" +
            //    "Points above/below whiskers are designated as outliers.";

            //median of each array
            PointPairList medians = new PointPairList();
            //75th and 25th percentile, defines the box
            PointPairList hiLowList = new PointPairList();
            //+/- 1.5*Interquartile range, extentent of wiskers
            PointPairList barList = new PointPairList();
            //outliers
            PointPairList outs = new PointPairList();

            //Add the values
            DescriptiveStats ds = new DescriptiveStats();

            ds.getStats(iv);
            double median = ds.Median;

            medians.Add(0, median);
            double hivalue = percentile(iv, 75);
            double lovalue = percentile(iv, 25);

            hiLowList.Add(0, hivalue, lovalue);
            double iqr        = 1.5 * (hivalue - lovalue);
            double upperLimit = hivalue + iqr;
            double lowerLimit = lovalue - iqr;
            //The wiskers must end on an actual data point
            double wiskerlo = ValueNearestButGreater(iv, lowerLimit);
            double wiskerhi = ValueNearestButLess(iv, upperLimit);

            barList.Add(0, wiskerlo, wiskerhi);

            var upperouts = (from kv in datevalue
                             where kv.Value > upperLimit
                             select kv);

            foreach (var v in upperouts)
            {
                outs.Add(0, v.Value, v.Key);
            }

            var lowerouts = (from kv in datevalue
                             where kv.Value < lowerLimit
                             select kv);

            foreach (var v in lowerouts)
            {
                outs.Add(0, v.Value, v.Key);
            }

            //Plot the items, first the median values
            CurveItem meadian = gp.AddCurve("", medians, Color.Black, SymbolType.HDash);
            LineItem  myLine  = (LineItem)meadian;

            myLine.Line.IsVisible   = false;
            myLine.Symbol.Fill.Type = FillType.Solid;

            //Box
            HiLowBarItem myCurve = gp.AddHiLowBar("", hiLowList, Color.Black);

            myCurve.Bar.Fill.Type = FillType.None;

            //Wiskers
            ErrorBarItem myerror = gp.AddErrorBar("", barList, Color.Black);

            //Outliers
            CurveItem upper = gp.AddCurve(_dt.Columns[intSelectedcol].ColumnName + " outliers", outs, Color.Green, SymbolType.Circle);
            LineItem  bLine = (LineItem)upper;

            bLine.Line.IsVisible = false;

            gp.YAxis.Title.Text = _dt.Columns[intSelectedcol].ColumnName;
            gp.BarSettings.Type = BarType.Overlay;
            gp.XAxis.IsVisible  = false;
            gp.Legend.IsVisible = true;

            gp.Tag        = "BWPlot";
            gp.Title.Text = "BoxWhisker Plot";

            return(gp);
        }
コード例 #7
0
        private void initializeGraphControl(ZedGraphControl zedGraphControl)
        {
            zedGraphControl.MasterPane.PaneList.Clear();
            zedGraphControl.MasterPane.SetLayout(zedGraphControl.CreateGraphics(), 1, (int)IonSeries.Count + 1);
            zedGraphControl.MasterPane.InnerPaneGap     = 0;
            zedGraphControl.MasterPane.Border.IsVisible = true;
            zedGraphControl.IsEnableHPan        = false;
            zedGraphControl.IsEnableHZoom       = false;
            zedGraphControl.IsSynchronizeYAxes  = true;
            zedGraphControl.IsZoomOnMouseCenter = true;

            var axisPane = new GraphPane();

            axisPane.Legend.IsVisible          = false;
            axisPane.IsFontsScaled             = false;
            axisPane.XAxis.IsVisible           = false;
            axisPane.YAxis.Scale.Min           = 0;
            axisPane.YAxis.Scale.Max           = 100;
            axisPane.YAxis.Title.Text          = zedGraphControl.Text;
            axisPane.YAxis.Title.Gap           = 0.05f;
            axisPane.YAxis.MajorTic.IsOpposite = false;
            axisPane.YAxis.MinorTic.IsOpposite = false;
            axisPane.Chart.Border.IsVisible    = false;
            axisPane.Border.IsVisible          = false;
            axisPane.Margin.Left  = 1;
            axisPane.Margin.Right = 0;
            axisPane.Title.Text   = "Series:";
            zedGraphControl.MasterPane.Add(axisPane);

            var csr = new ColorSymbolRotator();

            for (int i = 0; i < (int)IonSeries.Count; ++i)
            {
                var graphPane = new GraphPane();
                graphPane.Title.Text             = IonSeriesLabels[i];
                graphPane.Legend.IsVisible       = false;
                graphPane.IsFontsScaled          = false;
                graphPane.Chart.Border.IsVisible = false;
                graphPane.Border.IsVisible       = false;
                graphPane.XAxis.Scale.Min        = -1;
                graphPane.XAxis.Scale.Max        = 1;
                graphPane.XAxis.IsVisible        = false;
                graphPane.YAxis.Scale.Min        = 0;
                graphPane.YAxis.Scale.Max        = 100;
                graphPane.YAxis.IsVisible        = false;
                zedGraphControl.MasterPane.Add(graphPane);

                graphPane.BarSettings.Type = BarType.Overlay;
                graphPane.BarSettings.ClusterScaleWidth = 1;

                var mean = graphPane.AddCurve(IonSeriesLabels[i],
                                              new PointPairList(),
                                              Color.Black,
                                              SymbolType.Circle);
                mean.Line.IsVisible          = false;
                mean.Symbol.Border.IsVisible = false;
                mean.Symbol.Fill.Type        = FillType.Solid;

                var errorBar = graphPane.AddErrorBar(IonSeriesLabels[i],
                                                     new PointPairList(),
                                                     Color.Black);
                errorBar.Bar.IsVisible           = true;
                errorBar.Bar.PenWidth            = .1f;
                errorBar.Bar.Symbol.IsVisible    = true;
                errorBar.Bar.Symbol.Type         = SymbolType.HDash;
                errorBar.Bar.Symbol.Border.Width = .1f;
                errorBar.Bar.Symbol.Size         = 4;

                var hiLowBar = graphPane.AddHiLowBar(IonSeriesLabels[i],
                                                     new PointPairList(),
                                                     Color.Black);
                hiLowBar.Bar.Fill.Type = FillType.None;

                var scatter = graphPane.AddCurve(IonSeriesLabels[i],
                                                 new PointPairList(),
                                                 csr.NextColor,
                                                 SymbolType.Circle);
                scatter.Line.IsVisible          = false;
                scatter.Symbol.IsAntiAlias      = true;
                scatter.Symbol.Border.IsVisible = false;
                scatter.Symbol.Fill.Type        = FillType.Solid;
                scatter.Symbol.Size             = 3f;
            }

            zedGraphControl.MasterPane.AxisChange();
            zedGraphControl.Refresh();
        }
コード例 #8
0
 /// <summary>
 /// Creates a new CurveItem using the PointPairList and add it the the given pane.
 /// </summary>
 /// <param name="pane">the GraphPane object to which to add the new curve</param>
 /// <param name="points">a PointPairList collection defining the points for this curve</param>
 /// <returns>the newly created CurveItem added to the given GraphPane</returns>
 /// <remarks>This method must be overriden by childs</remarks>
 public override CurveItem CreateInPane( GraphPane pane, PointPairList points )
 {
     ErrorBarItem x = pane.AddErrorBar( this.Label, points, this.Color );
     this.CopyTo( x );
     return x;
 }
コード例 #9
0
ファイル: frmCatGraph.cs プロジェクト: DeepakkSHAW/.NET
        private void CreateHighLow(ZedGraphControl zgc)
        {
            GraphPane myPane = zgc.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text       = "Hi-Low-Close Daily Stock Chart";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "Trading Price, Rs(INR)";

            // Set the title font characteristics
            myPane.Title.FontSpec.Family   = "Arial";
            myPane.Title.FontSpec.IsItalic = true;
            myPane.Title.FontSpec.Size     = 14;

            // Generate some random stock price data
            PointPairList hList = new PointPairList();
            PointPairList cList = new PointPairList();
            Random        rand  = new Random();
            // initialize the starting close price

            string    sOnlyOneday   = string.Empty;
            DateTime  tKickoff      = DateTime.MinValue;
            DataTable dtVirtual     = new DataTable();
            string    selectInDates = "Ondate>=#{0}# AND Ondate<#{1}#";
            DataTable dt            = _dsPlot.Tables[0];

            dtVirtual = dt.Clone();

            foreach (DataRow dr in dt.Rows)
            {
                if (tKickoff.ToShortDateString().CompareTo(
                        Convert.ToDateTime(dr[3]).ToShortDateString()) != 0)
                {
                    // another date
                    tKickoff = Convert.ToDateTime(dr[3]);
                    dtVirtual.Rows.Clear();

                    sOnlyOneday = string.Format(selectInDates, tKickoff.ToShortDateString(), tKickoff.AddDays(1).ToShortDateString());
                    foreach (DataRow drStocks in dt.Select(sOnlyOneday))
                    {
                        dtVirtual.ImportRow(drStocks);
                    }

                    DataRow[] maxPrice = dtVirtual.Select("Price=Max(Price)");
                    DataRow[] minPrice = dtVirtual.Select("Price=Min(Price)");
                    DataRow[] clsPrice = dtVirtual.Select("Ondate=Max(Ondate)");

                    /* Console.WriteLine(maxPrice[0].ItemArray[2].ToString());
                     * Console.WriteLine(minPrice[0].ItemArray[2].ToString());
                     * Console.WriteLine(clsPrice[0].ItemArray[2].ToString());*/

                    //filling the data to plot the Graph
                    double x     = (double)new XDate(tKickoff.Year, tKickoff.Month, tKickoff.Day);
                    double hi    = Convert.ToDouble(maxPrice[0].ItemArray[2]);
                    double low   = Convert.ToDouble(minPrice[0].ItemArray[2]);
                    double close = Convert.ToDouble(clsPrice[0].ItemArray[2]);
                    hList.Add(x, hi, low);
                    cList.Add(x, close);
                }
            }

            // Make a new curve with a "Closing Price" label
            LineItem curve = myPane.AddCurve("Closing Price", cList, Color.Black,
                                             SymbolType.Diamond);

            // Turn off the line display, symbols only
            curve.Line.IsVisible = false;
            // Fill the symbols with solid red color
            curve.Symbol.Fill = new Fill(Color.Red);
            curve.Symbol.Size = (float)4.5;

            // Add a blue error bar to the graph
            ErrorBarItem myCurve = myPane.AddErrorBar("Price Range", hList,
                                                      Color.Blue);

            myCurve.Bar.PenWidth         = 3;
            myCurve.Bar.Symbol.IsVisible = false;

            // Set the XAxis to date type
            myPane.XAxis.Type = AxisType.Date;
            // X axis step size is 1 day
            myPane.XAxis.Scale.MajorStep = 1;
            myPane.XAxis.Scale.MajorUnit = DateUnit.Day;
            // tilt the x axis labels to an angle of 65 degrees
            myPane.XAxis.Scale.FontSpec.Angle  = 65;
            myPane.XAxis.Scale.FontSpec.IsBold = true;
            myPane.XAxis.Scale.FontSpec.Size   = 12;
            myPane.XAxis.Scale.Format          = "d MMM";
            // make the x axis scale minimum 1 step less than the minimum data value
            myPane.XAxis.Scale.Min = hList[0].X - 1;

            // Display the Y axis grid
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.Scale.MinorStep     = 0.5;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.FromArgb(255, 255, 166), 90F);

            // Calculate the Axis Scale Ranges
            zgc.AxisChange();
        }
コード例 #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            //DEFINE DATA SOURCE
            string path = @"C:\dataset\DAT_ASCII_EURUSD_M1_2017.csv";

            string[] strs  = File.ReadAllLines(path);
            int      limit = 60; //1 hour

            //define bounds for autoscale

            //start / stop time  + delta
            DateTime min_myDateTime = (DateTime.ParseExact(strs[0].Split(';')[0].Trim('\"'), "yyyyMMdd HHmmss", null));
            DateTime max_myDateTime = (DateTime.ParseExact(strs[limit - 1].Split(';')[0].Trim('\"'), "yyyyMMdd HHmmss", null));

            double DateTime_delta = (max_myDateTime - min_myDateTime).TotalSeconds * 0.1;

            min_myDateTime = (XDate)(min_myDateTime.AddSeconds(-DateTime_delta));
            max_myDateTime = (XDate)(max_myDateTime.AddSeconds(DateTime_delta));

            //high / low price + delta
            double min_LOW  = Convert.ToDouble(strs[0].Split(';')[3].Trim('\"'));
            double max_HIGH = Convert.ToDouble(strs[0].Split(';')[2].Trim('\"'));

            double price_delta = max_HIGH - min_LOW;

            min_LOW  -= price_delta;
            max_HIGH += price_delta;


            //LOAD DATA

            double        myDateTime, HIGH, OPEN, CLOSE, LOW;
            PointPairList HighLowList = new PointPairList();

            PointPairList OpenCloseList_green = new PointPairList();
            PointPairList OpenCloseList_red   = new PointPairList();

            for (int i = 0; i < limit; i++)
            {
                myDateTime = (double)new XDate(DateTime.ParseExact(strs[i].Split(';')[0].Trim('\"'), "yyyyMMdd HHmmss", null));
                HIGH       = Convert.ToDouble(strs[i].Split(';')[2].Trim('\"'));
                OPEN       = Convert.ToDouble(strs[i].Split(';')[1].Trim('\"'));
                CLOSE      = Convert.ToDouble(strs[i].Split(';')[4].Trim('\"'));
                LOW        = Convert.ToDouble(strs[i].Split(';')[3].Trim('\"'));

                HighLowList.Add(myDateTime, HIGH, LOW);
                //  OpenCloseList.Add(myDateTime, OPEN, CLOSE);

                if (CLOSE > OPEN)
                // green-bullish (rise)

                {
                    OpenCloseList_green.Add(myDateTime, OPEN, CLOSE);
                }
                else

                // red - bearish (fall)
                {
                    OpenCloseList_red.Add(myDateTime, OPEN, CLOSE);
                }
            }

            GraphPane myPane = zedGraphControl1.GraphPane;

            //axis titles
            myPane.Title.Text       = "Stock Chart";
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "EUR USD";

            //titles font
            myPane.Title.FontSpec.Family   = "Arial";
            myPane.Title.FontSpec.IsItalic = true;
            myPane.Title.FontSpec.Size     = 18;


            ErrorBarItem curve_green = myPane.AddErrorBar("O/C rise Price", OpenCloseList_green, Color.Green);

            curve_green.Bar.PenWidth         = 5;
            curve_green.Bar.Symbol.IsVisible = false;

            ErrorBarItem curve_red = myPane.AddErrorBar("O/C fall Price", OpenCloseList_red, Color.Red);

            curve_red.Bar.PenWidth         = 5;
            curve_red.Bar.Symbol.IsVisible = false;


            ErrorBarItem myCurve = myPane.AddErrorBar("H/L Range", HighLowList, Color.Blue);

            myCurve.Bar.PenWidth         = 1;
            myCurve.Bar.Symbol.IsVisible = false;

            //window bounds
            myPane.YAxis.Scale.Min = min_LOW;
            myPane.YAxis.Scale.Max = max_HIGH;
            myPane.XAxis.Scale.Max = (XDate)(max_myDateTime);
            myPane.XAxis.Scale.Min = (XDate)(min_myDateTime);


            //XAxis type
            myPane.XAxis.Type            = AxisType.Date;
            myPane.XAxis.Scale.MajorUnit = DateUnit.Day;
            myPane.XAxis.Scale.MinorUnit = DateUnit.Minute;

            //labels angle
            myPane.XAxis.Scale.FontSpec.Angle  = 65;
            myPane.XAxis.Scale.FontSpec.IsBold = true;
            myPane.XAxis.Scale.FontSpec.Size   = 12;
            myPane.XAxis.Scale.Format          = "dd HH:mm";

            // Display the Y axis grid
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.Scale.MinorStep     = 0.1;

            //refreh chart
            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
        }
コード例 #11
0
        private void calc_button_Click(object sender, EventArgs e)
        {
            StatCollection = new Dictionary <int, List <int> >();
            List <double>[] preStatDisp  = new List <double> [DayCount];
            List <double>[] postStatDisp = new List <double> [DayCount];
            List <double>   StatDisp     = new List <double>();

            for (int z = 0; z < DayCount; z++)
            {
                preStatDisp[z]  = new List <double>();
                postStatDisp[z] = new List <double>();
            }
            foreach (HumanInfo person in Peoples)
            {
                int LifeLength = (person.DethDate - person.Bdate).Days / (int)365;
                int Key        = 365 * person.Bdate.Year + person.Bdate.DayOfYear;
                if (!StatCollection.ContainsKey(Key))
                {
                    StatCollection.Add(Key, new List <int>());
                }
                StatCollection[Key].Add(LifeLength);
            }
            FHelpForm form = new FHelpForm(StatCollection);

            //form.MdiParent = this.MdiParent;
            form.Show();
            //подсчет данных;
            int TrueDataCount = 0;

            foreach (int i in StatCollection.Keys)
            {
                bool Validate = true;
                for (int j = -DayCount; j <= DayCount; j++)
                {
                    if (!StatCollection.ContainsKey(i + j))
                    {
                        Validate = false;
                        break;
                    }
                    if (StatCollection[i + j].Count < 5)
                    {
                        Validate = false;
                        break;
                    }
                }
                if (Validate)
                {
                    TrueDataCount++;
                    for (int j = -DayCount; j <= DayCount; j++)
                    {
                        double sigma   = 0;
                        double average = 0;
                        average = StatCollection[i + j].Average();
                        int        Count    = StatCollection[i + j].Count;
                        List <int> LifeList = new List <int>();
                        if (j < 0)
                        {
                            LifeList = StatCollection[i + j];
                            LifeList.AddRange(StatCollection[i]);
                        }
                        if (j > 0)
                        {
                            LifeList = StatCollection[i + j];
                            LifeList.AddRange(StatCollection[i]);
                        }
                        if (j == 0)
                        {
                            LifeList = StatCollection[i];
                        }
                        for (int z = 0; z < Count; z++)
                        {
                            sigma += Math.Pow((average - LifeList[z]), 2);
                        }
                        sigma /= (Count + 1);
                        sigma  = Math.Sqrt(sigma);
                        if (j > 0)
                        {
                            postStatDisp[j - 1].Add(sigma);
                        }
                        if (j == 0)
                        {
                            StatDisp.Add(sigma);
                        }
                        if (j < 0)
                        {
                            preStatDisp[DayCount + j].Add(sigma);
                        }
                    }
                }
            }
            MessageBox.Show("Данные успешно посчитаны, наборов заполненых дат: " + TrueDataCount.ToString());
            // Получим панель для рисования
            GraphPane pane = zedGraph.GraphPane;

            // Очистим список кривых
            pane.CurveList.Clear();

            // Количество столбцов в гистограмме
            int itemscount = 5;

            Random rnd = new Random();

            // Высота столбцов
            PointPairList values    = new PointPairList();
            PointPairList errorList = new PointPairList();

            // Заполним данные
            for (int i = 0; i < DayCount; i++)
            {
                values.Add(1 + i, postStatDisp[i].Average());
                values.Add(-1 - i, preStatDisp[i].Average());
                errorList.Add(i - 2, values[i].Y - 10, values[i].Y + 10);
            }
            values.Add(0, StatDisp.Average());

            // Создадим точки ошибок
            ErrorBarItem errorCurve = pane.AddErrorBar("Error", errorList, Color.Black);
            // Создадим кривую-гистограмму
            BarItem curve = pane.AddBar("Гистограмма", values, Color.Blue);

            // !!!
            // Установим цвет для столбцов гистограммы
            curve.Bar.Fill.Color = Color.YellowGreen;

            // Отключим градиентную заливку
            curve.Bar.Fill.Type = FillType.Solid;

            // Сделаем границы столбцов невидимыми
            curve.Bar.Border.IsVisible = false;

            // !!! Расстояния между кластерами (группами столбиков) гистограммы = 0.0
            // У нас в кластере только один столбик.
            pane.BarSettings.MinClusterGap = 0.5f;
            pane.BarSettings.MinBarGap     = 0.5f;
            pane.BarSettings.Type          = BarType.Overlay;
            // Вызываем метод AxisChange (), чтобы обновить данные об осях.
            zedGraph.AxisChange();

            // Обновляем график
            zedGraph.Invalidate();
        }
コード例 #12
0
ファイル: Ringtest.aspx.cs プロジェクト: bytting/Lorakon
    protected void graphStatistics_OnRenderGraph(ZedGraph.Web.ZedGraphWeb z, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        GraphPane myPane = masterPane[0];

        myPane.Border.Color          = Color.White;
        myPane.Title.Text            = Lang.Statistics_for_all_members;
        myPane.XAxis.Title.Text      = "";  //Lang.Participants;
        myPane.XAxis.Scale.IsVisible = false;
        myPane.YAxis.Title.Text      = "%"; // Lang.ErrorPercent;

        myPane.YAxis.Scale.Max = 11.0f;
        myPane.YAxis.Scale.Min = -11.0f;

        myPane.Legend.IsVisible          = true;
        myPane.Chart.Fill                = new Fill(Color.White, Color.FromArgb(255, Color.White), 45.0F);
        myPane.YAxis.Scale.MaxGrace      = 0.2;
        myPane.YAxis.MajorGrid.IsVisible = true;
        myPane.YAxis.MinorGrid.IsVisible = true;

        if (String.IsNullOrEmpty(ddStatistics.SelectedValue))
        {
            myPane.Title.Text      = Lang.Statistics_for_all_members_no_results;
            myPane.XAxis.Scale.Max = 1;
            myPane.XAxis.Scale.Min = 0;
            return;
        }

        List <Guid> idList = new List <Guid>();

        try
        {
            Database.Interface.open();
            Database.Account.select_ID(ref idList, Convert.ToInt32(ddStatistics.SelectedValue));

            PointPairList list       = new PointPairList();
            PointPairList local_list = new PointPairList();
            PointPairList eList      = new PointPairList();

            int count = 0;

            foreach (Guid id in idList)
            {
                DataSet dataSet = Database.RingtestReport.select_Error_CalculatedUncertainty_RingtestBoxID_MCAType_ActivityRef_where_AccountID_Year(id, Convert.ToInt32(ddStatistics.SelectedValue));
                if (dataSet.Tables[0].Rows.Count <= 0)
                {
                    continue;
                }

                double count_offset = (double)count;
                for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                {
                    double error       = Convert.ToDouble(dataSet.Tables[0].Rows[i][0]);
                    double uncertainty = Convert.ToDouble(dataSet.Tables[0].Rows[i][1]);
                    string MCAType     = dataSet.Tables[0].Rows[i][3].ToString();
                    if (MCAType.ToLower() != "serie10")
                    {
                        double activity = Convert.ToDouble(dataSet.Tables[0].Rows[i][4]);
                        uncertainty = (uncertainty / activity) * 100.0;
                    }

                    if (id.ToString() == hiddenAccountID.Value)
                    {
                        local_list.Add(count, error);
                    }
                    else
                    {
                        list.Add(count, error);
                    }

                    eList.Add(count_offset, error + uncertainty, error - uncertainty);
                }

                count++;
            }

            if (count < 5)
            {
                myPane.CurveList.Clear();
                Utils.displayStatus(ref labelStatusStatistics, Color.SeaGreen, Lang.Number_of_results_registered_is + " " + count.ToString() + ". " + Lang.Need_5_to_display_data);
            }
            else
            {
                myPane.XAxis.Scale.Max = count;
                myPane.XAxis.Scale.Min = -1;

                LineItem curve = myPane.AddCurve("Andres rapporterte resultater", list, Color.White, SymbolType.Circle);
                curve.Line.IsVisible = false;
                curve.Symbol.Size    = 6;
                curve.Symbol.Fill    = new Fill(Color.DodgerBlue);

                LineItem local_curve = myPane.AddCurve("Egne rapporterte resultater", local_list, Color.White, SymbolType.Circle);
                local_curve.Line.IsVisible = false;
                local_curve.Symbol.Size    = 6;
                local_curve.Symbol.Fill    = new Fill(Color.IndianRed);

                ErrorBarItem errBar = myPane.AddErrorBar("Beregent usikkerhet", eList, Color.Red);
                errBar.Bar.PenWidth = 1;
            }
        }
        catch (Exception ex)
        {
            Utils.displayStatus(ref labelStatusStatistics, Color.Red, ex.Message);
        }
        finally
        {
            Database.Interface.close();
        }

        masterPane.AxisChange(g);
    }
コード例 #13
0
ファイル: Ringtest.aspx.cs プロジェクト: bytting/Lorakon
    protected void graphResults_OnRenderGraph(ZedGraph.Web.ZedGraphWeb z, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        if (hiddenAccountID.Value == null || hiddenAccountID.Value == Guid.Empty.ToString())
        {
            return;
        }

        DataSet   dataSet = null;
        GraphPane myPane  = masterPane[0];

        myPane.Border.Color     = Color.White;
        myPane.Title.Text       = Lang.OurRingtestResults;;
        myPane.XAxis.Title.Text = Lang.Years;
        myPane.YAxis.Title.Text = "%"; // Lang.ErrorPercent;

        Database.RingtestBox box = new Database.RingtestBox();

        try
        {
            Database.Interface.open();
            dataSet = Database.RingtestReport.select_Year_Error_CalculatedUncertainty_RingtestBoxID_MCAType_ActivityRef_where_AccountID(new Guid(hiddenAccountID.Value));

            PointPairList list  = new PointPairList();
            PointPairList eList = new PointPairList();
            PointPairList bList = new PointPairList();

            double maxYear = DateTime.Now.Year;
            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                Guid boxID = (Guid)dataSet.Tables[0].Rows[i][3];
                box.select_all_where_ID(boxID);

                double year        = Convert.ToDouble(dataSet.Tables[0].Rows[i][0]);
                double error       = Convert.ToDouble(dataSet.Tables[0].Rows[i][1]);
                double uncertainty = Convert.ToDouble(dataSet.Tables[0].Rows[i][2]);
                string MCAType     = dataSet.Tables[0].Rows[i][4].ToString();
                if (MCAType.ToLower() != "serie10")
                {
                    double activity = Convert.ToDouble(dataSet.Tables[0].Rows[i][5]);
                    uncertainty = (uncertainty / activity) * 100.0;
                }

                if (year > maxYear)
                {
                    maxYear = year;
                }

                list.Add(year, error);
                eList.Add(year, error + uncertainty, error - uncertainty);
                bList.Add(year, box.Uncertainty, -box.Uncertainty);
            }

            myPane.YAxis.Scale.Max           = 11.0f;
            myPane.YAxis.Scale.Min           = -11.0f;
            myPane.XAxis.Scale.Max           = maxYear + 1;
            myPane.XAxis.Scale.Min           = maxYear - 10;
            myPane.XAxis.Scale.MinorStep     = 1.0;
            myPane.XAxis.Scale.MajorStep     = 1.0;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;
            myPane.Legend.IsVisible          = true;

            LineItem curve = myPane.AddCurve(Lang.Reported_result, list, Color.White, SymbolType.Circle);
            curve.Line.IsVisible = false;
            curve.Symbol.Fill    = new Fill(Color.IndianRed);
            curve.Symbol.Size    = 6;

            ErrorBarItem errBar = myPane.AddErrorBar(Lang.CalculatedUncertainty, eList, Color.Red);
            errBar.Bar.PenWidth = 1;

            ErrorBarItem boxBar = myPane.AddErrorBar(Lang.RingtestBoxUncertainty, bList, Color.LightGray);
            boxBar.Bar.PenWidth         = 12;
            boxBar.Bar.Symbol.IsVisible = false;

            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, Color.White), 45.0F);

            const double offset = 0.1;

            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                PointPair pt = curve.Points[i];

                if (pt.Y >= myPane.YAxis.Scale.Min && pt.Y <= myPane.YAxis.Scale.Max)
                {
                    TextObj text = new TextObj(pt.Y.ToString("f2"), pt.X + offset, pt.Y, CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
                    text.FontSpec.Size             = 6;
                    text.ZOrder                    = ZOrder.A_InFront;
                    text.FontSpec.Border.IsVisible = false;
                    text.FontSpec.Fill.IsVisible   = false;
                    //text.FontSpec.Angle = 90;
                    myPane.GraphObjList.Add(text);

                    //g.DrawLine(pen, new Point((int)(pt.X + 10), (int)pt.Y), new Point((int)(pt.X - 10), (int)pt.Y));
                }
            }

            myPane.YAxis.Scale.MaxGrace = 0.2;
        }
        catch (Exception ex)
        {
            Utils.reportStatus(ref labelStatus, Color.Red, "Ringtest.graphResults_OnRenderGraph: " + ex.Message);
            return;
        }
        finally
        {
            Database.Interface.close();
        }

        masterPane.AxisChange(g);
    }