Ejemplo n.º 1
0
        private void DrawLineData(List <ItemModel> data, AxisProp axis)
        {
            Axis   Yaxis = axis.Y_Axis;
            Axis   Xaxis = axis.X_Axis;
            PointF prev  = PointF.Empty;

            SetPen(Color.Black, 2);
            Color lineColor = Color.Black;
            int   dotSize   = 5;
            int   counter   = 0;

            foreach (ItemModel item in data)
            {
                PointF itemPoint = new PointF(Yaxis.Base + (Xaxis.Length / Xaxis.IncrementCount) * (float)(counter + .5), (float)(Xaxis.Base - (Yaxis.Length / (Yaxis.Scale * Yaxis.IncrementCount) * item.Data)));

                //DrawDot
                RectangleF border = new RectangleF(new PointF(itemPoint.X - (dotSize / 2), itemPoint.Y - (dotSize / 2)), new Size(dotSize, dotSize));
                canvas.FillPie(new SolidBrush(lineColor), border.X, border.Y, border.Size.Width, border.Size.Height, 0, 360); //Broke "border" into different variables since the overload that takes a Rectangle object doesn't take Rectangle F

                //DrawLine
                if (prev != Point.Empty)
                {
                    canvas.DrawLine(pen, prev, itemPoint);
                }

                prev = itemPoint;
                counter++;
            }
        }
Ejemplo n.º 2
0
        private void DrawBarData(List <ItemModel> data, AxisProp axis)
        {
            Axis Yaxis            = axis.Y_Axis;
            Axis Xaxis            = axis.X_Axis;
            int  counter          = 0;
            int  spacing          = 30;
            int  itemAllotedSpace = Xaxis.Length / Xaxis.IncrementCount;

            SetPen(Color.Black, 1);

            foreach (ItemModel item in data)
            {
                RectangleF rect = new RectangleF(
                    Yaxis.Base + itemAllotedSpace * counter + spacing / 2,
                    Xaxis.Base - (Yaxis.Length / (Yaxis.Scale * Yaxis.IncrementCount) * (float)item.Data),
                    itemAllotedSpace - spacing / 2,
                    Yaxis.Length / (Yaxis.Scale * Yaxis.IncrementCount) * (float)item.Data
                    );
                canvas.FillRectangle(new SolidBrush(item.Color), rect);
                canvas.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);

                counter++;
            }
        }
Ejemplo n.º 3
0
        private void DrawLineGraph(List <ItemModel> data)
        {
            AxisProp barGraph = DrawAxis(data);

            DrawLineData(data, barGraph);
        }