Ejemplo n.º 1
0
        public void Draw(Graphics g, AxisCollection yAxisCollection, XAxis xAxis, AdvancedRect area)
        {
            GraphicsState _s = g.Save();

            g.SetClip(area.Rect);
            foreach (KeyValuePair <string, Series> s in seriesByName)
            {
                s.Value.Draw(g, yAxisCollection, xAxis, area);
            }
            g.Restore(_s);
        }
Ejemplo n.º 2
0
        public Plot()
        {
            UseDateTimeXAxis();

            yAxes = new AxisCollection(this);
            yAxes.AddLeft("Default");

            series.OnSeriesCollectionChanged     += delegate() { raiseEvent(); };
            yAxes.OnAxisCollectionChanged        += delegate() { raiseEvent(); };
            background.OnBrushDescriptionChanged += delegate() { raiseEvent(); };
            annotations.OnChanged += delegate(object sender, EventArgs args) { raiseEvent(); };
        }
Ejemplo n.º 3
0
        public override void Draw(Graphics g, AxisCollection yAxisCollection, XAxis xAxis, AdvancedRect area)
        {
            if (data.Count == 0)
            {
                return;
            }

            GraphicsState _s = g.Save();

            g.SmoothingMode = SmoothingMode.AntiAlias;

            NumericAxis yAxis = yAxisCollection[YAxisName];

            using (Pen p = line.CreatePen())
                using (Symbol s = (SymbolStyle != SymbolStyle.NoSymbols) ? symbol.CreateSymbol() : null)
                {
                    // find continuous groups of non-null Y points
                    // if our yAxis is LogRate, then we need to find continuous
                    // groups of non-null, >0 Y points.  Yay.
                    int start = 0, end = 0, i = 0;
                    while (i < data.Count)
                    {
                        // chomp all nulls
                        // then draw all non-nulls
                        while (i < data.Count && (data.GetY(i) == null || (yAxis.LogAxis && data.GetY(i) <= 0)))
                        {
                            i++;
                        }
                        // found a non-null at i.
                        start = i;
                        while (i < data.Count && data.GetY(i) != null && (!yAxis.LogAxis || data.GetY(i) > 0))
                        {
                            i++;
                        }
                        // found a null at i;
                        end = i;
                        if (start != end)
                        {
                            drawLines(g, p, s, xAxis, yAxis, area, start, end);
                        }
                    }
                }

            g.Restore(_s);
        }
Ejemplo n.º 4
0
        public override void Draw(Graphics g, AxisCollection yAxisCollection, XAxis xAxis, AdvancedRect area)
        {
            if (data.Count == 0)
            {
                return;
            }

            GraphicsState _s = g.Save();

            g.SmoothingMode = SmoothingMode.AntiAlias;

            NumericAxis yAxis = yAxisCollection[YAxisName];

            double[] baseY = new double[data.Count];
            if (yAxis.LogAxis)
            {
                for (int i = 0; i < data.Count; i++)
                {
                    baseY[i] = yAxis.ScaleMinimum;
                }
            }
            else
            {
                for (int i = 0; i < data.Count; i++)
                {
                    baseY[i] = 0;
                }
            }

            for (int ySet = 0; ySet < data.GetY(0).Length; ySet++)
            {
                PointF[] polygon = new PointF[data.Count * 2];
                PointF[] line    = new PointF[data.Count];
                int      j       = 0;
                for (int i = (data.Count - 1); i >= 0; i--, j++)
                {
                    polygon[j] = new PointF(
                        xAxis.DataToCoordinate(data.GetX(i), area),
                        yAxis.DataToCoordinate(baseY[i], area)
                        );
                }
                for (int i = 0; i < data.Count; i++, j++)
                {
                    double?y = data.GetY(i)[ySet];
                    if (y == null)
                    {
                        y = baseY[i];
                    }
                    else
                    {
                        y = baseY[i] + y.Value;
                    }
                    polygon[j] = new PointF(
                        xAxis.DataToCoordinate(data.GetX(i), area),
                        yAxis.DataToCoordinate(y.Value, area)
                        );
                    line[i]  = polygon[j];
                    baseY[i] = y.Value;
                }

                if (brushes.Count != 0)
                {
                    int idx = ySet % brushes.Count;
                    using (Brush br = brushes[idx].CreateBrush())
                        g.FillPolygon(br, polygon);
                }
                if (pens.Count != 0 && line.Length >= 2)
                {
                    int idx = ySet % pens.Count;
                    using (Pen p = pens[idx].CreatePen())
                        g.DrawLines(p, line);
                }
            }

            g.Restore(_s);
        }
Ejemplo n.º 5
0
 public abstract void Draw(Graphics g, AxisCollection yAxisCollection, XAxis xAxis, AdvancedRect area);