home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Demo / conceptdraw / data1.cab / Samples__Basic / Solutions / Diagraming / BarGraph / BarChart.cdb next >
Text File  |  2004-02-13  |  26KB  |  544 lines

  1. '╨í╨╕╨╝╨▓╨╛╨╗, ╤ü╨╗╤â╨╢╨░╤ë╨╕╨╣ ╤Ç╨░╨╖╨┤╨╡╨╗╨╕╤é╨╡╨╗╨╡╨╝ ╨╝╨╡╨╢╨┤╤â ╨┐╨╛╨╗╤Å╨╝╨╕
  2. Const constrCharSeparator As String = ";"
  3.  
  4. '╨£╨░╤ü╤ü╨╕╨▓, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨╕╨╣ ╨╜╨╛╨╝╨╡╤Ç╨░ ╤ü╤é╨╛╨╗╨▒╤å╨╛╨▓, ╨▓ ╨║╨╛╤é╨╛╤Ç╤ï╤à ╨╖╨░╨┐╨╕╤ü╨░╨╜╨╛ ╨╕╨╝╤Å ╤ä╨╕╨╗╨╕╨░╨╗╨░, ╨▓ ╤ä╨░╨╣╨╗╨╡ ╨┤╨░╨╜╨╜╤ï╤à ╨║╨░╨╢╨┤╨╛╨│╨╛ ╨╕╨╖ ╤é╨╕╨┐╨╛╨▓. 
  5. Dim aiNameFieldPos(3) As Integer
  6. '╨£╨░╤ü╤ü╨╕╨▓, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨╕╨╣ ╨╜╨╛╨╝╨╡╤Ç╨░ ╤ü╤é╨╛╨╗╨▒╤å╨╛╨▓, ╨▓ ╨║╨╛╤é╨╛╤Ç╤ï╤à ╨╖╨░╨┐╨╕╤ü╨░╨╜╨░ ╨┐╤Ç╨╕╨▒╤ï╨╗╤î ╤ä╨╕╨╗╨╕╨░╨╗╨░ ╨╖╨░ ╨╕╨╜╤é╨╡╤Ç╨╡╤ü╤â╤Ä╤ë╨╕╨╣ ╨┐╨╡╤Ç╨╕╨╛╨┤, ╨▓ ╤ä╨░╨╣╨╗╨╡ ╨┤╨░╨╜╨╜╤ï╤à ╨╛╨┤╨╜╨╛╨│╨╛ ╨╕╨╖ ╤é╨╕╨┐╨╛╨▓. 
  7. Dim aiValueFieldPos(3) As Integer
  8. '╨ÿ╨╜╨╕╤å╨╕╨░╨╗╨╕╨╖╨░╤å╨╕╤Å ╤ì╤é╨╕╤à ╨╝╨░╤ü╤ü╨╕╨▓╨╛╨▓.
  9. aiNameFieldPos(0)=1
  10. aiValueFieldPos(0)=9
  11. aiNameFieldPos(1)=1
  12. aiValueFieldPos(1)=9
  13. aiNameFieldPos(2)=2
  14. aiValueFieldPos(2)=3
  15. aiNameFieldPos(3)=2
  16. aiValueFieldPos(3)=3
  17.  
  18. '╨£╨░╨║╤ü╨╕╨╝╨░╨╗╤î╨╜╨╛╨╡ ╨║╨╛╨╗╨╕╤ç╨╡╤ü╤é╨▓╨╛ ╤ü╤é╤Ç╨╛╨║ ╨▓ ╤ä╨░╨╣╨╗╨╡ ╨┤╨░╨╜╨╜╤ï╤à, ╨║╨╛╤é╨╛╤Ç╨╛╨╡ ╨▒╤â╨┤╨╡╤é ╨╛╨▒╤Ç╨░╨▒╨░╤é╤ï╨▓╨░╤é╤î ╤ü╨║╤Ç╨╕╨┐╤é.
  19. Const conintMaxProcessingStrings As Integer = 10
  20.  
  21. '╨ÿ╨╜╨┤╨╡╨║╤ü ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï, ╨║╨╛╤é╨╛╤Ç╨░╤Å ╨▒╤â╨┤╨╡╤é ╤ü╨╛╨╖╨┤╨░╨╜╨░ ╨┐╤Ç╨╕ ╨┤╨░╨╜╨╜╨╛╨╝ ╨▓╤ï╨╖╨╛╨▓╨╡ ╤ä╤â╨╜╨║╤å╨╕╨╕ ╨┐╨╛╤ü╤é╤Ç╨╛╨╡╨╜╨╕╤Å.
  22. Dim intDiagramIndex As Integer
  23.  
  24. '╨£╨░╤ü╤ü╨╕╨▓╤ï, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨╕╨╡ ╨┤╨░╨╜╨╜╤ï╨╡ ╨╛ ╤Ç╨░╨▒╨╛╤é╨╡ ╤ä╨╕╨╗╨╕╨░╨╗╨╛╨▓.
  25. '╨ÿ╨╝╨╡╨╜╨░ ╤ä╨╕╨╗╨╕╨░╨╗╨╛╨▓.
  26. Dim asNames() As String
  27. '╨ƒ╤Ç╨╕╨▒╤ï╨╗╤î ╤ä╨╕╨╗╨╕╨░╨╗╨╛╨▓.
  28. Dim adValues() As Double
  29. '╨¥╨╛╨╝╨╡╤Ç ╨┐╨╛╤ü╨╗╨╡╨┤╨╜╨╡╨│╨╛ ╨╕╨╜╨┤╨╡╨║╤ü╨░, ╤Ç╨╡╨░╨╗╤î╨╜╨╛ ╨╕╤ü╨┐╨╛╨╗╤î╨╖╨╛╨▓╨░╨▓╤ê╨╡╨│╨╛╤ü╤Å ╨▓╨╛ ╨▓╤Ç╨╡╨╝╤Å ╨╖╨░╤ç╨╕╤é╤ï╨▓╨░╨╜╨╕╤Å ╨┤╨░╨╜╨╜╤ï╤à.
  30. Dim iMaxUsedIndex As Integer
  31.  
  32. Declare Sub SelectFileAndRefreshDiagram(ByVal strDiagramIndex As String)
  33. Declare Sub AutoRefresh()
  34. Declare Function RefreshDiagram(ByVal intDiagramIndex As Integer, ByVal strTextFileName As String) As Boolean
  35. Declare Function LoadData(ByVal strFileName As String) As Boolean
  36. Declare Function DrawDiagram(ByVal intDiagramIndex As Integer, ByVal strTextFileName As String) As Boolean
  37. Declare Function CalcScaleStep(ByRef dblMaxProd As Double) As Double
  38. 'Declare Sub RefreshSelected()
  39.  
  40.  
  41.  
  42. '========================================================================================================================
  43. '========================================================================================================================
  44.  
  45. '╨í╨╛╨╖╨┤╨░╨╜╨╕╨╡ ╨┐╨╛╨╗╤î╨╖╨╛╨▓╨░╤é╨╡╨╗╤î╤ü╨║╨╛╨│╨╛ ╨╝╨╡╨╜╤Ä. ╨É╨▓╤é╨╛╨╝╨░╤é╨╕╤ç╨╡╤ü╨║╨╕ ╨▓╤ï╨╖╤ï╨▓╨░╨╡╤é╤ü╤Å ╨┐╤Ç╨╕ ╨╛╤é╨║╤Ç╤ï╤é╨╕╨╕ ╨┤╨╛╨║╤â╨╝╨╡╨╜╤é╨░ ╨╕╨╖
  46. '╨╝╨░╨║╤Ç╨╛╤ü╨░ ╤â╤Ç╨╛╨▓╨╜╤Å ╨┤╨╛╨║╤â╨╝╨╡╨╜╤é╨░.
  47. Sub CreateUserMenu()
  48.     Dim custMenu As Menu
  49.     Dim newMenuItem As MenuItem
  50.     
  51.     Set custMenu = thisDoc.CustomMenu
  52.     custMenu.Caption = "Fill Di&agrams"
  53.     custMenu.RemoveAll()
  54.  
  55.     Set newMenuItem = custMenu.AddMenuItem(0)
  56.     newMenuItem.Caption = "Fill 2D Diagram 1 Tipa"
  57.     newMenuItem.OnCmdArgs = "1"
  58.     newMenuItem.SetCmdProcessing("SelectFileAndRefreshDiagram")
  59.  
  60.     Set newMenuItem = custMenu.AddMenuItem(0)
  61.     newMenuItem.Caption = "Fill 3D Diagram 1 Tipa"
  62.     newMenuItem.OnCmdArgs = "2"
  63.     newMenuItem.SetCmdProcessing("SelectFileAndRefreshDiagram")
  64.  
  65.     Set newMenuItem = custMenu.AddMenuItem(0)
  66.     newMenuItem.Caption = "Fill 2D Diagram 2 Tipa"
  67.     newMenuItem.OnCmdArgs = "3"
  68.     newMenuItem.SetCmdProcessing("SelectFileAndRefreshDiagram")
  69.  
  70.     Set newMenuItem = custMenu.AddMenuItem(0)
  71.     newMenuItem.Caption = "Fill 3D Diagram 2 Tipa"
  72.     newMenuItem.OnCmdArgs = "4"
  73.     newMenuItem.SetCmdProcessing("SelectFileAndRefreshDiagram")
  74.  
  75.     Set newMenuItem = custMenu.AddMenuItem(0)
  76.     newMenuItem.Caption = "&Refresh All Diagrams"
  77.     newMenuItem.SetCmdProcessing("AutoRefresh")
  78. End Sub
  79.  
  80. '========================================================================================================================
  81. '========================================================================================================================
  82.  
  83. '╨É╨▓╤é╨╛╨╝╨░╤é╨╕╤ç╨╡╤ü╨║╨╛╨╡ ╨┐╨╛╤ü╤é╤Ç╨╛╨╡╨╜╨╕╨╡ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï ╨┐╨╛ ╨╛╨▒╨╜╨╛╨▓╨╗╨╡╨╜╨╜╤ï╨╝ ╨┤╨░╨╜╨╜╤ï╨╝ ╨▓ ╤é╨╡╨║╤ü╤é╨╛╨▓╨╛╨╝ ╤ä╨░╨╣╨╗╨╡.
  84. '╨ò╤ü╨╗╨╕ ╨╕╨╝╤Å ╤ä╨░╨╣╨╗╨░ ╤ü╨╛╤à╤Ç╨░╨╜╨╡╨╜╨╛ ╨▓ Property ╨╛╨▒╤è╨╡╨║╤é╨░ ╨╕ ╤é╨░╨║╨╛╨╣ ╤ä╨░╨╣╨╗ ╤ü╤â╤ë╨╡╤ü╤é╨▓╤â╨╡╤é, ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╨░ ╨▒╤â╨┤╨╡╤é ╨┐╨╡╤Ç╨╡╤ü╤ç╨╕╤é╨░╨╜╨░ ╨▒╨╡╨╖
  85. '╨╖╨░╨┐╤Ç╨╛╤ü╨░ ╤â ╨┐╨╛╨╗╤î╨╖╨╛╨▓╨░╤é╨╡╨╗╤Å ╨╜╨╛╨▓╨╛╨│╨╛ ╨╕╨╝╨╡╨╜╨╕ ╤ä╨░╨╣╨╗╨░ ╨┤╨░╨╜╨╜╤ï╤à.
  86. Sub AutoRefresh()
  87. On Error GoTo ErrHandler
  88.     '╨ÿ╨╝╤Å ╤ä╨░╨╣╨╗╨░ ╨┤╨░╨╜╨╜╤ï╤à
  89.     Dim strTextFileName As String
  90.     '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ Custom Property ╨╛╨▒╤è╨╡╨║╤é╨░ (╨▓ ╨╛╨┤╨╜╨╛╨╝ ╨╕╨╖ ╨╜╨╕╤à ╨╝╨╛╨╢╨╡╤é ╤à╤Ç╨░╨╜╨╕╤é╤î╤ü╤Å ╨┐╨╛╨╗╨╜╨╛╨╡ ╨╕╨╝╤Å ╤ä╨░╨╣╨╗╨░ ╨┤╨░╨╜╨╜╤ï╤à). 
  91.     Dim FileNameProp As CustomProp
  92.     Dim NextShape As Shape
  93.     Dim ActivePage As Page
  94.     Dim i As Integer
  95.     Dim j As Integer
  96.     
  97.     Set ActivePage = thisDoc.ActivePage()
  98.     
  99.     '╨ƒ╤Ç╨╛╨▓╨╡╤Ç╤Å╨╡╨╝ ╨▓╤ü╨╡ ╤ê╤ì╨╣╨┐╤ï ╨▓ ╨┤╨╛╨║╤â╨╝╨╡╨╜╤é╨╡. ╨¿╤ì╨╣╨┐, ╨▓╨╜╤â╤é╤Ç╨╕ ╨║╨╛╤é╨╛╤Ç╨╛╨│╨╛ ╨╛╨▒╨╜╨╛╨▓╨╗╤Å╨╡╤é╤ü╤Å ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╨░, 
  100.     '╤â╨╖╨╜╨░╨╡╤é╤ü╤Å ╨┐╨╛ Name.
  101.     For j=1 To ActivePage.ShapesNum()
  102.         Set NextShape = ActivePage.Shape(j)
  103.         Select Case NextShape.Name
  104.         Case "Diagram1"
  105.             intDiagramIndex = 1
  106.         Case "Diagram2"
  107.             intDiagramIndex = 2
  108.         Case "Diagram3"
  109.             intDiagramIndex = 3
  110.         Case "Diagram4"
  111.             intDiagramIndex = 4
  112.         Case Else
  113.             intDiagramIndex = 0
  114.         End Select
  115.         '╨ò╤ü╨╗╨╕ ╨╜╨░╨╣╨┤╨╡╨╜ ╤ê╤ì╨╣╨┐ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï, ╨┐╤Ç╨╛╨▓╨╡╤Ç╤Å╨╡╨╝, ╤ü╨╛╤à╤Ç╨░╨╜╨╡╨╜╨╛ ╨╗╨╕ ╨▓ ╨╜╨╡╨╝ Property ╤ü ╨╕╨╝╨╡╨╜╨╡╨╝ ╤ä╨░╨╣╨╗╨░-╨╕╤ü╤é╨╛╤ç╨╜╨╕╨║╨░ ╨┤╨░╨╜╨╜╤ï╤à.
  116.         If intDiagramIndex <> 0 Then
  117.             i=1
  118.             Set FileNameProp = Nothing
  119.             Do While i<=NextShape.CustomPropsNum() And FileNameProp = Nothing
  120.                 If NextShape.CustomProp(i).Label = "LastSourceFileName" Then
  121.                     Set FileNameProp = NextShape.CustomProp(i) 
  122.                     strTextFileName = FileNameProp.Value
  123.                     '╨ò╤ü╨╗╨╕ Property ╤ü╤â╤ë╨╡╤ü╤é╨▓╤â╨╡╤é, ╨╕ ╤ü╤â╤ë╨╡╤ü╤é╨▓╤â╨╡╤é ╤ä╨░╨╣╨╗, ╤â╨║╨░╨╖╨░╨╜╨╜╤ï╨╣ ╨▓ ╨╜╨╡╨╝ ╨║╨░╨║ ╨╕╤ü╤é╨╛╤ç╨╜╨╕╨║ ╨┤╨░╨╜╨╜╤ï╤à,
  124.                     '╨░╨▓╤é╨╛╨╝╨░╤é╨╕╤ç╨╡╤ü╨║╨╕ ╨╛╨▒╨╜╨╛╨▓╨╗╤Å╨╡╨╝ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤â.
  125.                     If Dir(strTextFileName) <> "" Then
  126.                          RefreshDiagram(intDiagramIndex, strTextFileName)
  127.                     End If
  128.                 End If
  129.                 i = i + 1
  130.             Loop 
  131.         End If
  132.     Next
  133.     
  134.     Exit Sub
  135. ErrHandler:
  136.     MsgBox("In performing the macros, an error has occured.", cdbExclamation)
  137. End Sub
  138.  
  139. '========================================================================================================================
  140. '========================================================================================================================
  141.  
  142. '╨ö╨╗╤Å ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï ╤â╨║╨░╨╖╨░╨╜╨╜╨╛╨│╨╛ ╨▓ ╨┐╨░╤Ç╨░╨╝╨╡╤é╤Ç╨╡ ╤é╨╕╨┐╨░ ╨╖╨░╨┐╤Ç╨░╤ê╨╕╨▓╨░╨╡╨╝ ╨╕╨╝╤Å ╤ä╨░╨╣╨╗╨░-╨╕╤ü╤é╨╛╤ç╨╜╨╕╨║╨░ ╨┤╨░╨╜╨╜╤ï╤à ╨╕ 
  143. '╤ü╤é╤Ç╨╛╨╕╨╝ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤â ╨╜╨░ ╨╛╤ü╨╜╨╛╨▓╨░╨╜╨╕╨╕ ╤ì╤é╨╕╤à ╨┤╨░╨╜╨╜╤ï╤à.
  144. Sub SelectFileAndRefreshDiagram(ByVal strDiagramIndex As String)
  145. On Error GoTo ErrHandler
  146.     Dim strTextFileName As String
  147.     
  148.     Select Case strDiagramIndex 
  149.     Case "1"
  150.         intDiagramIndex = 1
  151.     Case "2"
  152.         intDiagramIndex = 2
  153.     Case "3"
  154.         intDiagramIndex = 3
  155.     Case "4"
  156.         intDiagramIndex = 4
  157.     Case Else
  158.         intDiagramIndex = 0
  159.     End Select    
  160.     
  161.     '╨ƒ╤Ç╨╡╨┤╨╗╨░╨│╨░╨╡╨╝ ╨┐╨╛╨╗╤î╨╖╨╛╨▓╨░╤é╨╡╨╗╤Ä ╨▓╤ï╨▒╤Ç╨░╤é╤î ╨╕╨╝╤Å ╤ä╨░╨╣╨╗╨░ ╨┤╨░╨╜╨╜╤ï╤à
  162.     strTextFileName = GetOpenFileName("txt","Text Files")
  163.     '╨ò╤ü╨╗╨╕ ╤ä╨░╨╗ ╨▓╤ï╨▒╤Ç╨░╨╜, ╤ü╤é╤Ç╨╛╨╕╨╝ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤â.
  164.     If strTextFileName <> "" Then
  165.          RefreshDiagram(intDiagramIndex, strTextFileName)
  166.     End If
  167.     Exit Sub
  168. ErrHandler:
  169.     MsgBox("In performing the macros, an error has occured.", cdbExclamation)
  170. End Sub
  171.  
  172. '========================================================================================================================
  173. '========================================================================================================================
  174.  
  175. '╨₧╨▒╨╜╨╛╨▓╨╗╤Å╨╡╨╝ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤â ╤é╨╕╨┐╨░ intDiagramIndex ╨╜╨░ ╨╛╤ü╨╜╨╛╨▓╨░╨╜╨╕╨╕ ╨┤╨░╨╜╨╜╤ï╤à ╨▓ ╤ä╨░╨╣╨╗╨╡ strTextFileName 
  176. Function RefreshDiagram(ByVal intDiagramIndex As Integer, ByVal strTextFileName As String) As Boolean
  177. On Error GoTo ErrHandler
  178.     RefreshDiagram = False
  179.  
  180.     Dim i As Integer
  181.     
  182.     i = conintMaxProcessingStrings - 1
  183.     ReDim asNames(i) As String
  184.     ReDim adValues(i) As Double
  185.  
  186.     '╨ù╨░╤ç╨╕╤é╤ï╨▓╨░╨╡╨╝ ╨┤╨░╨╜╨╜╤ï╨╡ ╨╕╨╖ ╤é╨╡╨║╤ü╤é╨╛╨▓╨╛╨│╨╛ ╤ä╨░╨╣╨╗╨░ ╨╕ ╨┐╨╛╨╝╨╡╤ë╨░╨╡╨╝ ╨╕╤à ╨▓ ╨╝╨░╤ü╤ü╨╕╨▓╤ï. ╨ò╤ü╨╗╨╕ ╨▓╨╛ ╨▓╤Ç╨╡╨╝╤Å 
  187.     '╨▓╤ï╨┐╨╛╨╗╨╜╨╡╨╜╨╕╤Å ╤ä╤â╨╜╨║╤å╨╕╨╕ LoadData ╨╜╨╡ ╨┐╤Ç╨╛╨╕╨╖╨╛╤ê╨╗╨╛ ╨╛╤ê╨╕╨▒╨╛╨║...
  188.     If intDiagramIndex <> 0 And LoadData(strTextFileName) Then
  189.         '... ╤é╨╛ ╤ü╤é╤Ç╨╛╨╕╨╝ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤â. ╨ò╤ü╨╗╨╕ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╨░ ╨┐╨╛╤ü╤é╤Ç╨╛╨╡╨╜╨░ ╤â╤ü╨┐╨╡╤ê╨╜╨╛, ╤ü╨╛╨╛╨▒╤ë╨░╨╡╨╝ ╨╛╨▒ ╤ì╤é╨╛╨╝ ╨┐╨╛╨╗╤î╨╖╨╛╨▓╨░╤é╨╡╨╗╤Ä.
  190.         If DrawDiagram(intDiagramIndex, strTextFileName) Then
  191.             RefreshDiagram = True
  192.             MsgBox("Diagramma tipa " & CStr(intDiagramIndex) & " bila uspeshno obnovlena na osnovanii dannih iz faila " & strTextFileName)
  193.         End If
  194.     End If
  195.  
  196.     Exit Function
  197. ErrHandler:
  198.     MsgBox("In performing the macros, an error has occured.", cdbExclamation)
  199. End Function
  200.  
  201. '========================================================================================================================
  202. '========================================================================================================================
  203.  
  204. Function LoadData(ByVal strFileName As String) As Boolean
  205. On Error GoTo ErrHandle
  206.  
  207.     Dim intFileNumber As Integer        '╨ÿ╨┤╨╡╨╜╤é╨╕╤ä╨╕╨║╨░╤é╨╛╤Ç ╨╛╨▒╤Ç╨░╨▒╨░╤é╤ï╨▓╨░╨╡╨╝╨╛╨│╨╛ ╤ä╨░╨╣╨╗╨░ ╨┤╨░╨╜╨╜╤ï╤à
  208.     Dim strLineData As String        '╨ƒ╨╡╤Ç╨╡╨╝╨╡╨╜╨╜╨░╤Å, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨░╤Å ╨╛╨┤╨╜╤â ╤ü╤é╤Ç╨╛╨║╤â ╨╕╨╖ ╤é╨╡╨║╤ü╤é╨╛╨▓╨╛╨│╨╛ ╤ä╨░╨╣╨╗╨░
  209.     Dim intFieldsCounter As Integer    '╨¥╨╛╨╝╨╡╤Ç ╨╛╨▒╤Ç╨░╨▒╨░╤é╤ï╨▓╨░╤Ä╤ë╨╡╨│╨╛╤ü╤Å ╨┐╨╛╨╗╤Å ╤ü╤é╤Ç╨╛╨║╨╕
  210.     Dim intSeparatorPos As Integer    '╨ƒ╨╛╨╖╨╕╤å╨╕╤Å ╤Ç╨░╨╖╨┤╨╡╨╗╨╕╤é╨╡╨╗╤Å ╨┐╨╛╨╗╨╡╨╣ ╤ü╤é╤Ç╨╛╨║╨╕
  211.     Dim strFiels As String            '╨í╨╛╨┤╨╡╤Ç╨╢╨╕╨╝╨╛╨╡ ╨╛╨┤╨╜╨╛╨│╨╛ ╨┐╨╛╨╗╤Å ╤ü╤é╤Ç╨╛╨║╨╕
  212.     Dim fNoError As Boolean            '╨ñ╨╗╨░╨│, ╨┐╨╛╨║╨░╨╖╤ï╨▓╨░╤Ä╤ë╨╕╨╣, ╤ç╤é╨╛ ╨┐╤Ç╨╕ ╨╛╨▒╤Ç╨░╨▒╨╛╤é╨║╨╡ ╨┤╨░╨╜╨╜╤ï╤à ╤ä╨░╨╣╨╗╨░ ╨╜╨╡╤é ╨╛╤ê╨╕╨▒╨╛╨║
  213.     Dim strCharSeparator As String    '╨á╨░╨╖╨┤╨╡╨╗╨╕╤é╨╡╨╗╤î ╨┐╨╛╨╗╨╡╨╣ ╤ü╤é╤Ç╨╛╨║╨╕
  214.     Dim dSumOfValues As Double        '╨₧╨▒╤ë╨░╤Å ╨┐╤Ç╨╕╨▒╤ï╨╗╤î ╨▓╨╛ ╨▓╤ü╨╡╤à ╤â╨╢╨╡ ╨╖╨░╤ç╨╕╤é╨░╨╜╨╜╤ï╤à ╤ä╨╕╨╗╨╕╨░╨╗╨░╤à
  215.     Dim i As Integer
  216.     
  217.     strCharSeparator = constrCharSeparator
  218.     
  219.     fNoError = True
  220.     
  221.     '╨₧╤é╨║╤Ç╤ï╤é╨╕╨╡ ╤é╨╡╨║╤ü╤é╨╛╨▓╨╛╨│╨╛ ╤ä╨░╨╣╨╗╨░ ╨┤╨╗╤Å ╤ç╤é╨╡╨╜╨╕╤Å ╨┤╨░╨╜╨╜╤ï╤à
  222.     intFileNumber = FreeFile()
  223.     Open strFileName For Input As #intFileNumber
  224.     
  225.     
  226.     iMaxUsedIndex = -1
  227.     
  228.     
  229.     '╨ù╨░╤ç╨╕╤é╤ï╨▓╨░╨╡╨╝ ╨┐╨╛ ╨╛╨┤╨╜╨╛╨╣ ╤ü╤é╤Ç╨╛╨║╨╡ ╨╕╨╖ ╨┤╨╛ ╤é╨╡╤à ╨┐╨╛╤Ç, ╨┐╨╛╨║╨░ ╨╜╨╡ ╨┤╨╛╤ü╤é╨╕╨│╨╜╨╡╨╝ ╨║╨╛╨╜╤å╨░ ╤é╨╡╨║╤ü╤é╨╛╨▓╨╛╨│╨╛ ╤ä╨░╨╣╨╗╨░ ╨╕╨╗╨╕ ╨┐╨╛╨║╨░ ╨╜╨╡ ╨▓╨╛╨╖╨╜╨╕╨║╨╜╨╡╤é ╨╛╤ê╨╕╨▒╨║╨░
  230.     Do While (Not EOF(intFileNumber)) And fNoError
  231.         '╨ù╨░╤ç╨╕╤é╨░╤é╤î ╤ü╤é╤Ç╨╛╨║╤â
  232.         Line Input #intFileNumber, strLineData
  233.         strLineData = Trim$(strLineData)
  234.         '╨ò╤ü╨╗╨╕ ╤ü╤é╤Ç╨╛╨║╨░ ╨╜╨╡ ╨┐╤â╤ü╤é╨░, ╨╛╨▒╤Ç╨░╨▒╨╛╤é╨░╨╡╨╝ ╨╡╨╡.
  235.         If strLineData <> "" Then
  236.             '╨ú╨▓╨╡╨╗╨╕╤ç╨╕╤é╤î ╨╜╨░ 1 ╨╖╨╜╨░╤ç╨╡╨╜╨╕╨╡ ╨╜╨░╨╕╨▒╨╛╨╗╤î╤ê╨╡╨│╨╛ ╨╕╤ü╨┐╨╛╨╗╤î╨╖╤â╤Ä╤ë╨╡╨│╨╛╤ü╤Å ╨╕╨╜╨┤╨╡╨║╤ü╨░ ╨▓ ╨╝╨░╤ü╤ü╨╕╨▓╨░╤à.
  237.             iMaxUsedIndex = iMaxUsedIndex + 1
  238.             '╨ƒ╤Ç╨╛╨▓╨╡╤Ç╨╕╤é╤î, ╨╜╨╡ ╤ü╨╗╨╕╤ê╨║╨╛╨╝ ╨╗╨╕ ╨╝╨╜╨╛╨│╨╛ ╤ü╤é╤Ç╨╛╨║ ╨▓ ╤ä╨░╨╣╨╗╨╡ ╨┤╨░╨╜╨╜╤ï╤à
  239.             If  iMaxUsedIndex > conintMaxProcessingStrings-1 Then
  240.                 MsgBox("V faile soderzhits'a bolee " & conintMaxProcessingStrings & " strok. Eto slishkom mnogo dlja takoj diagrammi.")
  241.                 fNoError = False
  242.             Else
  243.                 '╨ÿ╨╜╨╕╤å╨╕╨░╨╗╨╕╨╖╨░╤å╨╕╤Å ╨╜╨╛╨╝╨╡╤Ç╨░ ╤é╨╡╨║╤â╤ë╨╡╨│╨╛ ╨┐╨╛╨╗╤Å ╤é╨╡╨║╤â╤ë╨╡╨╣ ╤ü╤é╤Ç╨╛╨║╨╕
  244.                 intFieldsCounter = 1
  245.                 Do
  246.                     '╨₧╨▒╤Ç╨░╨▒╨░╤é╤ï╨▓╨░╨╡╨╝ ╨┐╨╛╨╗╤Å ╤ü╤é╤Ç╨╛╨║╨╕ ╨┤╨╛ ╤é╨╡╤à ╨┐╨╛╤Ç, ╨┐╨╛╨║╨░ ╨╜╨╡ ╨┤╨╛╤ü╤é╨╕╨│╨╜╨╡╨╝ ╨║╨╛╨╜╤å╨░ ╤ü╤é╤Ç╨╛╨║╨╕. 
  247.                     '╨ö╨░╨╜╨╜╤ï╨╡ ╨╕╨╖ ╨┐╨╛╨╗╨╡╨╣ ╨┐╨╛╨╝╨╡╤ë╨░╨╡╨╝ ╨▓ ╨╝╨░╤ü╤ü╨╕╨▓╤ï.
  248.                     intSeparatorPos = InStr(strLineData, strCharSeparator)
  249.                     If intSeparatorPos > 0 Then
  250.                         strFiels = Trim(Left(strLineData, intSeparatorPos - 1))
  251.                         strLineData = Right(strLineData, Len(strLineData) - intSeparatorPos)
  252.                     Else
  253.                         '╨¥╨╛╨▓╤ï╨╣ ╤ü╨╡╨┐╨░╤Ç╨░╤é╨╛╤Ç ╨╜╨╡ ╨╜╨░╨╣╨┤╨╡╨╜. ╨¡╤é╨╛ ╨┐╨╛╤ü╨╗╨╡╨┤╨╜╨╡╨╡ ╨┐╨╛╨╗╨╡ ╤ü╤é╤Ç╨╛╨║╨╕.
  254.                         strFiels = Trim(strLineData)
  255.                     End If
  256.                     '╨ò╤ü╨╗╨╕ ╨╜╨╛╨╝╨╡╤Ç ╨┐╨╛╨╗╤Å ╤Ç╨░╨▓╨╡╨╜ ╨╛╨┤╨╜╨╛╨╝╤â ╨╕╨╖ ╨╛╨▒╤è╤Å╨▓╨╗╨╡╨╜╨╜╤ï╤à ╨║╨░╨║ ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨╕╨╡ ╨┤╨░╨╜╨╜╤ï╨╡ ╨┤╨╗╤Å ╨┐╨╛╤ü╤é╤Ç╨╛╨╡╨╜╨╕╤Å,
  257.                     '╨╖╨░╨╜╨╛╤ü╨╕╨╝ ╨┤╨░╨╜╨╜╤ï╨╡ ╨▓ ╨╝╨░╤ü╤ü╨╕╨▓╤ï.
  258.                     Select Case intFieldsCounter
  259.                     Case aiNameFieldPos(intDiagramIndex-1)
  260.                         asNames(iMaxUsedIndex) = strFiels
  261.                     Case aiValueFieldPos(intDiagramIndex-1)
  262.                         adValues(iMaxUsedIndex) = strFiels
  263.                     Case Else
  264.                     End Select
  265.                     intFieldsCounter = intFieldsCounter + 1
  266.                 Loop While intSeparatorPos > 0
  267.             End If
  268.         End If
  269.     Loop
  270.     
  271.     Close #intFileNumber
  272.     
  273.     '╨ƒ╤Ç╨╛╨▓╨╡╤Ç╨╕╤é╤î ╨▒╤ï╨╗╨╕ ╨╗╨╕ ╨▓ ╤ä╨░╨╣╨╗╨╡ ╨▓╨╛╨╛╨▒╤ë╨╡ ╨║╨░╨║╨╕╨╡-╤é╨╛ ╨┤╨░╨╜╨╜╤ï╨╡.
  274.     If iMaxUsedIndex = -1 Then
  275.         fNoError = False
  276.         MsgBox("V ukazannom faile ne obnaruzheni dannie.")
  277.     End If
  278.     
  279.     LoadData = fNoError
  280.     Exit Function
  281.     
  282. ErrHandle:
  283.     MsgBox ("Proizoshla oshibka pri zachitivanii textovogo faila.", cdbExclamation)
  284.     LoadData = False
  285.     Exit Function
  286. End Function 
  287.  
  288. '========================================================================================================================
  289. '========================================================================================================================
  290.  
  291. '╨ƒ╨╛╤ü╤é╤Ç╨╛╨╡╨╜╨╕╨╡ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï ╨▓ ╨┤╨╛╨║╤â╨╝╨╡╨╜╤é╨╡ ConceptDraw
  292. Function DrawDiagram(ByVal intDiagramIndex As Integer, ByVal strTextFileName As String) As Boolean
  293. On Error GoTo ErrHandle
  294.     Dim i As Integer
  295.     Dim iR As Integer                '╨ª╨▓╨╡╤é Red ╨║╨╛╨╝╨┐╨╛╨╜╨╡╨╜╤é╤ï ╤å╨▓╨╡╤é╨░ ╤ü╤é╨╛╨╗╨▒╤å╨░ ╨▓ RGB-╨┐╤Ç╨╡╨┤╤ü╤é╨░╨▓╨╗╨╡╨╜╨╕╨╕.
  296.     Dim iG As Integer                '╨ª╨▓╨╡╤é Green ╨║╨╛╨╝╨┐╨╛╨╜╨╡╨╜╤é╤ï ╤å╨▓╨╡╤é╨░ ╤ü╤é╨╛╨╗╨▒╤å╨░ ╨▓ RGB-╨┐╤Ç╨╡╨┤╤ü╤é╨░╨▓╨╗╨╡╨╜╨╕╨╕.
  297.     Dim iB As Integer                '╨ª╨▓╨╡╤é Blue ╨║╨╛╨╝╨┐╨╛╨╜╨╡╨╜╤é╤ï ╤å╨▓╨╡╤é╨░ ╤ü╤é╨╛╨╗╨▒╤å╨░ ╨▓ RGB-╨┐╤Ç╨╡╨┤╤ü╤é╨░╨▓╨╗╨╡╨╜╨╕╨╕.
  298.     Dim dblX0 As Double                  '╨Ü╨╛╨╛╤Ç╨┤╨╕╨╜╨░╤é╤ï ╨╗╨╡╨▓╨╛╨│╨╛ ╨╜╨╕╨╢╨╜╨╡╨│╨╛ ╤â╨│╨╗╨░ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  299.     Dim dblY0 As Double                  
  300.     Dim dblUnitY As Double               'the height of the elements in "Graph  scale 4"
  301.     Dim strLibObjTextBar As String       'the name of the library object representing the bars of the diagram
  302.     Dim dblStepScale As Double           'the scale of the diagram
  303.     Dim intScaleStepCount As Integer     'the number of elements in "Graph  scale 4"
  304.     Dim dblDiagWidth As Double        '╨Æ╤ï╤ü╨╛╤é╨░ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  305.     Dim dblDiagHeight As Double        '╨¿╨╕╤Ç╨╕╨╜╨░ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  306.     Dim curPage As Page            '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ ╤Ç╨░╨▒╨╛╤ç╤â╤Ä ╤ü╤é╤Ç╨░╨╜╨╕╤å╤â
  307.     Dim FileNameProp As CustomProp    '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ Custom Property ╨╛╨▒╤è╨╡╨║╤é╨░ (╨▓ ╨╛╨┤╨╜╨╛╨╝ ╨╕╨╖ ╨╜╨╕╤à ╤à╤Ç╨░╨╜╨╕╤é╤ü╤Å ╨┐╨╛╨╗╨╜╨╛╨╡ ╨╕╨╝╤Å ╤ä╨░╨╣╨╗╨░ ╨┤╨░╨╜╨╜╤ï╤à). 
  308.     Dim dblMaxProd As Double        '╨¥╨░╨╕╨▒╨╛╨╗╤î╤ê╨╡╨╡ ╨╖╨╜╨░╤ç╨╡╨╜╨╕╨╡ ╨┐╤Ç╨╕╨▒╤ï╨╗╨╕ ╨┤╨╗╤Å ╨▓╤ü╨╡╤à ╤ä╨╕╨╗╨╕╨░╨╗╨╛╨▓
  309.     Dim dblBarWidth As Double        '╨¿╨╕╤Ç╨╕╨╜╨░ ╤ü╤é╨╛╨╗╨▒╤å╨░ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  310.     Dim dblBarHeight As Double        '╨Æ╤ï╤ü╨╛╤é╨░ ╤é╨╡╨║╤â╤ë╨╡╨│╨╛ ╤ü╤é╨╛╨╗╨▒╤å╨░ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  311.     Dim workLib As Library            '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ ╨╛╤é╨║╤Ç╤ï╤é╤â╤Ä ╨▒╨╕╨▒╨╗╨╕╨╛╤é╨╡╨║╤â, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╤â╤Ä ╨╕╤ü╨┐╨╛╨╗╤î╨╖╤â╤Ä╤ë╨╕╨╡╤ü╤Å ╨╛╨▒╤è╨╡╨║╤é╤ï.
  312.     Dim libBarMaster As Master        '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ Master, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨╕╨╣ ╨╕╤ü╨┐╨╛╨╗╤î╨╖╤â╤Ä╤ë╨╕╨╣╤ü╤Å ╨╛╨▒╤è╨╡╨║╤é.
  313.     Dim libScaleMaster As Master        '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ Master, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨╕╨╣ ╨╕╤ü╨┐╨╛╨╗╤î╨╖╤â╤Ä╤ë╨╕╨╣╤ü╤Å ╨╛╨▒╤è╨╡╨║╤é ╨┤╨╗╤Å ╨╛╤é╨╛╨▒╤Ç╨░╨╢╨╡╨╜╨╕╤Å Scale.
  314.     Dim ScaleShape As Shape            '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ ╨╛╨▒╤è╨╡╨║╤é, ╨╕╨╖╨╛╨▒╤Ç╨░╨╢╨░╤Ä╤ë╨╕╨╣ Scale
  315.     Dim BarShape As Shape            '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ ╨╛╨▒╤è╨╡╨║╤é, ╨╕╨╖╨╛╨▒╤Ç╨░╨╢╨░╤Ä╤ë╨╕╨╣ ╤ü╤é╨╛╨╗╨▒╨╡╤å ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  316.     Dim BarTextShape As Shape        '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ ╤ê╤ì╨╣╨┐, ╨┐╤Ç╨╡╨┤╤ü╤é╨░╨▓╨╗╤Å╤Ä╤ë╨╕╨╣ ╨┐╨╛╨┤╨┐╨╕╤ü╤î ╨║ ╤ü╤é╨╛╨╗╨▒╤å╤â ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  317.     Dim DiagramShape As Shape        '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ ╤ê╤ì╨╣╨┐, ╨┐╤Ç╨╡╨┤╤ü╤é╨░╨▓╨╗╤Å╤Ä╤ë╨╕╨╣ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤â
  318.     Dim TitleShape As Shape            '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ ╤ê╤ì╨╣╨┐, ╨┐╤Ç╨╡╨┤╤ü╤é╨░╨▓╨╗╤Å╤Ä╤ë╨╕╨╣ ╨╖╨░╨│╨╛╨╗╨╛╨▓╨╛╨║ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  319.     Dim ValueText As Shape            '╨í╤ü╤ï╨╗╨║╨░ ╨╜╨░ ╤ê╤ì╨╣╨┐, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨╕╨╣ ╨╖╨╜╨░╤ç╨╡╨╜╨╕╨╡ ╨┐╤Ç╨╕╨▒╤ï╨╗╨╕ ╤ä╨╕╨╗╨╕╨░╨╗╨░, ╤ü╨╛╨╛╤é╨▓╨╡╤é╤ü╤é╨▓╤â╤Ä╤ë╨╡╨│╨╛ ╤ü╤é╨╛╨╗╨▒╤å╤â ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï
  320.     Dim intCharColor As Integer        '╨ª╨▓╨╡╤é ╤é╨╡╨║╤ü╤é╨░ ╨▓ ╨╕╨╜╨┤╨╡╨║╤ü╨╜╨╛╨╝ ╨┐╤Ç╨╡╨┤╤ü╤é╨░╨▓╨╗╨╡╨╜╨╕╨╕ ╤å╨▓╨╡╤é╨░
  321.     Dim dblTitleYShift As Double        '╨í╨╝╨╡╤ë╨╡╨╜╨╕╨╡ ╨╖╨░╨│╨╛╨╗╨╛╨▓╨║╨░ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï ╨┐╨╛ ╨╛╤é╨╜╨╛╤ê╨╡╨╜╨╕╤Ä ╨║ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╨╡ ╨┐╨╛ ╨▓╨╡╤Ç╤é╨╕╨║╨░╨╗╨╕
  322.     
  323.     
  324.     Set curPage = thisDoc.Page(1)
  325.  
  326.     '╨₧╨┐╤Ç╨╡╨┤╨╡╨╗╤Å╨╡╨╝ ╨╜╨░╨╕╨▒╨╛╨╗╤î╤ê╨╡╨╡ ╨╖╨╜╨░╤ç╨╡╨╜╨╕╨╡ ╨┐╤Ç╨╕╨▒╤ï╨╗╨╕ ╨▓╨╛ ╨▓╤ü╨╡╤à ╤ä╨╕╨╗╨╕╨░╨╗╨░╤à    
  327.     dblMaxProd = 0
  328.     For i = 0 To iMaxUsedIndex 
  329.         If dblMaxProd < adValues(i) Then
  330.             dblMaxProd = adValues(i)
  331.         End If
  332.     Next
  333.     
  334.     '╨Æ╤ï╤ç╨╕╤ü╨╗╤Å╨╡╨╝ ╨┐╨░╤Ç╨░╨╝╨╡╤é╤Ç╤ï ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï - ╨╝╨░╤ü╤ê╤é╨░╨▒, ╨║╨╛╨╗╨╕╤ç╨╡╤ü╤é╨▓╨╛ ╨╜╨░╨╜╨╛╤ü╨╕╨╝╤ï╤à ╨┤╨╡╨╗╨╡╨╜╨╕╨╣, ╨║╨╛╨╗╨╕╤ç╨╡╤ü╤é╨▓╨╛ ╨╡╨┤╨╕╨╜╨╕╤å, 
  335.     '╨║╨╛╤é╨╛╤Ç╤ï╨╡ ╨╕╨╖╨╛╨▒╤Ç╨░╨╢╨░╨╡╤é ╨║╨░╨╢╨┤╨╛╨╡ ╨┤╨╡╨╗╨╡╨╜╨╕╨╡, ╤ê╨╕╤Ç╨╕╨╜╤â ╤ü╤é╨╛╨╗╨▒╤å╨░
  336.     dblStepScale = CalcScaleStep(dblMaxProd)
  337.     intFilialCount = iMaxUsedIndex + 1
  338.     If 100 < 2000 / intFilialCount Then
  339.         dblBarWidth = 100
  340.     Else
  341.         dblBarWidth = 2000 / intFilialCount
  342.     End If    
  343.     intScaleStepCount = dblMaxProd \ dblStepScale
  344.     If intScaleStepCount < 10 Then 
  345.         intScaleStepCount = intScaleStepCount + 1
  346.     End If
  347.     dblUnitY = 1000 \ intScaleStepCount
  348.     '╨₧╨┐╤Ç╨╡╨┤╨╡╨╗╤Å╨╡╨╝ ╨┐╨╛╨╗╨╛╨╢╨╡╨╜╨╕╨╡ ╨╕ ╤Ç╨░╨╖╨╝╨╡╤Ç ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï ╨╕ ╨┐╨╛╨┤╨┐╨╕╤ü╨╕ ╨║ ╨╜╨╡╨╣.
  349.     Select Case intDiagramIndex
  350.     Case 1
  351.         dblDiagWidth = intFilialCount * dblBarWidth 
  352.         dblDiagHeight = dblUnitY * intScaleStepCount 
  353.         dX0 = 200
  354.         dY0 = 250 + dblDiagHeight 
  355.         dblTitleYShift = 150
  356.         strLibObjTextBar = "Vertical text bar"
  357.     Case 2
  358.         dblDiagWidth = intFilialCount * dblBarWidth 
  359.         dblDiagHeight = dblUnitY * intScaleStepCount 
  360.         dX0 = 200
  361.         dY0 = 2900
  362.         dblTitleYShift = 200
  363.         strLibObjTextBar = "Vertical   3-D bar"
  364.     Case 3
  365.         dblDiagWidth = dblUnitY * intScaleStepCount 
  366.         dblDiagHeight = intFilialCount * dblBarWidth 
  367.         dX0 = 2000
  368.         dY0 = 250 + dblDiagHeight 
  369.         dblTitleYShift = 150
  370.         strLibObjTextBar = "Vertical text bar"
  371.     Case 4
  372.         dblDiagWidth = dblUnitY * intScaleStepCount 
  373.         dblDiagHeight = intFilialCount * dblBarWidth 
  374.         dX0 = 2000
  375.         dY0 = 2800
  376.         dblTitleYShift = 200
  377.         strLibObjTextBar = "Vertical   3-D bar"
  378.     End Select
  379.     i=1
  380.     Set DiagramShape = Nothing
  381.     Set TitleShape = Nothing
  382.     '╨ÿ╤ë╨╡╨╝ ╨▓ ╨┤╨╛╨║╤â╨╝╨╡╨╜╤é╨╡ ╤ê╤ì╨╣╨┐╤ï, ╨▓ ╨║╨╛╤é╨╛╤Ç╤ï╤à ╨┤╨╛╨╗╨╢╨╜╤ï ╨▒╤ï╤é╤î ╤ü╨╛╨╖╨┤╨░╨╜╤ï ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï ╨╕ ╨┐╨╛╨┤╨┐╨╕╤ü╨╕ ╨║ ╨╜╨╕╨╝.
  383.     Do While i <= curPage.ShapesNum()
  384.         if curPage.Shape(i).Name = "Diagram" & CStr(intDiagramIndex) Then
  385.             Set DiagramShape = curPage.Shape(i)
  386.         End If
  387.         if curPage.Shape(i).Name = "Title" & CStr(intDiagramIndex) Then
  388.             Set TitleShape = curPage.Shape(i)
  389.         End If
  390.         i=i+1
  391.     Loop
  392.     '╨ò╤ü╨╗╨╕ ╤ê╤ì╨╣╨┐ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤ï ╨╜╨╡ ╨╜╨░╨╣╨┤╨╡╨╜, ╨╛╨╜ ╤ü╨╛╨╖╨┤╨░╨╡╤é╤ü╤Å. 
  393.     If DiagramShape = Nothing Then
  394.         Set DiagramShape = curPage.DrawGroup(dX0, dY0 - dblDiagHeight, dX0 + dblDiagWidth, dY0)
  395.         DiagramShape.Name = "Diagram" & CStr(intDiagramIndex)
  396.     Else
  397.     '╨ò╤ü╨╗╨╕ ╤ê╤ì╨╣╨┐ ╨╜╨░╨╣╨┤╨╡╨╜, ╨╛╨╜ ╨╛╤ç╨╕╤ë╨░╨╡╤é╤ü╤Å ╨╛╤é Child-╨╛╨▒╤è╨╡╨║╤é╨╛╨▓, ╨▓╤ï╤ü╤é╨░╨▓╨╗╤Å╤Ä╤é╤ü╤Å ╨╡╨│╨╛ ╨┐╨░╤Ç╨░╨╝╨╡╤é╤Ç╤ï ╨╕ ╨║╨╛╨╛╤Ç╨┤╨╕╨╜╨░╤é╤ï.
  398.         DiagramShape.RemoveAllShapes()
  399.         DiagramShape.Height = dblDiagHeight
  400.         DiagramShape.Width = dblDiagWidth
  401.         DiagramShape.GPinX = dX0 + dblDiagWidth/2
  402.         DiagramShape.GPinY = dY0 - dblDiagHeight/2 
  403.     End If
  404.     '╨É╨╜╨░╨╗╨╛╨│╨╕╤ç╨╜╨╛ ╨┤╨╗╤Å ╨╖╨░╨│╨╛╨╗╨╛╨▓╨║╨░
  405.     If TitleShape = Nothing Then
  406.         Set TitleShape = curPage.DrawRect(dX0, dY0 - dblDiagHeight-dblTitleYShift-50, dX0 + dblDiagWidth, dY0 - dblDiagHeight-dblTitleYShift+50)
  407.         TitleShape.Name = "Title" & CStr(intDiagramIndex)
  408.     Else
  409.         TitleShape.Height = 100 
  410.         TitleShape.Width = 1800
  411.         TitleShape.GPinX = dX0 + TitleShape.Width/2 - 100
  412.         TitleShape.GPinY = dY0 - dblDiagHeight - dblTitleYShift 
  413.     End If
  414.     TitleShape.FillPattern = 0
  415.     TitleShape.PenPattern = 0
  416.     TitleShape.Text = "Dannie diagrammi importirovani iz kolonok " & aiNameFieldPos(intDiagramIndex - 1) & " i " & aiValueFieldPos(intDiagramIndex - 1) & " faila " & Chr(10) & strTextFileName 
  417.     TitleShape.SetParaHAlign(1, Len(TitleShape.Text), 0)
  418.     TitleShape.SetCharSize(1, Len(TitleShape.Text), 11)
  419.     TitleShape.SetCharStyle(1, Len(TitleShape.Text), 1)
  420.     
  421.     '╨₧╤é╨║╤Ç╤ï╨▓╨░╤Ä ╨▒╨╕╨▒╨╗╨╕╨╛╤é╨╡╨║╤â ConceptDraw,    
  422.     '╨┐╤Ç╨╛╨▓╨╡╤Ç╤Å╤Ä, ╤â╨┤╨░╨╗╨╛╤ü╤î ╨╗╨╕ ╨╡╨╡ ╨╛╤é╨║╤Ç╤ï╤é╤î ╨╕ ╨╡╤ü╤é╤î ╨╗╨╕ ╨▓ ╨╜╨╡╨╣ ╨╜╨╡╨╛╨▒╤à╨╛╨┤╨╕╨╝╤ï╨╡ ╨┤╨╗╤Å ╤Ç╨░╨▒╨╛╤é╤ï ╨╛╨▒╤è╨╡╨║╤é╤ï.
  423.     Set workLib = thisApp.OpenLib("ChartingFigures.cdl")
  424.     '╨₧╤é╨║╤Ç╤ï╨╗╨░╤ü╤î ╨╗╨╕ ╨▒╨╕╨▒╨╗╨╕╨╛╤é╨╡╨║╨░?
  425.     If Null = workLib Then
  426.         DrawDiagram = False
  427.         Msgbox("Ne udalos' otkrit' biblioteku ChartingFigures.cdl")
  428.         Exit Function
  429.     End If
  430.     '╨ò╤ü╤é╤î ╨╗╨╕ ╨╜╤â╨╢╨╜╤ï╨╡ ╨╛╨▒╤è╨╡╨║╤é╤ï?
  431.     Set libBarMaster = workLib.MasterByName(strLibObjTextBar)
  432.     If Null = libBarMaster Then
  433.         DrawDiagram = False
  434.         Msgbox("Ob'ekt """ & strLibObjTextBar & """ ne najden v biblioteke")
  435.         Exit Function
  436.     End If
  437.     Set libScaleMaster = workLib.MasterByName("Graph  scale 4")
  438.     If Null = libScaleMaster Then
  439.         DrawDiagram = False
  440.         Msgbox("Ob'ekt ""Graph  scale 4"" ne najden v biblioteke")
  441.         Exit Function
  442.     End If
  443.     '╨Æ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤â ╨┐╨╛╨╝╨╡╤ë╨░╤Ä╤é╤ü╤Å ╨╛╨▒╤è╨╡╨║╤é╤ï, ╨╕╨╖╨╛╨▒╤Ç╨░╨╢╨░╤Ä╤ë╨╕╨╡ ╤ê╨║╨░╨╗╤â.
  444.     For i=1 To intScaleStepCount
  445.         If intDiagramIndex = 1 Or intDiagramIndex = 2 Then
  446.             Set ScaleShape = DiagramShape.DropStamp(libScaleMaster.Shape, - 25, dblDiagHeight - dblUnitY *(i - 0.5))
  447.         Else
  448.             Set ScaleShape = DiagramShape.DropStamp(libScaleMaster.Shape, dblUnitY *(i - 0.5), dblDiagHeight + 25)
  449.             ScaleShape.FlipY = True
  450.             ScaleShape.Angle = -1.570796
  451.             ScaleShape.TextAngle = 3.141593
  452.         End If
  453.         ScaleShape.Width = 50
  454.         ScaleShape.Height = dblUnitY 
  455.         ScaleShape.Text = CStr(dblStepScale * i)
  456.     Next
  457.     Randomize
  458.     '╨ƒ╨╛╨╝╨╡╤ë╨░╤Ä ╨▓ ╨┤╨╕╨░╨│╤Ç╨░╨╝╨╝╤â ╤ü╤é╨╛╨╗╨▒╤å╤ï, ╨╕╨╖╨╛╨▒╤Ç╨░╨╢╨░╤Ä╤ë╨╕╨╡ ╨┐╤Ç╨╕╨▒╤ï╨╗╤î, ╨┐╨╛╨╗╤â╤ç╨╡╨╜╨╜╤â╤Ä ╤ä╨╕╨╗╨╕╨░╨╗╨╛╨╝.
  459.     For i = 0 To iMaxUsedIndex        
  460.         '╨₧╨┐╤Ç╨╡╨┤╨╡╨╗╤Å╤Ä ╤å╨▓╨╡╤é ╤ü╤é╨╛╨╗╨▒╤å╨░ ╤ü╨╗╤â╤ç╨░╨╣╨╜╤ï╨╝ ╨╛╨▒╤Ç╨░╨╖╨╛╨╝.        
  461.         iR = Int(Rnd() * 255.999)  
  462.         iG = Int(Rnd() * 255.999)
  463.         iB = Int(Rnd() * 255.999)
  464.         dblBarHeight = adValues(i) * dblUnitY / dblStepScale
  465.         Select Case intDiagramIndex
  466.         Case 1, 2
  467.             '╨ƒ╨╛╨╝╨╡╤ë╨░╤Ä ╤ü╤é╨╛╨╗╨▒╨╡╤å
  468.             Set BarShape = DiagramShape.DropStamp(libBarMaster.Shape, dblBarWidth*(i+0.5), dblDiagHeight - dblBarHeight / 2)
  469.             '╨ƒ╨╛╨╝╨╡╤ë╨░╤Ä ╨┐╨╛╨┤╨┐╨╕╤ü╤î ╨║ ╤ü╤é╨╛╨╗╨▒╤å╤â ╤ü ╤é╨╡╨║╤ü╤é╨╛╨╝, ╤ü╨╛╨┤╨╡╤Ç╨╢╨░╤ë╨╕╨╝ ╨╖╨╜╨░╤ç╨╡╨╜╨╕╨╡ ╤Ç╨░╨╖╨╝╨╡╤Ç╨░ ╨┐╤Ç╨╕╨▒╤ï╨╗╨╕
  470.             Set ValueText = DiagramShape.DrawRect(dblBarWidth*i, dblDiagHeight - dblBarHeight - 50, dblBarWidth*(i+1), dblDiagHeight - dblBarHeight)
  471.         Case 3, 4
  472.             Set BarShape = DiagramShape.DropStamp(libBarMaster.Shape, dblBarHeight / 2, dblDiagHeight - dblBarWidth*(i + 0.5))
  473.             Set ValueText = DiagramShape.DrawRect(dblBarHeight, dblDiagHeight - dblBarWidth*(i + 0.5) - 25, dblBarHeight + 150, dblDiagHeight - dblBarWidth*(i + 0.5) + 25)
  474.             BarShape.FlipX = True
  475.             BarShape.Angle = 1.570796
  476.         End Select
  477.         '╨ú╤é╨╛╤ç╨╜╤Å╤Ä ╤ü╨▓╨╛╨╣╤ü╤é╨▓╨░ ╨╛╨▒╤è╨╡╨║╤é╨╛╨▓ ╨┤╨╗╤Å ╨╜╨░╨╕╨▒╨╛╨╗╨╡╨╡ ╤â╨┤╨╛╨▒╨╜╨╛╨│╨╛ ╨╛╤é╨╛╨▒╤Ç╨░╨╢╨╡╨╜╨╕╤Å.
  478.         ValueText.Text = CStr(adValues(i))
  479.         ValueText.PenPattern = 0 
  480.         ValueText.FillPattern = 0 
  481.         ValueText.SetCharSize(1, Len(ValueText.Text), 9)
  482.         ValueText.SetCharColor(1, Len(ValueText.Text), 0, 0, 0)
  483.         BarShape.Width = dblBarWidth
  484.         BarShape.Height = dblBarHeight
  485.         '╨¥╨░╤à╨╛╨╢╤â ╤ê╤ì╨╣╨┐, ╨▓ ╨║╨╛╤é╨╛╤Ç╨╛╨╝ ╨▒╤â╨┤╨╡╤é ╨▓╤ï╨▓╨╡╨┤╨╡╤é ╤é╨╡╨║╤ü╤é ╨▓╨╜╤â╤é╤Ç╨╕ ╤ü╤é╨╛╨╗╨▒╤å╨░. ╨ó╨╡╨║╤ü╤é ╤ü╨╛╨┤╨╡╤Ç╨╢╨╕╤é ╨╛╨┐╨╕╤ü╨░╨╜╨╕╨╡ ╤ä╨╕╨╗╨╕╨░╨╗╨░.
  486.         If BarShape.ShapesNum()>0 Then
  487.             Set BarTextShape = BarShape.Shape(BarShape.ShapesNum())
  488.         Else
  489.             Set BarTextShape = BarShape
  490.         End If
  491.         BarTextShape.Text = asNames(i)
  492.         '╨ú╤ü╤é╨░╨╜╨░╨▓╨╗╨╕╨▓╨░╤Ä ╤å╨▓╨╡╤é ╤é╨╡╨║╤ü╤é╨░ ╨▓ ╤ü╤é╨╛╨╗╨▒╤å╨╡. ╨ó╨╡╨║╤ü╤é ╨┤╨╛╨╗╨╢╨╡╨╜ ╨▓╤ü╨╡╨│╨┤╨░ ╨▓╨╕╨┤╨╡╨╜ ╨╜╨░ ╤ä╨╛╨╜╨╡ ╤ü╤é╨╛╨╗╨▒╤å╨░.
  493.         BarTextShape.FillColor.SetRGB(iR,iG,iB)
  494.         If iR<90 Or iG<90 Or iB<90 Then
  495.             intCharColor = 255
  496.         Else 
  497.             intCharColor = 0 
  498.         End If
  499.         BarTextShape.SetCharColor(1, Len(BarTextShape.Text), intCharColor, intCharColor, intCharColor)
  500.     Next
  501.     
  502.     i=1
  503.     Set FileNameProp = Nothing
  504.     '╨ƒ╨╡╤Ç╨╡╨▒╨╕╤Ç╨░╨╡╨╝ CustomProperty ╨╛╨▒╤è╨╡╨║╤é╨░ ╨┤╨╛ ╤é╨╡╤à ╨┐╨╛╤Ç, ╨┐╨╛╨║╨░ ╨╜╨╡ ╨▒╤â╨┤╨╡╤é ╨╜╨░╨╣╨┤╨╡╨╜ ╤é╨╛╤é, ╤ç╤é╨╛ ╤ü╨╛╨┤╨╡╤Ç╨╢╨╕╤é
  505.     '╨╕╨╝╤Å ╤ä╨░╨╣╨╗╨░ ╨┤╨░╨╜╨╜╤ï╤à. ╨ò╨│╨╛ Label ╨┤╨╛╨╗╨╢╨╡╨╜ ╨▒╤ï╤é╤î ╤Ç╨░╨▓╨╡╨╜ "LastSourceFileName" 
  506.     Do While i<=DiagramShape.CustomPropsNum() And FileNameProp = Nothing
  507.         If DiagramShape.CustomProp(i).Label = "LastSourceFileName" Then
  508.             Set FileNameProp = DiagramShape.CustomProp(i) 
  509.         End If
  510.         i = i + 1    
  511.     Loop 
  512.     '╨ò╤ü╨╗╨╕ ╤é╨░╨║╨╛╨│╨╛ CustomProperty ╨╜╨╡ ╤ü╤â╤ë╨╡╤ü╤é╨▓╤â╨╡╤é, ╨╛╨╜ ╤ü╨╛╨╖╨┤╨░╨╡╤é╤ü╤Å.
  513.     If FileNameProp = Nothing Then
  514.         Set FileNameProp = DiagramShape.AddCustomProp() 
  515.         FileNameProp.Label = "LastSourceFileName" 
  516.     End If
  517.     FileNameProp.Value = strTextFileName 
  518.     FileNameProp.Type = 0
  519.     FileNameProp.Prompt = "Imja Fajla, ispol'zovavshegosja v kachestve poslednego istochnika dannih"
  520.     
  521.     DrawDiagram = True
  522.     Exit Function
  523. ErrHandle:
  524.     MsgBox ("Proizoshla oshibka pri postroenii diagrammi.", cdbExclamation)
  525.     DrawDiagram = False
  526.     Exit Function
  527. End Function
  528.  
  529. '========================================================================================================================
  530. '========================================================================================================================
  531.  
  532. 'Adjusting the suitable scale for the diagram
  533. Function CalcScaleStep(ByRef dblMaxProd As Double) As Double
  534.     CalcScaleStep = 1
  535.     If dblMaxProd > 0 Then 'Checking the correctness of the parameter
  536.         CalcScaleStep = 10 ^ Int(Log(dblMaxProd) / Log(10))
  537.         If CalcScaleStep = dblMaxProd Then
  538.             CalcScaleStep = CalcScaleStep / 10
  539.         End If
  540.     End If
  541. End Function
  542.  
  543.  
  544.