示例#1
0
        /// <summary>
        /// 绘制坐标轴
        /// </summary>
        /// <param name="m">margin</param>
        /// <param name="w">宽度</param>
        /// <param name="h">高度</param>
        private void DrawAxis(double m, double w, double h)
        {
            // 绘制坐标轴和标签
            CanvasDrawing.DrawLine(this.DrawCurveCanvas, m, m, w - m, m);
            CanvasDrawing.DrawLine(this.DrawCurveCanvas, m, h - m, w - m, h - m);
            CanvasDrawing.DrawLine(this.DrawCurveCanvas, m, m, m, h - m);
            CanvasDrawing.DrawLine(this.DrawCurveCanvas, w - m, m, w - m, h - m);

            // 绘制纵坐标和横向网格线
            for (int i = 0; i < 11; i++)
            {
                CanvasDrawing.DrawText(this.DrawCurveCanvas, w - m + 3, (h - 2 * m) / 10 * i, (100 - i * 10).ToString(), 11, Brushes.Black, false, false, false);
                CanvasDrawing.DrawText(this.DrawCurveCanvas, w - m + 3, (h - 2 * m) / 10 * i, (i * 10).ToString());

                CanvasDrawing.DrawLine(this.DrawCurveCanvas, m, m + (h - 2 * m) / 10 * i, w - m, m + (h - 2 * m) / 10 * i);
            }

            // 绘制横坐标和纵向网格线
            double uniteLen = (w - 2 * m) / 5;

            double[] dScale = new double[9] {
                0, 0.05, 0.1, 0.16, 0.22, 0.30, 0.4, 0.52, 0.7
            };
            double[] lenNumber = new double[14] {
                100, 60, 40, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005
            };

            int k = 0;

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    double X = m + uniteLen * dScale[j] + uniteLen * i;

                    if (j != 9 && !(i == 0 && j == 0))
                    {
                        CanvasDrawing.DrawLine(this.DrawCurveCanvas, X, m, X, h - m);
                    }

                    if ((i == 0) && (j == 0 || j == 4 || j == 6 || j == 8))
                    {
                        CanvasDrawing.DrawText(this.DrawCurveCanvas, X - 5, h - m, lenNumber[k].ToString());
                        k++;
                    }
                    else if ((i == 1 || i == 2) && (j == 0 || j == 5 || j == 8))
                    {
                        CanvasDrawing.DrawText(this.DrawCurveCanvas, X - 5, h - m, lenNumber[k].ToString());
                        k++;
                    }
                    else if ((i == 3 || i == 4) && (j == 0 || j == 5))
                    {
                        CanvasDrawing.DrawText(this.DrawCurveCanvas, X - 5, h - m, lenNumber[k].ToString());
                        k++;
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 绘制曲线
        /// </summary>
        /// <param name="m">margin</param>
        /// <param name="w">宽度</param>
        /// <param name="h">高度</param>
        private void DrawCurve(double m, double w, double h)
        {
            if (statisticList.Count == 0)
            {
                return;
            }

            double uniteLen = (w - 2 * m) / 5;

            double[] dScale = new double[9] {
                0, 0.05, 0.1, 0.16, 0.22, 0.30, 0.4, 0.52, 0.7
            };
            double x1 = m;
            double x2 = m + uniteLen * dScale[8] + uniteLen * 0;
            double x3 = m + uniteLen * dScale[8] + uniteLen * 1;
            double x4 = m + uniteLen * dScale[5] + uniteLen * 2;
            double x5 = m + (uniteLen * dScale[7] + uniteLen * dScale[8]) / 2 + uniteLen * 2;
            double x6 = m + (uniteLen * dScale[1] + uniteLen * dScale[2]) / 2 + uniteLen * 3;
            double x7 = w - m;

            double uniteHei = (h - 2 * m) / 100;
            double y1       = m;
            double y2       = m + (100 - statisticList[0].GroupLessThan20) * uniteHei;
            double y3       = m + (100 - statisticList[0].GroupLessThan2) * uniteHei;
            double y4       = m + (100 - statisticList[0].GroupLessThan0_5) * uniteHei;
            double y5       = m + (100 - statisticList[0].GroupLessThan0_25) * uniteHei;
            double y6       = m + (100 - statisticList[0].GroupLessThan0_075) * uniteHei;
            double y7       = h - m;

            double[,] axis = new double[2, 7] {
                { x1, x2, x3, x4, x5, x6, x7 }, { y1, y2, y3, y4, y5, y6, y7 }
            };
            for (int i = 0; i < 7; i++)
            {
                CanvasDrawing.DrawCircle(this.DrawCurveCanvas, axis[0, i], axis[1, i], 2, true, 1, Brushes.DarkRed);
                if (i != 6)
                {
                    CanvasDrawing.DrawLine(this.DrawCurveCanvas, axis[0, i], axis[1, i], axis[0, i + 1], axis[1, i + 1], 1, Brushes.Red);
                }
            }
        }