📄 frmtest.frm
字号:
Height = 255
Index = 7
Left = 60
TabIndex = 9
Top = 7020
Width = 1845
End
Begin VB.Label Label1
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "Y 轴上字体色"
Height = 255
Index = 6
Left = 60
TabIndex = 8
Top = 6720
Width = 1845
End
Begin VB.Label Label1
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "Y 轴左字体色"
Height = 255
Index = 5
Left = 60
TabIndex = 7
Top = 6420
Width = 1845
End
Begin VB.Label Label1
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "X 轴上字体色"
Height = 255
Index = 4
Left = 60
TabIndex = 6
Top = 6120
Width = 1845
End
Begin VB.Label Label1
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "X 轴下字体色"
Height = 255
Index = 3
Left = 60
TabIndex = 5
Top = 5820
Width = 1845
End
Begin VB.Label Label1
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "字体色(顶下)"
Height = 255
Index = 2
Left = 60
TabIndex = 4
Top = 5520
Width = 1845
End
Begin VB.Label Label1
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "字体色(顶上)"
Height = 255
Index = 1
Left = 60
TabIndex = 3
Top = 5220
Width = 1845
End
Begin VB.Label Label1
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "背景色"
Height = 255
Index = 0
Left = 60
TabIndex = 1
Top = 4920
Width = 1845
End
End
Attribute VB_Name = "frmTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub PrepareData()
Dim X As Integer
Dim intSign As Integer
Dim oChartItem As ChartItem
Dim varMonths As Variant
Dim varMonthsExt As Variant
varMonths = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
varMonthsExt = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
Randomize
With XChart1
' .AutoRedraw = True
.Clear
.CustomMenuItems = "&Hello|&World|Print legend text"
For X = 1 To 12
If .MinY < 0 And .MaxY >= 0 Then
intSign = CInt(Rnd * 1)
If intSign = 0 Then
oChartItem.Value = CInt(Rnd * .MaxY)
Else
oChartItem.Value = -CInt(Rnd * Abs(.MinY))
End If
ElseIf .MinY >= 0 And .MaxY >= 0 Then
oChartItem.Value = .MinY + CInt(Rnd * (.MaxY - .MinY))
ElseIf .MinY < 0 And .MaxY < 0 Then
oChartItem.Value = .MaxY - CInt(Rnd * (Abs(.MinY) - Abs(.MaxY)))
End If
oChartItem.ItemID = X
oChartItem.XAxisDescription = "Month" & vbCrLf & varMonths(X - 1)
oChartItem.SelectedDescription = varMonthsExt(X - 1)
oChartItem.LegendDescription = "Month " & varMonthsExt(X - 1)
.AddItem oChartItem
Next X
End With
End Sub
Private Sub RefreshData()
Dim intIdx As Integer
With XChart1
Label1(0).BackColor = .BackColor '背景色
Label1(1).BackColor = .ChartTitleColor '字体色(顶上)
Label1(2).BackColor = .ChartSubTitleColor '字体色(顶下)
Label1(3).BackColor = .AxisLabelXColor ''X 轴下字体色
Label1(4).BackColor = .AxisItemsXColor 'X 轴上字体色
Label1(5).BackColor = .AxisLabelYColor 'Y 轴左字体色
Label1(6).BackColor = .AxisItemsYColor 'Y 轴上字体色
Label1(7).BackColor = .SelectedBarColor '内背景色
Label1(8).BackColor = .BarColor '内前景色
Label1(11).BackColor = .InfoForeColor '对话框字体色
Label1(12).BackColor = .InfoBackColor '对话框背景色
Label1(14).BackColor = .MajorGridColor '网格线
Label1(15).BackColor = .LineColor '线颜色
Check1(0).Value = IIf((.HotTracking = True), vbChecked, vbUnchecked) '出现对话框
txtMin.Text = .MinY 'y轴最小值
txtMax.Text = .MaxY 'y轴最大值
' txtBarPerc.Text = CStr(.BarWidthPercentage)
' txtLineWidth.Text = CStr(.LineWidth)
End With
End Sub
Private Sub Command1_Click()
With XChart1
' .AutoRedraw = False
.BackColor = Label1(0).BackColor
.ChartTitleColor = Label1(1).BackColor
.ChartSubTitleColor = Label1(2).BackColor
.AxisLabelXColor = Label1(3).BackColor
.AxisItemsXColor = Label1(4).BackColor
.AxisLabelYColor = Label1(5).BackColor
.AxisItemsYColor = Label1(6).BackColor
.SelectedBarColor = Label1(7).BackColor
.BarColor = Label1(8).BackColor
.InfoForeColor = Label1(11).BackColor
.InfoBackColor = Label1(12).BackColor
.MajorGridColor = Label1(14).BackColor
.LineColor = Label1(15).BackColor
' .MenuType = xcPopUpMenu
' .MenuType = xcButtonMenu
.HotTracking = IIf((Check1(0).Value = vbChecked), True, False)
' .MeanOn = IIf((Check1(6).Value = vbChecked), True, False)
' .LineWidth = CInt(txtLineWidth.Text)
' .BarWidthPercentage = CInt(txtBarPerc.Text)
.MinY = CDbl(txtMin.Text)
.MaxY = CDbl(txtMax.Text)
PrepareData
.ChartType = 68
' .AutoRedraw = True
End With
RefreshData
End Sub
Private Sub Label1_Click(Index As Integer)
dlgColor.Color = Label1(Index).BackColor
dlgColor.ShowColor
If dlgColor.Color <> Label1(Index).BackColor Then
Label1(Index).BackColor = dlgColor.Color
End If
End Sub
Private Sub Form_Load()
PrepareData
RefreshData
End Sub
Private Sub Form_Resize()
' grd.Width = Me.ScaleWidth
' XChart1.Width = Me.ScaleWidth
' grd.ColWidth(0) = 960
' grd.ColWidth(1) = Me.ScaleWidth - 960 - 2025
' grd.ColWidth(2) = 2025
End Sub
Private Sub grd_Click()
DoEvents
XChart1.SelectedColumn = grd.Row - 1
End Sub
Private Sub XChart1_MenuItemClick(intMenuItemIndex As Integer, stgMenuItemCaption As String)
MsgBox "You clicked " & intMenuItemIndex & ":" & stgMenuItemCaption, _
vbOKOnly, "CustomMenuItem"
If intMenuItemIndex = 2 Then
XChart1.PrintLegend
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -