📄 xchart.ctl
字号:
UserControl.ScaleMode = intScaleMode
Erase uaPts
End Sub
Public Property Let ChartType(intVal As ChartTypeConstants)
Attribute ChartType.VB_Description = "Determines the type of chart to be displayed."
If intVal <> uChartType Then
uChartType = intVal
DrawChart
PropertyChanged "ChartType"
End If
End Property
Private Sub FixData() '2222
If uMinYValue < 0 And uMaxYValue < 0 Then
uDataType = DT_NEG
uRangeY = (Abs(uMinYValue) - Abs(uMaxYValue))
ElseIf uMinYValue >= 0 And uMaxYValue >= 0 Then
uDataType = DT_POS
uRangeY = (Abs(uMaxYValue) - Abs(uMinYValue))
Else
uDataType = DT_BOTH
uRangeY = (Abs(uMaxYValue) + Abs(uMinYValue))
End If
If uRangeY = 0 Then uRangeY = 1
If uIntersectMajor = 0 Then uIntersectMajor = uRangeY / 10
If uIntersectMinor = 0 Then uIntersectMinor = uIntersectMajor / 5
End Sub
Private Sub FixCustomMenu() '55555555555555
On Error Resume Next
Dim ctl As Control
Dim intIdx As Integer
Dim stgItem As String
Dim varItems As Variant
Dim intItemCnt As Integer
For Each ctl In mnuMainCustomItems
ctl.Visible = False
Next
If Trim(uCustomMenuItems) <> Empty Then
varItems = Split(uCustomMenuItems, "|")
intItemCnt = 0
For intIdx = 0 To UBound(varItems)
stgItem = Trim(CStr(varItems(intIdx)))
If stgItem <> Empty Then
If intItemCnt > 7 Then Exit For
mnuMainCustomItems(intItemCnt).Caption = stgItem
mnuMainCustomItems(intItemCnt).Visible = True
intItemCnt = intItemCnt + 1
End If
Next
End If
mnuMainCustomItemsSeparator.Visible = (mnuMainCustomItems(0).Visible)
End Sub
Private Function InColumn(X As Single, Y As Single) As Integer '655525
Dim sngY As Single
Dim sngY1 As Single
Dim sngY2 As Single
Dim intCol As Integer
Dim intSelectedCol As Integer
intSelectedCol = -1
If (uChartType And XC_BAR) = XC_BAR _
Or (uChartType And XC_OVAL) = XC_OVAL _
Or (uChartType And XC_RHOMBUS) = XC_RHOMBUS _
Or (uChartType And XC_TRAPEZIUM) = XC_TRAPEZIUM _
Or (uChartType And XC_TRIANGLE) = XC_TRIANGLE Then
If (Y <= UserControl.ScaleHeight - uBottomMargin) And (Y >= uTopMargin) _
And (uSelectable = True) Then
intCol = (X - uLeftMargin) \ (uColWidth)
sngY1 = uColumns(intCol, 0)
sngY2 = uColumns(intCol, 1)
If sngY1 > sngY2 Then
sngY = sngY1
sngY1 = sngY2
sngY2 = sngY
End If
If (Y >= sngY1 And Y <= sngY2) Then
intSelectedCol = intCol
End If
End If
End If
InColumn = intSelectedCol
End Function
Public Property Let HotTracking(blnVal As Boolean)
If blnVal <> uHotTracking Then
uHotTracking = blnVal
DrawChart
PropertyChanged "HotTracking"
End If
End Property
Public Property Get HotTracking() As Boolean
HotTracking = uHotTracking
End Property
Public Property Let CustomMenuItems(stgVal As String) '55555
uCustomMenuItems = stgVal
FixCustomMenu
PropertyChanged "CustomMenuItems"
End Property
Public Property Let MaxY(dblMax As Double)
If dblMax > uMinYValue Then
uMaxYValue = dblMax
DrawChart
PropertyChanged "MaxY"
End If
End Property
Public Property Let MinY(dblMin As Double)
If dblMin < uMaxYValue Then
uMinYValue = dblMin
DrawChart
PropertyChanged "MinY"
End If
End Property
Public Property Get MinY() As Double '535555555555
Attribute MinY.VB_Description = "Returns/sets the minimum Y value."
MinY = uMinYValue
End Property
Public Property Get MaxY() As Double '5444444444
Attribute MaxY.VB_Description = "Returns/sets the maximum Y value."
MaxY = uMaxYValue
End Property
Public Property Let AxisLabelXColor(lngVal As OLE_COLOR)
Attribute AxisLabelXColor.VB_Description = "Returns/sets the color used to display the X-axis label."
If lngVal <> uXAxisLabelColor Then
uXAxisLabelColor = lngVal
DrawChart
PropertyChanged "AxisLabelXColor"
End If
End Property
Public Property Let AxisLabelYColor(lngVal As OLE_COLOR)
Attribute AxisLabelYColor.VB_Description = "Returns/sets the color used to display the Y-axis label."
If lngVal <> uYAxisLabelColor Then
uYAxisLabelColor = lngVal
DrawChart
PropertyChanged "AxisLabelYColor"
End If
End Property
Public Property Let AxisItemsYColor(lngVal As OLE_COLOR)
Attribute AxisItemsYColor.VB_Description = "Returns/sets the color used to display the Y-axis items."
If lngVal <> uYAxisItemsColor Then
uYAxisItemsColor = lngVal
DrawChart
PropertyChanged "AxisItemsYColor"
End If
End Property
Public Property Let AxisItemsXColor(lngVal As OLE_COLOR)
Attribute AxisItemsXColor.VB_Description = "Returns/sets the color used to display the X-axis items."
If lngVal <> uXAxisItemsColor Then
uXAxisItemsColor = lngVal
DrawChart
PropertyChanged "AxisItemsXColor"
End If
End Property
Public Property Get AxisItemsYColor() As OLE_COLOR
AxisItemsYColor = uYAxisItemsColor
End Property
Public Property Get AxisItemsXColor() As OLE_COLOR
AxisItemsXColor = uXAxisItemsColor
End Property
Public Property Get AxisLabelYColor() As OLE_COLOR
AxisLabelYColor = uYAxisLabelColor
End Property
Public Property Get AxisLabelXColor() As OLE_COLOR
AxisLabelXColor = uXAxisLabelColor
End Property
Public Property Let BackColor(lngVal As OLE_COLOR)
Attribute BackColor.VB_Description = "Returns/sets the color of the chart background."
If lngVal <> UserControl.BackColor Then
UserControl.BackColor = lngVal
DrawChart
PropertyChanged "BackColor"
End If
End Property
Public Property Get BackColor() As OLE_COLOR
BackColor = UserControl.BackColor
End Property
Public Property Get MajorGridColor() As OLE_COLOR
Attribute MajorGridColor.VB_Description = "Returns/sets the color of the major grid."
MajorGridColor = uMajorGridColor
End Property
Public Property Get ChartTitleColor() As OLE_COLOR
Attribute ChartTitleColor.VB_Description = "Returns/sets the color used to display the chart title."
ChartTitleColor = uChartTitleColor
End Property
Public Property Let ChartTitleColor(lngVal As OLE_COLOR)
If lngVal <> uChartTitleColor Then
uChartTitleColor = lngVal
DrawChart
PropertyChanged "ChartTitleColor"
End If
End Property
Public Property Let ChartSubTitleColor(lngVal As OLE_COLOR)
If lngVal <> uChartSubTitleColor Then
uChartSubTitleColor = lngVal
DrawChart
PropertyChanged "ChartSubTitleColor"
End If
End Property
Public Property Get ChartSubTitleColor() As OLE_COLOR
ChartSubTitleColor = uChartSubTitleColor
End Property
Public Property Let MajorGridColor(lngVal As OLE_COLOR)
If lngVal <> uMajorGridColor Then
uMajorGridColor = lngVal
DrawChart
PropertyChanged "MajorGridColor"
End If
End Property
Public Property Get BarColor() As OLE_COLOR
Attribute BarColor.VB_Description = "Returns/sets the color used to display the bar."
BarColor = uBarColor
End Property
Public Property Let InfoBackColor(lngVal As OLE_COLOR)
Attribute InfoBackColor.VB_Description = "Returns/sets the selection information background color."
If lngVal <> uInfoBackColor Then
uInfoBackColor = lngVal
DrawChart
PropertyChanged "InfoBackColor"
End If
End Property
Public Property Let InfoForeColor(lngVal As OLE_COLOR)
Attribute InfoForeColor.VB_Description = "Returns/sets the selection information foreground color."
If lngVal <> uInfoForeColor Then
uInfoForeColor = lngVal
DrawChart
PropertyChanged "InfoForeColor"
End If
End Property
Public Property Get InfoBackColor() As OLE_COLOR
InfoBackColor = uInfoBackColor
End Property
Public Property Get InfoForeColor() As OLE_COLOR
InfoForeColor = uInfoForeColor
End Property
Public Property Get SelectedBarColor() As OLE_COLOR
Attribute SelectedBarColor.VB_Description = "Returns/sets the color used to display the selected bar."
SelectedBarColor = uSelectedBarColor
End Property
Public Property Let SelectedBarColor(lngVal As OLE_COLOR)
If lngVal <> uSelectedBarColor Then
uSelectedBarColor = lngVal
PropertyChanged "SelectedBarColor"
End If
End Property
Public Property Let BarColor(lngVal As OLE_COLOR)
If lngVal <> uBarColor Then
uBarColor = lngVal
DrawChart
PropertyChanged "BarColor"
End If
End Property
Private Sub UserControl_Initialize() '1
Set cItems = New Collection
End Sub
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '56555565
Dim oItem As ChartItem
Dim intSelectedCol As Integer
If Button = vbLeftButton Then
On Error GoTo TrackExit
intSelectedCol = InColumn(X, Y)
If intSelectedCol >= 0 Then
If Not bProcessingOver Then
bProcessingOver = True
uSelectedColumn = intSelectedCol
If Not uSelectedColumn = uOldSelection Then
DrawChart
uOldSelection = uSelectedColumn
If (uMeanOn = True) And (uSelectedColumn = cItems.Count - 1) Then
Else
oItem = cItems(uSelectedColumn + 1)
RaiseEvent ItemClick(oItem)
End If
End If
bProcessingOver = False
End If
End If
ElseIf Button = vbRightButton Then
End If
RaiseEvent MouseDown(Button, Shift, X, Y)
TrackExit:
Exit Sub
End Sub
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '3533232
If (uHotTracking = True) Or (Button = vbLeftButton) Then
Call UserControl_MouseDown(vbLeftButton, Shift, X, Y)
End If
End Sub
Public Sub Clear() '5
Set cItems = Nothing
Set cItems = New Collection
ClearLegendItems
uSelectedColumn = -1
DrawChart
End Sub
Public Sub DrawChart() '3
On Error Resume Next
Dim x1 As Single
Dim x2 As Single
Dim y1 As Single
Dim y2 As Single
Dim xTemp As Single
Dim yTemp As Single
Dim xPrev As Single
Dim yPrev As Single
Dim sngRowHeight As Single
Dim CurrentColor As Integer
Dim iCols As Integer
Dim X As Integer
Dim oChartItem As ChartItem
Dim sngColWidth As Single
Dim xMiddle As Single
Dim varLabel As Variant
Dim intIdx As Integer
' If uAutoRedraw = False Then Exit Sub
FixData
iCols = cItems.Count
With lblInfo
.ForeColor = uInfoForeColor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -