Example #1
0
 static List<bool[]> CalculateValidDimensions(CurveList curves)
 {
     List<bool[]> ret = new List<bool[]>();
     foreach (CurveItem curve in curves)
         ret.Add(DimensionContainsNonZeroData(curve));
     return ret;
 }
Example #2
0
        private DataSeriesBox()
        {
            InitializeComponent();

            series = new CurveList();

            zedGraphControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
            zedGraphControl.GraphPane.Border.IsVisible = false;
            zedGraphControl.GraphPane.Border.Color = Color.White;
            zedGraphControl.GraphPane.Border.Width = 0;

            // zedGraphControl.IsAntiAlias = true;
            zedGraphControl.GraphPane.Fill = new Fill(Color.White);
            zedGraphControl.GraphPane.Chart.Fill = new Fill(Color.GhostWhite);
            zedGraphControl.GraphPane.CurveList = series;

            zedGraphControl.GraphPane.Legend.IsVisible = true;
            zedGraphControl.GraphPane.Legend.Position = LegendPos.Right;
            zedGraphControl.GraphPane.Legend.IsShowLegendSymbols = false;

            zedGraphControl.GraphPane.XAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.XAxis.MinorGrid.IsVisible = false;
            zedGraphControl.GraphPane.XAxis.MajorGrid.Color = Color.LightGray;
            zedGraphControl.GraphPane.XAxis.MajorGrid.IsZeroLine = false;
            zedGraphControl.GraphPane.XAxis.Scale.MaxGrace = 0;
            zedGraphControl.GraphPane.XAxis.Scale.MinGrace = 0;

            zedGraphControl.GraphPane.YAxis.MinorGrid.IsVisible = false;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.YAxis.MajorGrid.Color = Color.LightGray;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsZeroLine = false;
            zedGraphControl.GraphPane.YAxis.Scale.MaxGrace = 0;
            zedGraphControl.GraphPane.YAxis.Scale.MinGrace = 0;
        }
        public void addGrafica(CurveList g, DataTable dt)
        {
            tablas[posActual] = dt;
            graficas[posActual] = g.Clone();

            aumentarPos();
        }
Example #4
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The GraphPane object from which to copy</param>
        public GraphPane(GraphPane rhs)
        {
            paneRect  = rhs.PaneRect;
            xAxis     = new XAxis(rhs.XAxis);
            yAxis     = new YAxis(rhs.YAxis);
            y2Axis    = new Y2Axis(rhs.Y2Axis);
            legend    = new Legend(rhs.Legend);
            curveList = new CurveList(rhs.CurveList);
            textList  = new TextList(rhs.TextList);
            arrowList = new ArrowList(rhs.ArrowList);

            this.title       = rhs.Title;
            this.isShowTitle = rhs.IsShowTitle;
            this.fontSpec    = new FontSpec(rhs.FontSpec);

            this.isIgnoreInitial = rhs.IsIgnoreInitial;

            this.isPaneFramed      = rhs.IsPaneFramed;
            this.paneFrameColor    = rhs.PaneFrameColor;
            this.paneFramePenWidth = rhs.PaneFramePenWidth;
            this.paneBackColor     = rhs.PaneBackColor;

            this.isAxisFramed      = rhs.IsAxisFramed;
            this.axisFrameColor    = rhs.AxisFrameColor;
            this.axisFramePenWidth = rhs.AxisFramePenWidth;
            this.axisBackColor     = rhs.AxisBackColor;

            this.baseDimension = rhs.BaseDimension;
            this.paneGap       = rhs.PaneGap;
        }
Example #5
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The XAxis object from which to copy</param>
 public CurveList(CurveList rhs)
 {
     foreach (CurveItem item in rhs)
     {
         this.Add(new CurveItem(item));
     }
 }
Example #6
0
 static int CalculateMaxPoints(CurveList curves)
 {
     int max = 0;
     foreach (CurveItem curve in curves)
         max = Math.Max(max, curve.NPts);
     return max;
 }
Example #7
0
        /// <summary>
        /// Render all the <see cref="CurveItem"/> objects in the list to the
        /// specified <see cref="Graphics"/>
        /// device by calling the <see cref="CurveItem.Draw"/> member function of
        /// each <see cref="CurveItem"/> object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, GraphPane pane, float scaleFactor)
        {
            // Configure the accumulator for stacked bars
            //Bar.ResetBarStack();

            // Count the number of BarItems in the curvelist
            int pos = this.NumBars;

            // sorted overlay bars are a special case, since they are sorted independently at each
            // ordinal position.
            if (pane._barSettings.Type == BarType.SortedOverlay)
            {
                // First, create a new curveList with references (not clones) of the curves
                CurveList tempList = new CurveList();
                foreach (CurveItem curve in this)
                {
                    if (curve.IsBar)
                    {
                        tempList.Add((CurveItem)curve);
                    }
                }

                // Loop through the bars, graphing each ordinal position separately
                for (int i = 0; i < this.maxPts; i++)
                {
                    // At each ordinal position, sort the curves according to the value axis value
                    tempList.Sort(pane._barSettings.Base == BarBase.X ? SortType.YValues : SortType.XValues, i);
                    // plot the bars for the current ordinal position, in sorted order
                    foreach (BarItem barItem in tempList)
                    {
                        barItem.Bar.DrawSingleBar(g, pane, barItem,
                                                  ((BarItem)barItem).BaseAxis(pane),
                                                  ((BarItem)barItem).ValueAxis(pane),
                                                  0, i, ((BarItem)barItem).GetBarWidth(pane), scaleFactor);
                    }
                }
            }

            // Loop for each curve in reverse order to pick up the remaining curves
            // The reverse order is done so that curves that are later in the list are plotted behind
            // curves that are earlier in the list

            for (int i = this.Count - 1; i >= 0; i--)
            {
                CurveItem curve = this[i];

                if (curve.IsBar)
                {
                    pos--;
                }

                // Render the curve

                //	if it's a sorted overlay bar type, it's already been done above
                if (!(curve.IsBar && pane._barSettings.Type == BarType.SortedOverlay))
                {
                    curve.Draw(g, pane, pos, scaleFactor);
                }
            }
        }
