⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 realtime.frm

📁 Delphi Component - Chart Fx
💻 FRM
字号:
VERSION 5.00
Object = "{8996B0A4-D7BE-101B-8650-00AA003A5593}#4.0#0"; "CFX4032.OCX"
Begin VB.Form Form1 
   Caption         =   "Chart FX. Real-time charts"
   ClientHeight    =   7650
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7170
   LinkTopic       =   "Form1"
   ScaleHeight     =   7650
   ScaleWidth      =   7170
   StartUpPosition =   3  'Windows Default
   Begin VB.CheckBox Check2 
      Caption         =   "Scroll x-axis"
      Height          =   375
      Left            =   2400
      TabIndex        =   4
      Top             =   7200
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Add ONE"
      Height          =   375
      Left            =   5040
      TabIndex        =   3
      Top             =   7200
      Width           =   1575
   End
   Begin ChartfxLibCtl.ChartFX ChartFX2 
      Height          =   3495
      Left            =   120
      TabIndex        =   2
      Top             =   3600
      Width           =   6975
      _cx             =   1710370831
      _cy             =   1710364693
      _Version        =   262144
      TypeMask        =   109576194
      LeftGap         =   47
      Axis(0).Min     =   -80
      Axis(0).Max     =   80
      Axis(0).Style   =   26664
      nColors         =   2
      Pallete         =   "realtime.frx":0000
      Colors          =   "realtime.frx":00E4
      TopFontMask     =   268435464
      BeginProperty TopFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Courier"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Title(2)        =   "This way -->"
   End
   Begin ChartfxLibCtl.ChartFX ChartFX1 
      Height          =   3375
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   6975
      _cx             =   1710370831
      _cy             =   1710364481
      _Version        =   262144
      TypeMask        =   109576193
      LeftGap         =   47
      MarkerShape     =   0
      BorderWidth     =   2
      Axis(0).Min     =   -80
      Axis(0).Max     =   80
      Axis(0).Style   =   26664
      nColors         =   2
      Pallete         =   "realtime.frx":0114
      Colors          =   "realtime.frx":01F8
      TopFontMask     =   268435464
      BeginProperty TopFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Courier"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Title(2)        =   "<-- This way"
   End
   Begin VB.CheckBox Check1 
      Caption         =   "Start data acquisition"
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   7200
      Width           =   1935
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   6720
      Top             =   7200
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim nOffset As Long

Private Sub Check1_Click()
    Timer1.Enabled = Check1.Value
End Sub


Private Sub Command1_Click()
    Call AddPoint
End Sub

Private Sub Form_Load()
    'set and initialize the buffer of values for this real time chart
    ChartFX1.MaxValues = 20
    ChartFX1.OpenDataEx COD_VALUES Or COD_REMOVE, 2, 20
    ChartFX1.CloseData COD_VALUES
    
    ChartFX2.MaxValues = 20
    ChartFX2.OpenDataEx COD_VALUES Or COD_REMOVE, 2, 20
    ChartFX2.CloseData COD_VALUES
    
    ' Optimize scrolling. These lines will make the chart scroll faster.
    ChartFX1.TypeMask = ChartFX1.TypeMask Or CT_EVENSPACING
    ChartFX2.TypeMask = ChartFX2.TypeMask Or CT_EVENSPACING
    
    nOffset = 0
    ChartFX1.RealTimeStyle = CRT_LOOPPOS Or CRT_NOWAITARROW
    ChartFX2.RealTimeStyle = CRT_LOOPPOS Or CRT_NOWAITARROW
    ChartFX2.TypeEx = ChartFX2.TypeEx Or CTE_NOLEGINVALIDATE
End Sub

Private Sub AddPoint()
    Dim nCOD As CfxCod
    
    ' Switch realtime styles when the end of the
    If nOffset = 20 Then
        ChartFX1.RealTimeStyle = CRT_NOWAITARROW
        ChartFX1.Refresh
        ChartFX2.RealTimeStyle = CRT_NOWAITARROW
        ChartFX2.Refresh
    End If
    
    nCOD = COD_VALUES Or COD_REALTIME
    
    'insert one point from the left in realtime for each series
    ChartFX1.OpenDataEx COD_VALUES Or COD_INSERTPOINTS, 2, 1
        ChartFX1.ValueEx(0, 0) = -50 + Rnd * 100
        ChartFX1.ValueEx(1, 0) = -50 + Rnd * 100
    ChartFX1.CloseData nCOD
    
    ' Scroll x-axis labels too
    If Check2 Then
        nCOD = nCOD Or COD_SCROLLLEGEND
        If nOffset >= 20 Then ' Eliminate first (scroll) and add one at the end
            ChartFX2.Legend(0) = Chr$(1)
            ChartFX2.Legend(19) = Str(nOffset)
        Else
            ChartFX2.Legend(nOffset) = Str(nOffset)
        End If
    End If
    
    'add one point from the right in realtime for each series
    ChartFX2.OpenDataEx COD_VALUES Or COD_ADDPOINTS, 2, 1
        ChartFX2.ValueEx(0, 0) = -50 + Rnd * 100
        ChartFX2.ValueEx(1, 0) = -50 + Rnd * 100
    ChartFX2.CloseData nCOD
    
    ' Next
    nOffset = nOffset + 1
End Sub
Private Sub Timer1_Timer()
    Call AddPoint
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -