Пример #1
0
        /// <summary>
        /// Draw text.
        /// </summary>
        /// <param name="highestValue">Highest Y-value possible after drawing the grid.</param>
        /// <param name="widthPerBar">Width of a single bar.</param>
        /// <param name="points">Specified points in the series.</param>
        private void DrawLabels(float highestValue, float widthPerBar, DataPointCollection points)
        {
            float widthOfAllBars = Series.Count(s => s.Type == ChartType.Bar) * widthPerBar;
            float widthIterator  = 2 + PADDING_LEFT;

            for (int i = 0; i < points.Count; i++)
            {
                OnDrawText(this, new DrawEventArgs <TextDrawingData>()
                {
                    Data = new TextDrawingData(points[i].Label, (widthIterator + widthOfAllBars / 2) - (points[i].Label.Length * 4), Height + 25)
                });
                widthIterator += widthPerBar * Series.Count(s => s.Type == ChartType.Bar) + Spacing;
            }
        }
Пример #2
0
        /// <summary>
        /// Draw a pie chart.
        /// </summary>
        /// <param name="points">Specified points in the series.</param>
        private void DrawPieChart(DataPointCollection points, int pieNo)
        {
            double sizeOfCircle = ((WidthRequest > HeightRequest) ? HeightRequest / 2 : WidthRequest / 2);

            double[] values          = points.Select(p => p.Value).ToArray();
            double   degreesPerValue = 360 / values.Sum();

            for (int i = 0; i < values.Length; i++)
            {
                values[i] = values[i] * degreesPerValue;
            }

            OnDrawPie(this, new DrawEventArgs <PieDrawingData> {
                Data = new PieDrawingData(WidthRequest / 2, HeightRequest / 2, pieNo, sizeOfCircle, values)
            });
        }
Пример #3
0
        /// <summary>
        /// Draw a bar.
        /// </summary>
        /// <param name="highestValue">Highest Y-value possible after drawing the grid.</param>
        /// <param name="widthPerBar">Width of a single bar.</param>
        /// <param name="barNo">The number of the series</param>
        /// <param name="points">Specified points in the series.</param>
        private void DrawBarChart(float highestValue, float widthPerBar, int barNo, DataPointCollection points)
        {
            float widthIterator = 2 + (barNo * widthPerBar) + PADDING_LEFT;

            foreach (DataPoint point in points)
            {
                float heightOfBar = ((Height - PADDING_TOP) / highestValue) * point.Value;

                OnDrawBar(this, new DrawEventArgs <DoubleDrawingData>()
                {
                    Data = new DoubleDrawingData(widthIterator + 1, ((Height - PADDING_TOP) - heightOfBar) + PADDING_TOP, (widthIterator + widthPerBar) - 1, Height, barNo)
                });

                widthIterator += widthPerBar * Series.Count(s => s.Type == ChartType.Bar) + Spacing;
            }
        }
Пример #4
0
        /// <summary>
        /// Draw text.
        /// </summary>
        /// <param name="highestValue">Highest Y-value possible after drawing the grid.</param>
        /// <param name="widthPerBar">Width of a single bar.</param>
        /// <param name="points">Specified points in the series.</param>
        private void DrawLabels(double highestValue, double widthPerBar, DataPointCollection points)
        {
            int noOfBarSeries = Series.Count(s => s.Type == ChartType.Bar);

            if (noOfBarSeries == 0)
            {
                noOfBarSeries = 1;
            }
            double widthOfAllBars = noOfBarSeries * widthPerBar;
            double widthIterator  = 2 + PADDING_LEFT;

            for (int i = 0; i < points.Count; i++)
            {
                OnDrawText(this, new DrawEventArgs <TextDrawingData>()
                {
                    Data = new TextDrawingData(points[i].Label, (widthIterator + widthOfAllBars / 2) - (points[i].Label.Length * 4), HeightRequest + 25)
                });
                widthIterator += widthPerBar * noOfBarSeries + Spacing;
            }
        }