Example #8
0
        /// <summary>
        /// Place a list of <see cref="CurveItem" />'s in the selection list, removing all other
        /// items.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ciList">The list of <see cref="CurveItem" /> to be added to the list.</param>
        public void Select(MasterPane master, CurveList ciList)
        {
            //Clear the selection, but don't send the event,
            //the event will be sent in "AddToSelection" by calling "UpdateSelection"
            ClearSelection(master, false);

            AddToSelection(master, ciList);
        }
Example #9
0
 public static void ExportToCsv(CurveList curves, string filename)
 {
     validDimensions = CalculateValidDimensions(curves);
     using (StreamWriter writer = new StreamWriter(filename, false, ASCIIEncoding.ASCII))
     {
         WriteHeaders(curves, writer);
         WriteData(curves, writer);
     }
 }
Example #10
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The XAxis object from which to copy</param>
        public CurveList(CurveList rhs)
        {
            MaxPts = rhs.MaxPts;

            foreach (var item in rhs)
            {
                Add((CurveItem)((ICloneable)item).Clone());
            }
        }
Example #11
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The XAxis object from which to copy</param>
        public CurveList(CurveList rhs)
        {
            this.maxPts = rhs.maxPts;

            foreach (CurveItem item in rhs)
            {
                this.Add((CurveItem)((ICloneable)item).Clone());
            }
        }
Example #12
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The XAxis object from which to copy</param>
        public CurveList( CurveList rhs )
        {
            this.maxPts = rhs.maxPts;

            foreach ( CurveItem item in rhs )
            {
                this.Add( (CurveItem) ((ICloneable)item).Clone() );
            }
        }
        private void asignarGrafica(ZedGraphControl z, int i)
        {
            CurveList g = new CurveList();

            g = h.getGrafica(i);

            if (g != null)
                z.GraphPane.CurveList = g;
        }
Example #14
0
 public static void SaveDataAs(CurveList curves, string filename)
 {
     string ext = Path.GetExtension(filename).ToLower();
     if (!ExportMethods.ContainsKey(ext))
     {
         MessageBox.Show("Cannot write to file format: " + ext);
         return;
     }
     ExportMethods[ext](curves, filename);
 }
        public void addGrafica(CurveList g, double finX, double finY, double inicioX, double inicioY, DataTable dt)
        {
            tablas[posActual] = dt;

            graficas[posActual] = g.Clone();
            this.finX[posActual] = finX;
            this.finY[posActual] = finY;
            this.inicioX[posActual] = inicioX;
            this.inicioY[posActual] = inicioY;
            aumentarPos();
        }
Example #16
0
        /// <summary>
        /// Add a list of <see cref="CurveItem" />'s to the selection list.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ciList">The list of <see cref="CurveItem" />'s to be added to the list.</param>
        public void AddToSelection(MasterPane master, CurveList ciList)
        {
            foreach (CurveItem ci in ciList)
            {
                if (this.Contains(ci) == false)
                {
                    this.Add(ci);
                }
            }

            UpdateSelection(master);
        }
Example #17
0
 public static void QueryUserAndSaveAs(CurveList curves)
 {
     if (curves.Count < 1)
     {
         MessageBox.Show("No data to save!");
         return;
     }
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.Filter = CreateFilter();
     if (sfd.ShowDialog() == DialogResult.OK)
         SaveDataAs(curves, sfd.FileName);
 }
Example #18
0
 static void WriteData(CurveList curves, StreamWriter writer)
 {
     int maxPoints = CalculateMaxPoints(curves);
     Console.WriteLine(maxPoints);
     for (int i = 0; i < maxPoints; i++)
     {
         Console.WriteLine("line: " + i);
         firstElementInLine = true;
         WriteDataRow(curves, i, writer);
         writer.WriteLine();
     }
 }
Example #19
0
        /// <summary>
        /// Add a list of <see cref="CurveItem" />'s to the selection list.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ciList">The list of <see cref="CurveItem" />'s to be added to the list.</param>
        public void AddToSelection(MasterPane master, CurveList ciList)
        {
            foreach (var ci in ciList)
            {
                if (Contains(ci) == false)
                {
                    Add(ci);
                }
            }

            UpdateSelection(master);
        }
        private void asignarGrafica(ZedGraphControl z, int i)
        {
            CurveList g = new CurveList();

            g = h.getGrafica(i);

            if (g != null)
            {
                z.GraphPane.CurveList = g;
                z.Invalidate();
                z.Refresh();
            }
        }
Example #21
0
        /// <summary>
        /// Render all the <see cref="CurveItem"/> objects in the list to the
        /// specified <see cref="Graphics"/>
        /// device by calling the <see cref="CurveItem.Draw"/> member function of
        /// each <see cref="CurveItem"/> object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, GraphPane pane, double scaleFactor)
        {
            // Configure the accumulator for stacked bars
            //Bar.ResetBarStack();

            // Count the number of BarItems in the curvelist
            int pos = this.NumBars;

            if (pane.BarType == BarType.SortedOverlay)
            {
                // First, create a new curveList with references (not clones) of the curves
                CurveList tempList = new CurveList();
                foreach (CurveItem curve in this)
                {
                    if (curve.IsBar)
                    {
                        tempList.Add((CurveItem)curve);
                    }
                }

                for (int i = 0; i < this.maxPts; i++)
                {
                    tempList.Sort(pane.BarBase == BarBase.X ? SortType.YValues : SortType.XValues, i);
                    foreach (BarItem barItem in tempList)
                    {
                        barItem.Bar.DrawSingleBar(g, pane, barItem,
                                                  ((BarItem)barItem).BaseAxis(pane),
                                                  ((BarItem)barItem).ValueAxis(pane, barItem.IsY2Axis),
                                                  0, i, scaleFactor);
                    }
                }
            }

            //	Loop for each curve in reverse order to pick up the remaining bartypes
            for (int i = this.Count - 1; i >= 0; i--)
            {
                CurveItem curve = this[i];

                if (curve.IsBar)
                {
                    pos--;
                }

                // Render the curve
                //	if	it's a bar type or a sorted overlay or a percentstacked bar, it's already been	done above
                if (!(pane.BarType == BarType.SortedOverlay) || !curve.IsBar)
                {
                    curve.Draw(g, pane, pos, scaleFactor);
                }
            }
        }
Example #22
0
        /// <summary>
        ///   Constructs a new instance of the ScatterplotView.
        /// </summary>
        public ScatterplotView()
        {
            InitializeComponent();

            scatterplot = new Scatterplot();

            classes = new CurveList();

            zedGraphControl.GraphPane.Title.Text = "Scatter Plot";
            zedGraphControl.GraphPane.XAxis.Title.Text = "X";
            zedGraphControl.GraphPane.YAxis.Title.Text = "Y";
            zedGraphControl.GraphPane.Fill = new Fill(Color.WhiteSmoke);
            zedGraphControl.GraphPane.CurveList = classes;
        }
Example #23
0
 public void TestEasyData()
 {
     string [] labels = {"basic1","basic2"};
     double[] x1 = { 4, 5, 6 };
     double[] y1 = { 12, 15, 18 };
     double[] x2 = { -2, -3, -4 };
     double[] y2 = { 0.01, 0.1, 1 };
     CurveList cl = new CurveList();
     cl.Add(new LineItem(labels[0], x1, y1, Color.Black, SymbolType.Circle));
     cl.Add(new LineItem(labels[1], x2, y2, Color.Black, SymbolType.Circle));
     string filename = folder + labels[0]+".csv";
     Console.WriteLine("Writing for file: " + filename);
     CsvWriter.ExportToCsv(cl, filename);
 }
        /// <summary>
        ///   Constructs a new instance of the ScatterplotView.
        /// </summary>
        /// 
        public ScatterplotView(Scatterplot scatterplot)
        {
            InitializeComponent();

            classes = new CurveList();

            zedGraphControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
            zedGraphControl.GraphPane.Border.IsVisible = false;
            zedGraphControl.GraphPane.Border.Color = Color.White;
            zedGraphControl.GraphPane.Border.Width = 0;

            // zedGraphControl.IsAntiAlias = true;
            zedGraphControl.GraphPane.Fill = new Fill(Color.White);
            zedGraphControl.GraphPane.Chart.Fill = new Fill(Color.GhostWhite);
            zedGraphControl.GraphPane.CurveList = classes;

            zedGraphControl.GraphPane.Legend.IsVisible = true;
            zedGraphControl.GraphPane.Legend.Position = LegendPos.Right;
            zedGraphControl.GraphPane.Legend.IsShowLegendSymbols = false;

            zedGraphControl.GraphPane.XAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.XAxis.MinorGrid.IsVisible = false;
            zedGraphControl.GraphPane.XAxis.MajorGrid.Color = Color.LightGray;
            zedGraphControl.GraphPane.XAxis.MajorGrid.IsZeroLine = false;
            zedGraphControl.GraphPane.XAxis.Scale.MaxGrace = 0;
            zedGraphControl.GraphPane.XAxis.Scale.MinGrace = 0;

            zedGraphControl.GraphPane.YAxis.MinorGrid.IsVisible = false;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsVisible = true;
            zedGraphControl.GraphPane.YAxis.MajorGrid.Color = Color.LightGray;
            zedGraphControl.GraphPane.YAxis.MajorGrid.IsZeroLine = false;
            zedGraphControl.GraphPane.YAxis.Scale.MaxGrace = 0;
            zedGraphControl.GraphPane.YAxis.Scale.MinGrace = 0;

            ScaleTight = false;
            SymbolSize = 7;
            LinesVisible = false;

            this.scatterplot = scatterplot;
        }
Example #25
0
 public void TestComplexData()
 {
     string[] labels = { "complex1", "complex2","complex3" };
     double[] x1 = { 4e12, 5e13, 6e14 };
     double[] y1 = { 12e-10, 15e-10, 18e-10 };
     double[] x2 = { -2, -3, -4, -5, -6, -7, -8, -9, -10, -11 };
     double[] y2 = { 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000, 100000, 1000000 };
     double[] z2 = { 1.23453456345345345, 2.6450985347635, 3.45237895638925, 4.42378962387534, 5.4532498734563,
                       6.429874343, 7.5349857345, 8.5347637634, 9.3764684593453, 10.53948756876345 };
     double[] x3 = { 1, 2, 3, 4, 5, 6, 7, 8 };
     double[] y3 = new double[x3.Length];
     CurveList cl = new CurveList();
     cl.Add(new LineItem(labels[0], x1, y1, Color.Black, SymbolType.Circle));
     PointPairList ppl = new PointPairList();
     for(int i = 0; i < x2.Length; i++)
         ppl.Add(x2[i],y2[i],z2[i]);
     cl.Add(new LineItem(labels[1], ppl, Color.Black, SymbolType.Circle));
     cl.Add(new LineItem(labels[2], x3, y3, Color.Black, SymbolType.Circle));
     string filename = folder + labels[0] + ".csv";
     Console.WriteLine("Writing for file: " + filename);
     CsvWriter.ExportToCsv(cl, filename);
 }
