Ejemplo n.º 1
0
 public void ClearSeries()
 {
     m_DataSets.Clear();
     m_BackupSeries = null;
     this.m_fMin = this.m_fMax = float.NaN;
     FireRedrawRequired(this, new EventArgs());
 }
Ejemplo n.º 2
0
 public void RemoveSeries(GraphSeries series)
 {
     m_DataSets.Remove(series);
     series.RedrawRequired -= new EventHandler(series_RedrawRequired);
     FireRedrawRequired(this, new EventArgs());
 }
Ejemplo n.º 3
0
 public void AddSeries(GraphSeries series)
 {
     m_DataSets.Add(series);
     series.RedrawRequired += new EventHandler(series_RedrawRequired);
     RecalculateMinMax();
     FireRedrawRequired(this, new EventArgs());
 }
Ejemplo n.º 4
0
        protected void DrawDataSet(GraphSeries d, Graphics gfx, RectangleF plotRect, int lineLoc)
        {
            Color c = d.Selected ? d.DefaultColour : Color.FromArgb(m_nUnselectedTransparency, d.DefaultColour);
            Pen dataPen = new Pen(c, 2);

            //Handle the extreme cases first:
            if (float.IsInfinity(d.Max) || float.IsInfinity(d.Min) ||
                float.IsNaN(d.Max) || float.IsNaN(d.Min) || Range == 0)
            {
                //gfx.DrawLine(dataPen, new PointF(plotRect.Bottom, plotRect.Left), new PointF(plotRect.Bottom, plotRect.Right));
                return;
            }

            gfx.SetClip(plotRect);

            double pixelGranularity = Range / plotRect.Width;
            double gran = pixelGranularity > d.Granularity ? pixelGranularity : d.Granularity;
            int dataPoints = (int)(Range / gran + 1);
            if (dataPoints < 2) dataPoints = 2; //Avoid divide by zero problems, and ensure that the graph at least draws a line across it.
            PointF lastPoint = PointF.Empty;

            float XFact = plotRect.Width / (dataPoints - 1);

            float dMin;
            if (d.Logarithmic && d.Min * d.Max <= 0)
                dMin = d.Max * 1E-6f;
            else
                dMin = d.Min;

            if (d.Max == dMin)
            {
                //This is the special case of the function not varying with x. However, the function may still not be valid for all x:
                float Y = (plotRect.Top + plotRect.Bottom) / 2 + lineLoc;
                for (int i = 0; i < dataPoints; i++)
                {
                    double x = i * gran + m_dMinXValue;
                    PointF newPoint = d.ValidAt(x) ? new PointF(plotRect.Left + i * XFact, Y) : PointF.Empty;
                    if (lastPoint != PointF.Empty && newPoint != PointF.Empty)
                        gfx.DrawLine(dataPen, lastPoint, newPoint);
                    lastPoint = newPoint;
                }
            }
            else
            {
                float YFact = (float) (d.Logarithmic ? plotRect.Height  / Math.Log(d.Max / dMin) : plotRect.Height / (d.Max - dMin));
                for (int i = 0; i < dataPoints; i++)
                {
                    double x = i * gran + m_dMinXValue;
                    double y = d.ValidAt(x) ? d.ValueAt(x) : 0;
                    float yScreenSpace = (float) (d.Logarithmic ? y * dMin > 0 ? Math.Log(y/dMin) : double.NaN : (y - dMin));
                    PointF newPoint = d.ValidAt(x) && !double.IsNaN(yScreenSpace) ? new PointF(plotRect.Left + i * XFact, plotRect.Bottom - YFact * yScreenSpace) : PointF.Empty;
                    if (lastPoint != PointF.Empty && newPoint != PointF.Empty)
                        gfx.DrawLine(dataPen, lastPoint, newPoint);
                    lastPoint = newPoint;
                }
            }

            gfx.SetClip(this.ClientRectangle);
        }
Ejemplo n.º 5
0
 public void RemoveDataset(GraphSeries d)
 {
     m_Datasets.Remove(d);
     d.RedrawRequired -= new EventHandler(d_RedrawRequired);
     this.Invalidate();
 }
Ejemplo n.º 6
0
 public void AddDataset(GraphSeries d)
 {
     if (!m_Datasets.Contains(d))
     {
         m_Datasets.Add(d);
         d.RedrawRequired += new EventHandler(d_RedrawRequired);
         d.MinX = MinXValue;
         d.MaxX = MaxXValue;
     }
     this.Invalidate();
 }