Пример #5
0
        /// <summary>
        /// Draw a line.
        /// </summary>
        /// <param name="highestValue">Highest Y-value possible after drawing the grid.</param>
        /// <param name="widthPerBar">Width of a single bar.</param>
        /// <param name="lineNo">The number of the series</param>
        /// <param name="points">Specified points in the series.</param>
        private void DrawLineChart(double highestValue, double widthPerBar, int lineNo, DataPointCollection points)
        {
            int noOfBarSeries = Series.Count(s => s.Type == ChartType.Bar);

            if (noOfBarSeries == 0)
            {
                noOfBarSeries = 1;
            }
            double widthOfAllBars = noOfBarSeries * widthPerBar;
            double widthIterator  = 2 + PADDING_LEFT;

            List <double> pointsList = new List <double>();

            double[] previousPoints = new double[2];
            for (int i = 0; i < points.Count; i++)
            {
                double heightOfLine = ((HeightRequest - PADDING_TOP) / highestValue) * points[i].Value;

                double x = widthIterator + (widthOfAllBars / 2);
                double y = ((HeightRequest - PADDING_TOP) - heightOfLine) + PADDING_TOP;

                if (i != 0)
                {
                    OnDrawLine(this, new DrawEventArgs <DoubleDrawingData>()
                    {
                        Data = new DoubleDrawingData(previousPoints[0], previousPoints[1], x, y, lineNo)
                    });
                }

                previousPoints[0] = x;
                previousPoints[1] = y;

                OnDrawCircle(this, new DrawEventArgs <SingleDrawingData>()
                {
                    Data = new SingleDrawingData(widthIterator + (widthOfAllBars / 2), ((HeightRequest - PADDING_TOP) - heightOfLine) + PADDING_TOP, lineNo)
                });

                widthIterator += widthPerBar * noOfBarSeries + Spacing;
            }
        }
Пример #6
0
 public Series(Color color)
 {
     Points     = new DataPointCollection();
     this.Color = color;
 }
Пример #7
0
 public Series()
 {
     Points = new DataPointCollection();
 }
Пример #8
0
        /// <summary>
        /// Draw a line.
        /// </summary>
        /// <param name="highestValue">Highest Y-value possible after drawing the grid.</param>
        /// <param name="widthPerBar">Width of a single bar.</param>
        /// <param name="lineNo">The number of the series</param>
        /// <param name="points">Specified points in the series.</param>
        private void DrawLineChart(float highestValue, float widthPerBar, int lineNo, DataPointCollection points)
        {
            float widthOfAllBars = Series.Count(s => s.Type == ChartType.Bar) * widthPerBar;
            float widthIterator  = 2 + PADDING_LEFT;

            List <float> pointsList = new List <float>();

            float[] previousPoints = new float[2];
            for (int i = 0; i < points.Count; i++)
            {
                float heightOfLine = ((Height - PADDING_TOP) / highestValue) * points[i].Value;

                float x = widthIterator + (widthOfAllBars / 2);
                float y = ((Height - PADDING_TOP) - heightOfLine) + PADDING_TOP;

                if (i != 0)
                {
                    OnDrawLine(this, new DrawEventArgs <DoubleDrawingData>()
                    {
                        Data = new DoubleDrawingData(previousPoints[0], previousPoints[1], x, y, lineNo)
                    });
                }

                previousPoints[0] = x;
                previousPoints[1] = y;

                OnDrawCircle(this, new DrawEventArgs <SingleDrawingData>()
                {
                    Data = new SingleDrawingData(widthIterator + (widthOfAllBars / 2), ((Height - PADDING_TOP) - heightOfLine) + PADDING_TOP, lineNo)
                });

                widthIterator += widthPerBar * Series.Count(s => s.Type == ChartType.Bar) + Spacing;
            }
        }