Example #26
0
        public RectangleF axisRect;                                     // The area of the pane defined by the axes

        /// <summary>
        /// Constructor for the <see cref="GraphPane"/> object.  This routine will
        /// initialize all member variables and classes, setting appropriate default
        /// values as defined in the <see cref="Def"/> class.
        /// </summary>
        /// <param name="paneRect"> A rectangular screen area where the graph is to be displayed.
        /// This area can be any size, and can be resize at any time using the
        /// <see cref="PaneRect"/> property.
        /// </param>
        /// <param name="paneTitle">The <see cref="Axis.Title"/> for this <see cref="GraphPane"/></param>
        /// <param name="xTitle">The <see cref="Axis.Title"/> for the <see cref="XAxis"/></param>
        /// <param name="yTitle">The <see cref="Axis.Title"/> for the <see cref="YAxis"/></param>
        public GraphPane(RectangleF paneRect, string paneTitle,
                         string xTitle, string yTitle)
        {
            this.paneRect = paneRect;

            xAxis     = new XAxis(xTitle);
            yAxis     = new YAxis(yTitle);
            y2Axis    = new Y2Axis("");
            legend    = new Legend();
            curveList = new CurveList();
            textList  = new TextList();
            arrowList = new ArrowList();

            this.title       = paneTitle;
            this.isShowTitle = Def.Pane.ShowTitle;
            this.fontSpec    = new FontSpec(Def.Pane.FontFamily,
                                            Def.Pane.FontSize, Def.Pane.FontColor, Def.Pane.FontBold,
                                            Def.Pane.FontItalic, Def.Pane.FontUnderline);
            this.fontSpec.IsFilled = false;
            this.fontSpec.IsFramed = false;

            this.isIgnoreInitial = Def.Ax.IgnoreInitial;

            this.isPaneFramed      = Def.Pane.IsFramed;
            this.paneFrameColor    = Def.Pane.FrameColor;
            this.paneFramePenWidth = Def.Pane.FramePenWidth;
            this.paneBackColor     = Def.Pane.BackColor;

            this.isAxisFramed      = Def.Ax.IsFramed;
            this.axisFrameColor    = Def.Ax.FrameColor;
            this.axisFramePenWidth = Def.Ax.FramePenWidth;
            this.axisBackColor     = Def.Ax.BackColor;

            this.baseDimension = Def.Pane.BaseDimension;
            this.paneGap       = Def.Pane.Gap;
        }
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The GraphPane object from which to copy</param>
        public GraphPane( GraphPane rhs )
            : base(rhs)
        {
            // copy values for all the value types
            _isIgnoreInitial = rhs.IsIgnoreInitial;
            _isBoundedRanges = rhs._isBoundedRanges;
            _isAlignGrids = rhs._isAlignGrids;

            _chart = rhs._chart.Clone();

            _barSettings = new BarSettings( rhs._barSettings, this );

            _lineType = rhs.LineType;

            // copy all the reference types with deep copies
            _xAxis = new XAxis( rhs.XAxis );
            _x2Axis = new X2Axis( rhs.X2Axis );

            _yAxisList = new YAxisList( rhs._yAxisList );
            _y2AxisList = new Y2AxisList( rhs._y2AxisList );

            _curveList = new CurveList( rhs.CurveList );
            _zoomStack = new ZoomStateStack( rhs._zoomStack );
        }
        /// <summary>
        /// Find the data point that lies closest to the specified mouse (screen)
        /// point.
        /// </summary>
        /// <remarks>
        /// This method will search through the specified list of curves to find which point is
        /// nearest.  It will only consider points that are within
        /// <see cref="Default.NearestTol"/> pixels of the screen point, and it will
        /// only consider <see cref="CurveItem"/>'s that are in 
        /// <paramref name="targetCurveList"/>.
        /// </remarks>
        /// <param name="mousePt">The screen point, in pixel coordinates.</param>
        /// <param name="targetCurveList">A <see cref="CurveList"/> object containing
        /// a subset of <see cref="CurveItem"/>'s to be searched.</param>
        /// <param name="nearestCurve">A reference to the <see cref="CurveItem"/>
        /// instance that contains the closest point.  nearestCurve will be null if
        /// no data points are available.</param>
        /// <param name="iNearest">The index number of the closest point.  The
        /// actual data vpoint will then be <see cref="CurveItem.Points">CurveItem.Points[iNearest]</see>
        /// .  iNearest will
        /// be -1 if no data points are available.</param>
        /// <returns>true if a point was found and that point lies within
        /// <see cref="Default.NearestTol"/> pixels
        /// of the screen point, false otherwise.</returns>
        public bool FindNearestPoint( PointF mousePt, CurveList targetCurveList,
			out CurveItem nearestCurve, out int iNearest )
        {
            CurveItem nearestBar = null;
            int iNearestBar = -1;
            nearestCurve = null;
            iNearest = -1;

            // If the point is outside the ChartRect, always return false
            if ( !_chart._rect.Contains( mousePt ) )
                return false;

            double x, x2;
            double[] y;
            double[] y2;

            //ReverseTransform( mousePt, out x, out y, out y2 );
            ReverseTransform( mousePt, out x, out x2, out y, out y2 );

            if ( !AxisRangesValid() )
                return false;

            ValueHandler valueHandler = new ValueHandler( this, false );

            double xPixPerUnit = _chart._rect.Width / ( _xAxis._scale._max - _xAxis._scale._min );
            //double	yPixPerUnit = chartRect.Height / ( yAxis.Max - yAxis.Min );
            //double	y2PixPerUnit; // = chartRect.Height / ( y2Axis.Max - y2Axis.Min );

            double yPixPerUnitAct, yAct, yMinAct, yMaxAct;
            double minDist = 1e20;
            double xVal, yVal, dist = 99999, distX, distY;
            double tolSquared = Default.NearestTol * Default.NearestTol;

            int iBar = 0;

            foreach ( CurveItem curve in targetCurveList )
            {
                //test for pie first...if it's a pie rest of method superfluous
                if ( curve is PieItem && curve.IsVisible )
                {
                    if ( ( (PieItem)curve ).SlicePath != null &&
                            ( (PieItem)curve ).SlicePath.IsVisible( mousePt ) )
                    {
                        nearestBar = curve;
                        iNearestBar = 0;
                    }

                    continue;
                }
                else if ( curve.IsVisible )
                {
                    int yIndex = curve.GetYAxisIndex( this );
                    Axis yAxis = curve.GetYAxis( this );

                    if ( curve.IsY2Axis )
                    {
                        yAct = y2[yIndex];
                        yMinAct = _y2AxisList[yIndex]._scale._min;
                        yMaxAct = _y2AxisList[yIndex]._scale._max;
                    }
                    else
                    {
                        yAct = y[yIndex];
                        yMinAct = _yAxisList[yIndex]._scale._min;
                        yMaxAct = _yAxisList[yIndex]._scale._max;
                    }

                    yPixPerUnitAct = _chart._rect.Height / ( yMaxAct - yMinAct );

                    IPointList points = curve.Points;
                    float barWidth = curve.GetBarWidth( this );
                    double barWidthUserHalf;
                    Axis baseAxis = curve.BaseAxis( this );
                    bool isXBaseAxis = ( baseAxis is XAxis || baseAxis is X2Axis );
                    if ( isXBaseAxis )
                        barWidthUserHalf = barWidth / xPixPerUnit / 2.0;
                    else
                        barWidthUserHalf = barWidth / yPixPerUnitAct / 2.0;

                    if ( points != null )
                    {
                        for ( int iPt = 0; iPt < curve.NPts; iPt++ )
                        {
                            // xVal is the user scale X value of the current point
                            if ( _xAxis._scale.IsAnyOrdinal && !curve.IsOverrideOrdinal )
                                xVal = (double)iPt + 1.0;
                            else
                                xVal = points[iPt].X;

                            // yVal is the user scale Y value of the current point
                            if ( yAxis._scale.IsAnyOrdinal && !curve.IsOverrideOrdinal )
                                yVal = (double)iPt + 1.0;
                            else
                                yVal = points[iPt].Y;

                            if ( xVal != PointPair.Missing &&
                                    yVal != PointPair.Missing )
                            {

                                if ( curve.IsBar || curve is ErrorBarItem ||
                                    curve is HiLowBarItem || curve is OHLCBarItem ||
                                    curve is JapaneseCandleStickItem )
                                {
                                    double baseVal, lowVal, hiVal;
                                    valueHandler.GetValues( curve, iPt, out baseVal,
                                            out lowVal, out hiVal );

                                    if ( lowVal > hiVal )
                                    {
                                        double tmpVal = lowVal;
                                        lowVal = hiVal;
                                        hiVal = tmpVal;
                                    }

                                    if ( isXBaseAxis )
                                    {

                                        double centerVal = valueHandler.BarCenterValue( curve, barWidth, iPt, xVal, iBar );

                                        if ( x < centerVal - barWidthUserHalf ||
                                                x > centerVal + barWidthUserHalf ||
                                                yAct < lowVal || yAct > hiVal )
                                            continue;
                                    }
                                    else
                                    {
                                        double centerVal = valueHandler.BarCenterValue( curve, barWidth, iPt, yVal, iBar );

                                        if ( yAct < centerVal - barWidthUserHalf ||
                                                yAct > centerVal + barWidthUserHalf ||
                                                x < lowVal || x > hiVal )
                                            continue;
                                    }

                                    if ( nearestBar == null )
                                    {
                                        iNearestBar = iPt;
                                        nearestBar = curve;
                                    }
                                }
                                else if ( xVal >= _xAxis._scale._min && xVal <= _xAxis._scale._max &&
                                            yVal >= yMinAct && yVal <= yMaxAct )
                                {
                                    if ( curve is LineItem && _lineType == LineType.Stack )
                                    {
                                        double zVal;
                                        valueHandler.GetValues( curve, iPt, out xVal, out zVal, out yVal );
                                    }

                                    distX = ( xVal - x ) * xPixPerUnit;
                                    distY = ( yVal - yAct ) * yPixPerUnitAct;
                                    dist = distX * distX + distY * distY;

                                    if ( dist >= minDist )
                                        continue;

                                    minDist = dist;
                                    iNearest = iPt;
                                    nearestCurve = curve;
                                }

                            }
                        }

                        if ( curve.IsBar )
                            iBar++;
                    }
                }
            }

            if ( nearestCurve is LineItem )
            {
                float halfSymbol = (float)( ( (LineItem)nearestCurve ).Symbol.Size *
                    CalcScaleFactor() / 2 );
                minDist -= halfSymbol * halfSymbol;
                if ( minDist < 0 )
                    minDist = 0;
            }

            if ( minDist >= tolSquared && nearestBar != null )
            {
                // if no point met the tolerance, but a bar was found, use it
                nearestCurve = nearestBar;
                iNearest = iNearestBar;
                return true;
            }
            else if ( minDist < tolSquared )
            {
                // Did we find a close point, and is it within the tolerance?
                // (minDist is the square of the distance in pixel units)
                return true;
            }
            else  // otherwise, no valid point found
                return false;
        }
        /// <summary>
        /// Constructor for the <see cref="GraphPane"/> object.  This routine will
        /// initialize all member variables and classes, setting appropriate default
        /// values as defined in the <see cref="Default"/> class.
        /// </summary>
        /// <param name="rect"> A rectangular screen area where the graph is to be displayed.
        /// This area can be any size, and can be resize at any time using the
        /// <see cref="PaneBase.Rect"/> property.
        /// </param>
        /// <param name="title">The <see cref="PaneBase.Title"/> for this <see cref="GraphPane"/></param>
        /// <param name="xTitle">The <see cref="Axis.Title"/> for the <see cref="XAxis"/></param>
        /// <param name="yTitle">The <see cref="Axis.Title"/> for the <see cref="YAxis"/></param>
        public GraphPane( RectangleF rect, string title,
			string xTitle, string yTitle )
            : base(title, rect)
        {
            _xAxis = new XAxis( xTitle );
            _x2Axis = new X2Axis( "" );

            _yAxisList = new YAxisList();
            _y2AxisList = new Y2AxisList();

            _yAxisList.Add( new YAxis( yTitle ) );
            _y2AxisList.Add( new Y2Axis( string.Empty ) );

            _curveList = new CurveList();
            _zoomStack = new ZoomStateStack();

            _isIgnoreInitial = Default.IsIgnoreInitial;
            _isBoundedRanges = Default.IsBoundedRanges;
            _isAlignGrids = false;

            _chart = new Chart();

            _barSettings = new BarSettings( this );

            _lineType = Default.LineType;
        }
        /// <summary>
        /// Find the data point that lies closest to the specified mouse (screen)
        /// point for the specified curve.
        /// </summary>
        /// <remarks>
        /// This method will search only through the points for the specified
        /// curve to determine which point is
        /// nearest the mouse point.  It will only consider points that are within
        /// <see cref="Default.NearestTol"/> pixels of the screen point.
        /// </remarks>
        /// <param name="mousePt">The screen point, in pixel coordinates.</param>
        /// <param name="nearestCurve">A reference to the <see cref="CurveItem"/>
        /// instance that contains the closest point.  nearestCurve will be null if
        /// no data points are available.</param>
        /// <param name="targetCurve">A <see cref="CurveItem"/> object containing
        /// the data points to be searched.</param>
        /// <param name="iNearest">The index number of the closest point.  The
        /// actual data vpoint will then be <see cref="CurveItem.Points">CurveItem.Points[iNearest]</see>
        /// .  iNearest will
        /// be -1 if no data points are available.</param>
        /// <returns>true if a point was found and that point lies within
        /// <see cref="Default.NearestTol"/> pixels
        /// of the screen point, false otherwise.</returns>
        public bool FindNearestPoint( PointF mousePt, CurveItem targetCurve,
				out CurveItem nearestCurve, out int iNearest )
        {
            CurveList targetCurveList = new CurveList();
            targetCurveList.Add( targetCurve );
            return FindNearestPoint( mousePt, targetCurveList,
                out nearestCurve, out iNearest );
        }
        // Revision: JCarpenter 10/06
        /// <summary>
        /// Find any objects that exist within the specified (screen) rectangle.
        /// This method will search through all of the graph objects, such as
        /// <see cref="Axis"/>, <see cref="Legend"/>, <see cref="PaneBase.Title"/>,
        /// <see cref="GraphObj"/>, and <see cref="CurveItem"/>.
        /// and see if the objects' bounding boxes are within the specified (screen) rectangle
        /// This method returns true if any are found.
        /// </summary>
        public bool FindContainedObjects( RectangleF rectF, Graphics g,
			 out CurveList containedObjs )
        {
            containedObjs = new CurveList();

            foreach ( CurveItem ci in this.CurveList )
            {
                for ( int i = 0; i < ci.Points.Count; i++ )
                {
                    if ( ci.Points[i].X > rectF.Left &&
                         ci.Points[i].X < rectF.Right &&
                         ci.Points[i].Y > rectF.Bottom &&
                         ci.Points[i].Y < rectF.Top )
                    {
                        containedObjs.Add( ci );
                    }
                }
            }
            return ( containedObjs.Count > 0 );
        }
        public frmRespuestaTransienteLocus(String respTr)
        {
            //Seteo la cultura para utilizar el punto como separador decimal
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            InitializeComponent();
            pnlAcciones.Hide();
            respTransiente = respTr;

            //h = new Historial();
            //this.h = his;

            CurveList g = new CurveList();

            //g = h.getGrafica(0);

            //if (g.Count != 0)
            //    this.btnComparar.Enabled = true;
            //else
            //    this.btnComparar.Enabled = false;

            //--------------DB---------------//
            persRespuestas = new persGraficaMySql(respTransiente);
            //--------------DB---------------//

            //lstArchivos.DataSource = generarLista();
            //generarLista(lstArchivos);

            //Desactivo las opciones no permitidas
            guardarToolStripMenuItem.Enabled = false;
            eliminarToolStripMenuItem.Enabled = false;

            //Se inicializa la Respuesta Transiente correspondiente según corresponda con el parámetro respTransiente
            //Además, se setea el título de la ventana correspondiente a la función seleccionada
            //Tamibén setea la imagen con la fórmula correspondiente en cada caso
            if (respTransiente.Equals("Escalon1")) {
                this.Text = this.Text + ", Sistemas de Primer Orden, Entrada Escalón";
                iniciarComponentesGrafica(new EntradaEscalonOrden1());
                agregarComponentes();
                pbFormula.Image = TeoriaDeControl.Properties.Resources.FormulaEscalon1Orden;
            }
            else if (respTransiente.Equals("Impulso1")) {
                this.Text = this.Text + ", Sistemas de Primer Orden, Entrada Impulso";
                iniciarComponentesGrafica(new EntradaImpulsoOrden1());
                agregarComponentes();
                pbFormula.Image = TeoriaDeControl.Properties.Resources.FormulaImpulso1Orden;
            }
            else if (respTransiente.Equals("Senoidal1"))
            {
                this.Text = this.Text + ", Sistemas de Primer Orden, Entrada Senoidal";
                iniciarComponentesGrafica(new EntradaSenoidalOrden1());
                agregarComponentes();
                pbFormula.Image = TeoriaDeControl.Properties.Resources.FormulaSenoidal1Orden;
            }
            else if (respTransiente.Equals("Rampa1"))
            {
                this.Text = this.Text + ", Sistemas de Primer Orden, Entrada Rampa";
                iniciarComponentesGrafica(new EntradaRampaOrden1());
                agregarComponentes();
                pbFormula.Image = TeoriaDeControl.Properties.Resources.FormulaRampa1Orden;
            }
            else if (respTransiente.Equals("Escalon2"))
            {
                this.Text = this.Text + ", Sistemas de Segundo Orden, Entrada Escalón";
                iniciarComponentesGrafica(new EntradaEscalonOrden2());
                agregarComponentes();
                pbFormula.Image = TeoriaDeControl.Properties.Resources.FormulaEscalon2Orden1;
            }
            else if (respTransiente.Equals("Impulso2"))
            {
                this.Text = this.Text + ", Sistemas de Segundo Orden, Entrada Impulso";
                iniciarComponentesGrafica(new EntradaImpulsoOrden2());
                agregarComponentes();
                pbFormula.Image = TeoriaDeControl.Properties.Resources.FormulaImpulso2Orden1;
            }
            else if (respTransiente.Equals("Senoidal2"))
            {
                this.Text = this.Text + ", Sistemas de Segundo Orden, Entrada Senoidal";
                iniciarComponentesGrafica(new EntradaSenoidalOrden2());
                agregarComponentes();
                pbFormula.Image = TeoriaDeControl.Properties.Resources.FormulaSenoidal2Orden1;
            }
            this.Text += "                         ";
        }
