Создание базы данных
1612
1613 If Not ((angle > Pi_2) And (angle <= 3 * Pi_2)) Then
1614 Chart. Line (X2, Y2) - (X2 + d1, Y2), LineColor
1615 Chart. CurrentX = X2
1616 Chart. CurrentY = Y2
1617 Chart. Print CStr(str_1)
1618
1619 Chart. CurrentX = X2
1620 Chart. CurrentY = Y2 - Chart. TextHeight(str_2)
1621 Chart. Print CStr(str_2)
1622 Else
1623 Chart. Line (X2, Y2) - (X2 - d1, Y2), LineColor
1624 Chart. CurrentX = X2 - d1
1625 Chart. CurrentY = Y2
1626 Chart. Print CStr(str_1)
1627
1628 Chart. CurrentX = X2 - d1
1629 Chart. CurrentY = Y2 - Chart. TextHeight(str_2)
1630 Chart. Print CStr(str_2)
1631 End If
1632 End If
1633
1634 ' а теперь вывод боковых линий
1635 Chart. DrawStyle = 0
1636
1637 ' начальный угол
1638 If Not ((StAn > 90) And (StAn < 180)) Then
1639 sa# = StAn * Pi_180
1640 x0 = x + Radius * Cos(sa)
1641 y0 = y - Radius * Ellipce * Sin(sa)
1642
1643 If (Mode270Mode <> mode270end) Then
1644 Chart. Line (x0, y0) - (x0, y0 + d3D_ * Screen. TwipsPerPixelY), LineColor
1645 End If
1646 End If
1647
1648 ' конечный угол
1649 If Not ((EnAn > 0) And (EnAn < 90)) Then
1650 x0 = x + Radius * Cos(EnAn * Pi_180)
1651 y0 = y - Radius * Ellipce * Sin(EnAn * Pi_180)
1652
1653 Chart. Line (x0, y0) - (x0, y0 + d3D_ * Screen. TwipsPerPixelY), LineColor
1654 End If
1655
1656 ' центр
1657 If Not ((EnAn >= 270) And (StAn <= 270)) Then
1658 Chart. Line (x, y) - (x, y + d3D_ * Screen. TwipsPerPixelY), LineColor
1659 End If
1660
1661 ' левый край
1662 If ((StAn <= 180) And (EnAn >= 180)) Then
1663 Chart. Line (x - Radius, y) - (x - Radius, y + d3D_ * Screen. TwipsPerPixelY), LineColor
1664 End If
1665
1666 End If
1667
1668 OldGrad = Grad
1669End Sub
1670
1671
1672' рисование круговой диаграммы
1673Sub DrawCircle()
1674 Dim Mode270 As Boolean
1675 Dim Item270%
1676
1677 ItemCount = UBound(DiagData) + 1
1678
1679 With Chart
1680 Max = - 1
1681 Sum = 0
1682 For i% = 1 To ItemCount
1683 If (DiagData(i - 1). Val > Max) Then Max = DiagData(i - 1). Val
1684 Sum = Sum + DiagData(i - 1). Val
1685 Next i
1686
1687 Mode270 = (Max > 3 / 4 * Sum)
1688
1689 OneGradus = 360 / Sum
1690 OldGrad = 0.00001
1691
1692 Xc = Chart. Width 2
1693 Yc = Chart. Height 2
1694
1695 Dim pos90%, pos270% ' индексы ключевых элементов
1696 pos90 = - 1
1697 pos270 = - 1
1698 OldGrad = 0
1699
1700 Dim Angles() As Double
1701 ReDim Angles(ItemCount - 1, 1)
1702
1703 For i% = 1 To ItemCount
1704 If Mode270 Then If (DiagData(i - 1). Val = Max) Then Item270 = i - 1
1705 Grad# = DiagData(i - 1). Val * OneGradus + OldGrad
1706 If (OldGrad <= 90) And (Grad >= 90) Then pos90 = i - 1
1707 If (OldGrad <= 270) And (Grad >= 270) Then pos270 = i - 1
1708 Angles(i - 1, 0) = OldGrad
1709 Angles(i - 1, 1) = Grad
1710 OldGrad = Grad
1711 Next i
1712
1713 Chart. DrawStyle = 0
1714
1715 If Not Mode270 Then
1716
1717 For i% = pos90 To 0 Step - 1
1718 Call OutOneElem(i, Angles(i, 0), Angles(i, 1))
1719 Next i
1720
1721 For i% = pos90 + 1 To pos270 - 1
1722 Call OutOneElem(i, Angles(i, 0), Angles(i, 1))
1723 Next i
1724
1725 For i% = ItemCount - 1 To pos270 Step - 1
1726 Call OutOneElem(i, Angles(i, 0), Angles(i, 1))
1727 Next i
1728 Else
1729
1730 i% = pos90 - 1
1731 If (i < 0) Then i = ItemCount - 1
1732
1733 Call OutOneElem(Item270, Angles(Item270, 0), Angles(Item270, 1), mode270begin)
1734
1735 Do While (i <> Item270)
1736 Call OutOneElem(i, Angles(i, 0), Angles(i, 1))
1737
1738 i = i - 1
1739 If (i < 0) Then i = ItemCount - 1
1740 Loop
1741
1742 Call OutOneElem(Item270, Angles(Item270, 0), Angles(Item270, 1), mode270end)
1743
1744 End If
1745 End With
1746End Sub
1747
1748' рисование линейной, точечной и столбчатой диаграмм
1749Sub DrawPoint()
1750 Dim d3DX%
1751 Dim d3DY%
1752 Dim OldX%, OldY% ' координаты предыдущей точки
1753
1754 ItemCount = UBound(DiagData) + 1
1755 ChartHeight = Chart. Height * 0.8
1756 ChartTop = Chart. Height * 0.1
1757 ChartDown = Chart. Height * 0.9
1758
1759 With Chart
1760 dWidth = Chart. Width / (2 * ItemCount + 1)
1761
1762 Max = - 1
1763 Sum = 0
1764 For i% = 1 To ItemCount
1765 If (DiagData(i - 1). Val > Max) Then Max = DiagData(i - 1). Val
1766 Sum = Sum + DiagData(i - 1). Val
1767 Next i
1768
1769 dHeight = ChartHeight / Max
1770
1771 d3DX = Screen. TwipsPerPixelX
1772 d3DY = Screen. TwipsPerPixelY
1773
1774 With Chart
1775. DrawWidth = 1
1776. DrawStyle = 3
1777 Chart. Line (dWidth * 0.9, ChartTop 2) - (dWidth * 0.9, ChartDown), LineColor
1778 Chart. Line (dWidth * 0.9, ChartDown) - ((2 * ItemCount + 0.5) * dWidth, ChartDown), LineColor
1779. DrawStyle = 0
1780
1781. FontSize =. FontSize + 3
1782. FontUnderline = True
1783
1784. CurrentX = 2 * d3DX
1785. CurrentY = 2 * d3DY
1786 Chart. Print "Значения"
1787
1788 str_$ = "Подписи"
1789. CurrentX =. Width - . TextWidth(str_) - 10 * d3DX
1790. CurrentY = ChartDown +. TextHeight(str_)
1791 Chart. Print str_
1792
1793. FontSize =. FontSize - 3
1794. FontUnderline = False
1795 End With
1796
1797
1798 For i% = 1 To ItemCount
1799 j% = 2 * i - 1
1800 Dim y#, x#
1801 y = ChartTop + dHeight * (Max - DiagData(i - 1). Val)
1802
1803 Select Case DrawingMode
1804 Case 0 ' // // // // // // // // // // // // // // // // / ЛИНИИ // // // // // // // // // // // // // // // // // // // // /
1805 x# = (j + 0.5) * dWidth
1806
1807 If (i > 1) Then
1808 Chart. DrawWidth = LineWidth
1809 Chart. Line (OldX, OldY) - (x, y), DiagData(i - 1). Color
1810 Chart. DrawWidth = 1
1811 End If
1812 Chart. DrawStyle = 1
1813 Chart. Line (x, y) - (x, ChartDown), DiagData(i - 1). Color
1814 Chart. DrawStyle = 0
1815 OldX = x
1816 OldY = y
1817
1818 str_$ = CStr(DiagData(i - 1). Text)
1819 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) 2
1820 Chart. CurrentY = ChartDown + Chart. TextHeight(str_) 10
1821 Chart. Print str_
1822
1823 str_ = CStr(Round(DiagData(i - 1). Val / Sum * 100)) + "%"
1824 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) 2
1825 Chart. CurrentY = y - Chart. TextHeight(str_) * 1.2
1826 Chart. Print str_
1827
1828 ' значение слева с засечкой и линией
1829 str_ = CStr(DiagData(i - 1). Val)
1830 If UseLineLeftValues Then
1831 Chart. CurrentX = dWidth * 0.8 - Chart. TextWidth(str_)
1832 Chart. DrawStyle = 2
1833 Chart. Line (dWidth * 0.9, y) - (x, y), LineColor
1834 Chart. DrawStyle = 0
1835 End If
1836
1837 Chart. DrawWidth = 2
1838 Chart. Line (dWidth * 0.85, y) - (dWidth * 0.95, y), LineColor
1839 Chart. DrawWidth = 1
1840 x# = dWidth * 0.8 - Chart. TextWidth(str_)
1841 Chart. CurrentX = x
1842 Chart. CurrentY = y - Chart. TextHeight(str_) 2
1843 Chart. Print str_
1844
1845 Case 1 ' // // // // // // // // // // // // // // // // / КОЛОНКИ // // // // // // // // // // // // // // // // // // // /
1846 If (Not Use3D) Then
1847 Chart. Line (j * dWidth, y) - ((j + 1) * dWidth, ChartDown), DiagData(i - 1). Color, BF
1848 Chart. Line (j * dWidth, y) - ((j + 1) * dWidth, ChartDown), LineColor, B
1849
1850 str_ = CStr(DiagData(i - 1). Text)
1851 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) 2
1852 Chart. CurrentY = ChartDown + Chart. TextHeight(str_) 10
1853 Chart. Print str_
1854
1855 str_ = CStr(Round(DiagData(i - 1). Val / Sum * 100)) + "%"
1856 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) 2
1857 Chart. CurrentY = y - Chart. TextHeight(str_) * 1.2
1858 Chart. Print str_
1859
1860 ' значение слева с засечкой и линией
1861 str_ = CStr(DiagData(i - 1). Val)
1862 If UseLineLeftValues Then
1863 Chart. CurrentX = dWidth * 0.8 - Chart. TextWidth(str_)
1864 Chart. DrawStyle = 2
1865 Chart. Line (dWidth * 0.9, y) - (j * dWidth, y), LineColor
1866 Chart. DrawStyle = 0
1867 End If
1868
1869 x# = dWidth * 0.8 - Chart. TextWidth(str_)
1870 Chart. CurrentX = x
1871 Chart. CurrentY = y - Chart. TextHeight(str_) 2
1872 Chart. Print str_
1873 Chart. CurrentX = x
1874 Chart. CurrentY = y
1875 Chart. DrawWidth = 2
1876 Chart. Line (dWidth * 0.85, y) - (dWidth * 0.95, y), LineColor
1877 Chart. DrawWidth = 1
1878 Else
1879 For k% = 0 To d3D - 1
1880 Chart. Line (j * dWidth + k * d3DX, y - k * d3DY) - ((j + 1) * dWidth + k * d3DX, ChartDown - k * d3DY), DiagData(i - 1). Color, B
1881 Next k
1882 Chart. Line (j * dWidth, y) - ((j + 1) * dWidth, ChartDown), DiagData(i - 1). Color, BF
1883 ' верхняя левая в глубине
1884 ltdx% = j * dWidth + (d3D - 1) * d3DX
1885 ltdy% = y - (d3D - 1) * d3DY
1886 ' верхняя правая в глубине
1887 rtdx% = (j + 1) * dWidth + (d3D - 1) * d3DX
1888 rtdy% = y - (d3D - 1) * d3DY
1889 ' нижняя правая в глубине
1890 rddx% = (j + 1) * dWidth + (d3D - 1) * d3DX
1891 rddy% = ChartDown - (d3D - 1) * d3DY
1892 ' верхняя в глубине
1893 Chart. Line (rtdx, rtdy) - (rddx, rddy), LineColor
1894 ' правая в глубине
1895 Chart. Line (ltdx, ltdy) - (rtdx, rtdy), LineColor
1896
1897 ' левая переходная
1898 Chart. Line (ltdx, ltdy) - (ltdx - d3D * d3DX, ltdy + d3D * d3DY), LineColor
1899 ' правая верхняя переходная
1900 Chart. Line (rtdx, rtdy) - (rtdx - d3D * d3DX, rtdy + d3D * d3DY), LineColor
1901 ' правая нижняя переходная
1902 Chart. Line (rddx, rddy) - (rddx - d3D * d3DX, rddy + d3D * d3DY), LineColor
1903 Chart. Line (j * dWidth, y) - ((j + 1) * dWidth, ChartDown), LineColor, B
1904
1905 ' надпись внизу
1906 str_ = CStr(DiagData(i - 1). Text)
1907 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) 2
1908 Chart. CurrentY = ChartDown + Chart. TextHeight(str_) 10
1909 Chart. Print str_
1910 ' процент вверху
1911 str_ = CStr(Round(DiagData(i - 1). Val / Sum * 100)) + "%"
1912 Chart. CurrentX = d3D * d3DX + j * dWidth + (dWidth - Chart. TextWidth(str_)) 2
1913 Chart. CurrentY = y - d3D * d3DY - Chart. TextHeight(str_) * 1.2
1914 Chart. Print str_
1915 ' значение слева с засечкой и линией
1916 str_ = CStr(DiagData(i - 1). Val)
1917 If UseLineLeftValues Then
1918 Chart. CurrentX = dWidth * 0.8 - Chart. TextWidth(str_)
1919 Chart. DrawStyle = 2
1920 Chart. Line (dWidth * 0.9, y) - (j * dWidth, y), LineColor
1921 Chart. DrawStyle = 0
1922 End If
1923
1924 x# = dWidth * 0.8 - Chart. TextWidth(str_)
1925 Chart. CurrentX = x
1926 Chart. CurrentY = y - Chart. TextHeight(str_) 2
1927 Chart. Print str_
1928 Chart. CurrentX = x
1929 Chart. CurrentY = y
1930 Chart. DrawWidth = 2
1931 Chart. Line (dWidth * 0.85, y) - (dWidth * 0.95, y), LineColor
1932 Chart. DrawWidth = 1
1933 End If
1934
1935 Case 2 ' // // // // // // // // // // // // // // // // / ТОЧКИ // // // // // // // // // // // // // // // // // // // // /
1936 Chart. FillStyle = 0
1937 Chart. FillColor = DiagData(i - 1). Color
1938 x# = (j + 0.5) * dWidth
1939 Chart. Circle (x, y), PointRadius * d3DX, LineColor
1940 Chart. FillStyle = 1
1941 Chart. DrawStyle = 1
1942 Chart. Line (x, y) - (x, ChartDown), DiagData(i - 1). Color
1943 Chart. DrawStyle = 0
1944
1945 str_ = CStr(DiagData(i - 1). Text)
1946 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) 2
1947 Chart. CurrentY = ChartDown + Chart. TextHeight(str_) 10
1948 Chart. Print str_
1949
1950 str_ = CStr(Round(DiagData(i - 1). Val / Sum * 100)) + "%"
1951 Chart. CurrentX = j * dWidth + (dWidth - Chart. TextWidth(str_)) 2
1952 Chart. CurrentY = y - PointRadius * d3D - Chart. TextHeight(str_) * 1.2
1953 Chart. Print str_
1954
1955 ' значение слева с засечкой и линией
1956 str_ = CStr(DiagData(i - 1). Val)
1957 Chart. CurrentX = dWidth * 0.8 - Chart. TextWidth(str_)
1958 Chart. DrawStyle = 2
1959 Chart. Line (dWidth * 0.9, y) - (x, y), LineColor
1960 Chart. DrawStyle = 0
1961
1962 Chart. DrawWidth = 2
1963 Chart. Line (dWidth * 0.85, y) - (dWidth * 0.95, y), LineColor
1964 Chart. DrawWidth = 1
1965 x# = dWidth * 0.8 - Chart. TextWidth(str_)
1966 Chart. CurrentX = x
1967 Chart. CurrentY = y - Chart. TextHeight(str_) 2
1968 Chart. Print str_
1969 End Select
1970 Next i
1971
1972 End With
1973End Sub
1974
1975Sub DrawDiagram()
1976 If (Chart. Height > Screen. TwipsPerPixelX * 5) And (UseColorFill) Then
1977 Call ColorFill(Chart, StartFillColor, EndFillColor)
1978 Else
1979 Chart. Line (0, 0) - (Chart. Width, Chart. Height), StartFillColor, BF
1980 End If
1981
1982 Select Case DrawingMode
1983 Case 3: Call DrawCircle
1984 Case Else: Call DrawPoint
1985 End Select
1986End Sub
1987
1988Private Sub Chart_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
1989 If (DrawingMode <> 3) Then
1990 y = Round((ChartDown - y) * Max / (ChartDown - ChartTop))
1991 Label3. Caption = CStr(y)
1992 End If
1993End Sub
1994
1995Private Sub Form_KeyDown(KeyCode