Example #33
0
        public void DisplayCurves()
        {
            CurveList allCurves = new CurveList(mCurveList);
            allCurves.AddRange(highlightList);
            graph.GraphPane.CurveList = allCurves;

            if (ScaleType != AxisScaleType.UserDefined)
            {
                this.ScaleAxes();
                this.UpdateAxes();
            }
        }
Example #34
0
 private static void AssertCurveListsSame(CurveList curveList1, CurveList curveList2)
 {
     CollectionAssert.AreEqual(curveList1.Select(curve=>curve.Label.Text).ToArray(), curveList2.Select(curve=>curve.Label.Text).ToArray());
     CollectionAssert.AreEqual(curveList1.Select(curve=>curve.Color).ToArray(), curveList2.Select(curve=>curve.Color).ToArray());
 }
Example #35
0
        /// <summary>
        /// Render all the <see cref="CurveItem"/> objects in the list to the
        /// specified <see cref="Graphics"/>
        /// device by calling the <see cref="CurveItem.Draw"/> member function of
        /// each <see cref="CurveItem"/> object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw( Graphics g, GraphPane pane, float scaleFactor )
        {
            // Configure the accumulator for stacked bars
            //Bar.ResetBarStack();

            // Count the number of BarItems in the curvelist
            int pos = this.NumBars;

            // sorted overlay bars are a special case, since they are sorted independently at each
            // ordinal position.
            if ( pane._barSettings.Type == BarType.SortedOverlay )
            {
                // First, create a new curveList with references (not clones) of the curves
                CurveList tempList = new CurveList();
                foreach ( CurveItem curve in this )
                    if ( curve.IsBar )
                        tempList.Add( (CurveItem) curve );

                // Loop through the bars, graphing each ordinal position separately
                for ( int i=0; i<this.maxPts; i++ )
                {
                    // At each ordinal position, sort the curves according to the value axis value
                    tempList.Sort( pane._barSettings.Base == BarBase.X ? SortType.YValues : SortType.XValues, i );
                    // plot the bars for the current ordinal position, in sorted order
                    foreach ( BarItem barItem in tempList )
                        barItem.Bar.DrawSingleBar( g, pane, barItem,
                            ((BarItem)barItem).BaseAxis( pane ),
                            ((BarItem)barItem).ValueAxis( pane ),
                            0, i, ( (BarItem)barItem ).GetBarWidth( pane ), scaleFactor );
                }
            }

            // Loop for each curve in reverse order to pick up the remaining curves
            // The reverse order is done so that curves that are later in the list are plotted behind
            // curves that are earlier in the list

            for ( int i = this.Count - 1; i >= 0; i-- )
            {
                CurveItem curve = this[i];

                if ( curve.IsBar )
                    pos--;

                // Render the curve

                //	if it's a sorted overlay bar type, it's already been done above
                if ( !( curve.IsBar && pane._barSettings.Type == BarType.SortedOverlay ) )
                {
                    curve.Draw( g, pane, pos, scaleFactor );
                }
            }
        }
Example #36
0
        // Revision: JCarpenter 10/06
        /// <summary>
        /// Perform selection on curves within the drag pane, or under the mouse click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HandleSelectionFinish(object sender, MouseEventArgs e)
        {
            if (e.Button != _selectButtons) {
                Refresh();
                return;
            }

            PointF mousePtF = BoundPointToRect(new Point(e.X, e.Y), _dragPane.Chart._rect);

            PointF mousePt = BoundPointToRect(new Point(e.X, e.Y), _dragPane.Rect);

            Point curPt = ((Control)sender).PointToScreen(Point.Round(mousePt));

            // Only accept a drag if it covers at least 5 pixels in each direction
            //Point curPt = ( (Control)sender ).PointToScreen( Point.Round( mousePt ) );
            if ((Math.Abs(mousePtF.X - _dragStartPt.X) > 4) &&
                (Math.Abs(mousePtF.Y - _dragStartPt.Y) > 4)) {
                #region New Code to Select on Rubber Band

                double x1, x2, xx1, xx2;
                double[] y1, y2, yy1, yy2;
                PointF startPoint =
                    ((Control)sender).PointToClient(new Point(Convert.ToInt32(this._dragPane.Rect.X),
                                                               Convert.ToInt32(this._dragPane.Rect.Y)));

                _dragPane.ReverseTransform(_dragStartPt, out x1, out xx1, out y1, out yy1);
                _dragPane.ReverseTransform(mousePtF, out x2, out xx2, out y2, out yy2);

                CurveList objects = new CurveList();

                double left = Math.Min(x1, x2);
                double right = Math.Max(x1, x2);

                double top = 0;
                double bottom = 0;

                for (int i = 0; i < y1.Length; i++) {
                    bottom = Math.Min(y1[i], y2[i]);
                    top = Math.Max(y1[i], y2[i]);
                }

                for (int i = 0; i < yy1.Length; i++) {
                    bottom = Math.Min(bottom, yy2[i]);
                    bottom = Math.Min(yy1[i], bottom);
                    top = Math.Max(top, yy2[i]);
                    top = Math.Max(yy1[i], top);
                }

                double w = right - left;
                double h = bottom - top;

                RectangleF rF = new RectangleF((float)left, (float)top, (float)w, (float)h);

                _dragPane.FindContainedObjects(rF, this.CreateGraphics(), out objects);

                if (Control.ModifierKeys == _selectAppendModifierKeys)
                    _selection.AddToSelection(_masterPane, objects);
                else
                    _selection.Select(_masterPane, objects);
                //				this.Select( objects );

                //Graphics g = this.CreateGraphics();
                //this._dragPane.AxisChange( g );
                //g.Dispose();

                #endregion
            }
            else // It's a single-select
            {
                #region New Code to Single Select

                //Point mousePt = new Point( e.X, e.Y );

                int iPt;
                GraphPane pane;
                object nearestObj;

                using (Graphics g = this.CreateGraphics()) {
                    if (this.MasterPane.FindNearestPaneObject(mousePt, g, out pane,
                                                              out nearestObj, out iPt)) {
                        if (nearestObj is CurveItem && iPt >= 0) {
                            if (Control.ModifierKeys == _selectAppendModifierKeys)
                                _selection.AddToSelection(_masterPane, nearestObj as CurveItem);
                            else
                                _selection.Select(_masterPane, nearestObj as CurveItem);
                        }
                        else
                            _selection.ClearSelection(_masterPane);

                        Refresh();
                    }
                    else {
                        _selection.ClearSelection(_masterPane);
                    }
                }

                #endregion New Code to Single Select
            }

            using (Graphics g = this.CreateGraphics()) {
                // always AxisChange() the dragPane
                _dragPane.AxisChange(g);

                foreach (GraphPane pane in _masterPane._paneList) {
                    if (pane != _dragPane && (_isSynchronizeXAxes || _isSynchronizeYAxes))
                        pane.AxisChange(g);
                }
            }

            Refresh();
        }
Example #37
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The XAxis object from which to copy</param>
 public CurveList(CurveList rhs)
 {
     MaxPts = rhs.MaxPts;
     rhs.ForEach(ci => Add((CurveItem)((ICloneable)ci).Clone()));
 }
        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected GraphPane( SerializationInfo info, StreamingContext context )
            : base(info, context)
        {
            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32( "schema2" );

            _xAxis = (XAxis)info.GetValue( "xAxis", typeof( XAxis ) );
            if ( sch >= 11 )
                _x2Axis = (X2Axis)info.GetValue( "x2Axis", typeof( X2Axis ) );
            else
                _x2Axis = new X2Axis( "" );

            _yAxisList = (YAxisList)info.GetValue( "yAxisList", typeof( YAxisList ) );
            _y2AxisList = (Y2AxisList)info.GetValue( "y2AxisList", typeof( Y2AxisList ) );

            _curveList = (CurveList)info.GetValue( "curveList", typeof( CurveList ) );

            _chart = (Chart) info.GetValue( "chart", typeof( Chart ) );

            _barSettings = (BarSettings)info.GetValue( "barSettings", typeof( BarSettings ) );
            _barSettings._ownerPane = this;

            _isIgnoreInitial = info.GetBoolean( "isIgnoreInitial" );
            _isBoundedRanges = info.GetBoolean( "isBoundedRanges" );
            _isIgnoreMissing = info.GetBoolean( "isIgnoreMissing" );
            _isAlignGrids = info.GetBoolean( "isAlignGrids" );

            _lineType = (LineType)info.GetValue( "lineType", typeof( LineType ) );

            _zoomStack = new ZoomStateStack();
        }
Example #39
0
		/// <summary>
		/// Add a list of <see cref="CurveItem" />'s to the selection list.
		/// </summary>
		/// <param name="master">The <see cref="MasterPane" /> that is the "owner"
		/// of the <see cref="CurveItem" />'s.</param>
		/// <param name="ciList">The list of <see cref="CurveItem" />'s to be added to the list.</param>
		public void AddToSelection( MasterPane master, CurveList ciList )
		{
			foreach ( CurveItem ci in ciList )
			{
				if ( this.Contains( ci ) == false )
					this.Add( ci );
			}

			UpdateSelection( master );
		}
Example #40
0
		/// <summary>
		/// Place a list of <see cref="CurveItem" />'s in the selection list, removing all other
		/// items.
		/// </summary>
		/// <param name="master">The <see cref="MasterPane" /> that is the "owner"
		/// of the <see cref="CurveItem" />'s.</param>
		/// <param name="ciList">The list of <see cref="CurveItem" /> to be added to the list.</param>
		public void Select( MasterPane master, CurveList ciList )
		{
			//Clear the selection, but don't send the event,
			//the event will be sent in "AddToSelection" by calling "UpdateSelection"
			ClearSelection( master, false );

			AddToSelection( master, ciList );
		}
Example #41
0
        /// <summary>
        /// Render all the <see cref="CurveItem"/> objects in the list to the
        /// specified <see cref="Graphics"/>
        /// device by calling the <see cref="CurveItem.Draw"/> member function of
        /// each <see cref="CurveItem"/> object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, GraphPane pane, float scaleFactor)
        {
            // Configure the accumulator for stacked bars
            //Bar.ResetBarStack();

            // Count the number of BarItems in the curvelist
            int pos = NumBars;

            // sorted overlay bars are a special case, since they are sorted independently at each
            // ordinal position.
            if (pane._barSettings.Type == BarType.SortedOverlay)
            {
                // First, create a new curveList with references (not clones) of the curves
                var tempList = new CurveList();
                tempList.AddRange(this.Where(curve => curve.IsBar));

                // Loop through the bars, graphing each ordinal position separately
                for (var i = 0; i < MaxPts; i++)
                {
                    // At each ordinal position, sort the curves according to the value axis value
                    tempList.Sort(pane._barSettings.Base == BarBase.X ? SortType.YValues : SortType.XValues, i);
                    // plot the bars for the current ordinal position, in sorted order
                    foreach (var barItem in tempList.Cast <BarItem>())
                    {
                        barItem.Bar.DrawSingleBar(g, pane, barItem,
                                                  barItem.BaseAxis(pane),
                                                  barItem.ValueAxis(pane),
                                                  0, i, barItem.GetBarWidth(pane), scaleFactor);
                    }
                }
            }

            var list = this.Where(c => !(c.IsBar && pane._barSettings.Type == BarType.SortedOverlay));

            // Loop over the remaining curves first drawing the ones that have ZOrder set.
            // The list is already sorted respecting curves' ZOrder.
            foreach (var curve in list.Where(c => c.ZOrder >= 0))
            {
                if (curve.IsBar)
                {
                    pos--;
                }

                //  if it's a sorted overlay bar type, it's already been done above
                curve.Draw(g, pane, pos, scaleFactor);
            }

            // Loop for each curve in reverse order to pick up the remaining curves.
            // The reverse order is done so that curves that are later in the list are plotted behind
            // curves that are earlier in the list.
            foreach (var curve in list.Where(c => c.ZOrder < 0).Reverse())
            {
                if (curve.IsBar)
                {
                    pos--;
                }

                // Render the curve

                //  if it's a sorted overlay bar type, it's already been done above
                curve.Draw(g, pane, pos, scaleFactor);
            }
        }
        /// <summary>
        /// Initliase the Active Learning graph
        /// </summary>
        private void InitialiseActiveLearningGraphs()
        {
            //AccuracyGraph Settings
            accuracyGraphPane = graphControlAccuracyGraph.GraphPane;
            accuracyGraphPane.CurveList.Clear() ; //clear the curveList in the graphpane

            //set x starting point of the AccuracyGraph
            accuracyGraphPane.XAxis.Scale.Min = currentExperimentSetting.initialStartingLabel - 1;

            //add curves into the accuracyGraphPane
            List<ExperimentModel> currentExperimentItemsList = currentExperimentSetting.experimentModels;

            for (int i = 0; i < currentExperimentItemsList.Count; i++)
            {
                // The RollingPointPairList is an efficient storage class that always
                // keeps a rolling set of point data without needing to shift any data values
                RollingPointPairList list = new RollingPointPairList(currentExperimentSetting.currentDataset.totalNumberOfLabellingRows);

                //Add the curve with an empty datalist into the accuracyGraphPane
                LineItem curve = accuracyGraphPane.AddCurve(currentExperimentItemsList[i].ToString(), list, colourOptions[i], SymbolType.None);
                curve.Line.Width = 2.0f;
            }

            //scale the axes
            accuracyGraphPane.AxisChange();
            //set the CurveList
            accuracyGraphCurveList = accuracyGraphPane.CurveList;
            graphControlAccuracyGraph.Visible = true;
           
        }