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

📄 xchart.ctl

📁 chart图片,统计,网上下来的源代码
💻 CTL
📖 第 1 页 / 共 3 页
字号:
        .BackColor = uInfoBackColor
        .Visible = IIf((uDisplayDescript And uSelectedColumn > -1), True, False)
    End With
    mnuMainSelectionInfo.Checked = uDisplayDescript
    If Not bResize Then ClearLegendItems
    With UserControl
        uRowHeight = ((.ScaleHeight - (uTopMargin + uBottomMargin)) / uRangeY)
        If iCols Then
            uColWidth = ((.ScaleWidth - (uLeftMargin + uRightMargin)) / iCols)
        End If
        .Cls
    
        If iCols Then ReDim uColumns(iCols - 1, 1)
        On Error Resume Next
        .ForeColor = uChartTitleColor
        .CurrentX = xMiddle - (.TextWidth(uChartTitle) / 2)
        .CurrentY = 0
        .FontBold = True
        UserControl.Print uChartTitle
        .FontBold = False
        .ForeColor = uChartSubTitleColor
        .FontSize = .FontSize - 2
        .CurrentX = xMiddle - (.TextWidth(uChartSubTitle) / 2)
        UserControl.Print uChartSubTitle
        .FontSize = .FontSize + 2
        If uAxisYOn Then
            .ForeColor = uYAxisItemsColor
            For X = uMinYValue To uMaxYValue
                x1 = uLeftMargin + (2 * Screen.TwipsPerPixelX)
                x2 = .ScaleWidth - uRightMargin
                y1 = (.ScaleHeight - uBottomMargin)
                If uDataType = DT_NEG Then
                   y1 = y1 + ((Abs(X) - Abs(uMinYValue)) * uRowHeight)
                Else
                    y1 = y1 - ((X - uMinYValue) * uRowHeight)
               End If
                If (X = uMinYValue) Or (X = uMaxYValue) Or ((X Mod uIntersectMajor) = 0) Then
                    If uMajorGridOn Then
                        UserControl.Line (x1, y1)-(x2, y1), uMajorGridColor
                    End If
                    .FontSize = .FontSize - 2
                    .CurrentX = uLeftMargin - .TextWidth(X) - (5 * Screen.TwipsPerPixelX)
                    .CurrentY = y1 - (.TextHeight("0") / 2)
                    UserControl.Print X
                    .FontSize = .FontSize + 2
                ElseIf ((uMaxYValue - X) Mod uIntersectMinor = 0) Then
                    If uMinorGridOn Then
                    End If
                End If
            Next X
        End If
        On Error GoTo 0
        If uContentBorder Then
            UserControl.Line (uLeftMargin, uTopMargin)-(.ScaleWidth - uRightMargin, .ScaleHeight - uBottomMargin), uMajorGridColor, B
        End If
        For X = 0 To cItems.Count - 1
            oChartItem = cItems(X + 1)
            x1 = (X * uColWidth) + uLeftMargin + (2 * Screen.TwipsPerPixelX)    'increment by 2 pixs.
            x2 = x1 + uColWidth - (2 * Screen.TwipsPerPixelX)                   'decrement by 2 pixs.
           If uDataType = DT_POS Then
               sngRowHeight = uRowHeight * (oChartItem.Value - uMinYValue)
               y2 = .ScaleHeight - uBottomMargin
               y1 = y2 - sngRowHeight
           ElseIf uDataType = DT_NEG Then
                sngRowHeight = uRowHeight * (Abs(CDbl(oChartItem.Value)) - Abs(uMaxYValue))
                y1 = uTopMargin
                y2 = y1 + sngRowHeight
            Else
                sngRowHeight = (-CDbl(oChartItem.Value) * uRowHeight)
                y1 = .ScaleHeight - uBottomMargin
                y1 = y1 - uRowHeight * Abs(uMinYValue)
                y2 = y1 + sngRowHeight
            End If
            sngRowHeight = Abs(sngRowHeight)
            uColumns(X, 0) = y1
            uColumns(X, 1) = y2
            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
                    sngColWidth = uColWidth * uBarWidthPercentage / 100
                xTemp = x1 + ((uColWidth - sngColWidth) / 2)
                x2 = x2 - ((uColWidth - sngColWidth) / 2)
                .DrawWidth = uLineWidth
                .FillStyle = uBarFillStyle
                If X = uSelectedColumn And uSelectable Then
                    .FillColor = uSelectedBarColor
                        Call DrawTrapezium(oChartItem.Value, xTemp, x2, y1, y2)
                    .DrawWidth = 1
                    .FillStyle = vbFSTransparent
                Else
                    If (uMeanOn = True) And (X = cItems.Count - 1) Then
                   Else
                        .FillColor = IIf(uColorBars, QBColor(CurrentColor), uBarColor)
                   End If
                    .FillStyle = uBarFillStyle
                    .DrawWidth = uLineWidth
                        Call DrawTrapezium(oChartItem.Value, xTemp, x2, y1, y2)
                    .DrawWidth = 1
                    .FillStyle = vbFSTransparent
                End If
            End If
            If (uChartType And XC_SYMBOL) = XC_SYMBOL Then
                If uDataType = DT_NEG Then
                    yTemp = y2
                ElseIf uDataType = DT_POS Then
                    yTemp = y1
                Else
                    yTemp = IIf((oChartItem.Value > 0), y1, y2)
                End If
                .CurrentX = xTemp
                .CurrentY = yTemp
                .FontSize = .FontSize + 2
                .FontSize = .FontSize - 2
            End If
            If (uChartType And XC_LINE) = XC_LINE Then
                'draw the lines
                If uDataType = DT_NEG Then
                    yTemp = y2
                ElseIf uDataType = DT_POS Then
                    yTemp = y1
                Else
                    yTemp = IIf((oChartItem.Value > 0), y1, y2)
                End If
                xTemp = x1 + (uColWidth / 2)
                If (X > 0) Then
                End If
                xPrev = xTemp
                yPrev = yTemp
            End If
            If uAxisXOn Then
                .ForeColor = uXAxisItemsColor
                .FontSize = .FontSize - 1
                varLabel = Split(oChartItem.XAxisDescription, vbCrLf)
                xTemp = (((x2 - x1) / 2) + x1) / Screen.TwipsPerPixelX
                xTemp = xTemp - (((.TextHeight("A")) / Screen.TwipsPerPixelX) * (UBound(varLabel))) / 2
                For intIdx = UBound(varLabel) To 0 Step -1
                    yTemp = (.ScaleHeight - uBottomMargin + .TextWidth(varLabel(intIdx)) / 2) / Screen.TwipsPerPixelY + 5
                    PrintRotText .hDC, varLabel(intIdx), xTemp, yTemp, 270
                    xTemp = xTemp + .TextHeight("A") / Screen.TwipsPerPixelX
                Next
                xTemp = (((x2 - x1) / 2) + x1) / Screen.TwipsPerPixelX
                yTemp = (.ScaleHeight - uBottomMargin) + Screen.TwipsPerPixelX
                UserControl.Line (xTemp * Screen.TwipsPerPixelX, yTemp)-(xTemp * Screen.TwipsPerPixelX, yTemp + 2 * Screen.TwipsPerPixelX), uMajorGridColor
                .FontSize = .FontSize + 1
            End If
            If uColorBars = True Then
                CurrentColor = CurrentColor + 1
                If CurrentColor >= 15 Then CurrentColor = 0
            End If
        Next X
        If Len(uXAxisLabel) Then
            .FontSize = .FontSize - 1
            .CurrentY = .ScaleHeight - .TextHeight(uXAxisLabel) * 1.5
            .CurrentX = xMiddle - (.TextWidth(uXAxisLabel) / 2)
            .ForeColor = uXAxisLabelColor
            UserControl.Print uXAxisLabel
            .FontSize = .FontSize + 1
        End If
        If Len(uYAxisLabel) > 0 Then
            .FontSize = .FontSize - 1
            .ForeColor = uYAxisLabelColor
            PrintRotText .hDC, uYAxisLabel, .TextHeight(uYAxisLabel) / Screen.TwipsPerPixelX, .ScaleHeight / 2 / Screen.TwipsPerPixelY, 90
            .FontSize = .FontSize + 1
        End If
        If bDisplayLegend = True Then
            If uSelectable And uSelectedColumn > -1 Then
                Dim perScreen As Integer
                Dim scrollValue As Integer
                If (uSelectedColumn + 1) > perScreen Then
                End If
            End If
        End If
    End With
End Sub
Private Sub ClearLegendItems() '6
    Dim X As Integer
    On Error Resume Next    'we are expecting an error for item 1
    If bLegendAdded Then
        bLegendAdded = False
    End If
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag) '4
    On Error Resume Next
    With PropBag
        uTopMargin = .ReadProperty("uTopMargin", 55)
        uBottomMargin = .ReadProperty("uBottomMargin", 55)
        uLeftMargin = .ReadProperty("uLeftMargin", 55)
        uRightMargin = .ReadProperty("uRightMargin", 55)
        uContentBorder = .ReadProperty("uContentBorder", True)
        uSelectable = .ReadProperty("uSelectable", False)
        uHotTracking = .ReadProperty("uHotTracking", False)
        uSelectedColumn = .ReadProperty("uSelectedColumn", -1)
        uChartTitle = .ReadProperty("uChartTitle", UserControl.Name)
        uChartSubTitle = .ReadProperty("uChartSubTitle", uChartSubTitle)
        uAxisYOn = .ReadProperty("uAxisXOn", uAxisXOn)
        uAxisXOn = .ReadProperty("uAxisYOn", uAxisYOn)
        uColorBars = .ReadProperty("uColorBars", False)
        uIntersectMajor = .ReadProperty("uIntersectMajor", 10)
        uIntersectMinor = .ReadProperty("uIntersectMinor", 2)
        uMaxYValue = .ReadProperty("uMaxYValue", 100)
        uDisplayDescript = .ReadProperty("uDisplayDescript", False)
        uXAxisLabel = .ReadProperty("uXAxisLabel", uXAxisLabel)
        uYAxisLabel = .ReadProperty("uYAxisLabel", uYAxisLabel)
        UserControl.BackColor = .ReadProperty("BackColor", vbWhite)
        UserControl.ForeColor = .ReadProperty("ForeColor", vbBlack)
        uMinYValue = .ReadProperty("MinY")
        uBarColor = .ReadProperty("BarColor", vbBlue)
        uSelectedBarColor = .ReadProperty("SelectedBarColor", vbCyan)
        uMajorGridColor = .ReadProperty("MajorGridColor", vbBlack)
        uInfoBackColor = .ReadProperty("InfoBackColor")
        uInfoForeColor = .ReadProperty("InfoForeColor")
        uXAxisLabelColor = .ReadProperty("XAxisLabelColor", vbBlack)
        uYAxisLabelColor = .ReadProperty("YAxisLabelColor", vbBlack)
        uXAxisItemsColor = .ReadProperty("XAxisItemsColor", vbBlack)
        uYAxisItemsColor = .ReadProperty("YAxisItemsColor", vbBlack)
        uChartTitleColor = .ReadProperty("ChartTitleColor", vbBlack)
        uChartSubTitleColor = .ReadProperty("ChartSubTitleColor", vbBlack)
        uChartType = .ReadProperty("ChartType")
        uMenuItems = .ReadProperty("MenuItems")
        uCustomMenuItems = .ReadProperty("CustomMenuItems")
        uInfoItems = .ReadProperty("InfoItems")
        uSaveAsCaption = .ReadProperty("SaveAsCaption")
        uBarWidthPercentage = .ReadProperty("BarWidthPercentage", 100)
          uMinorGridOn = .ReadProperty("MinorGridOn", True)
        uMajorGridOn = .ReadProperty("MajorGridOn", True)
        uLineWidth = .ReadProperty("LineWidth", 1)
        uLineColor = .ReadProperty("LineColor", vbRed)
        uBarFillStyle = .ReadProperty("BarFillStyle", vbFSSolid)
        uLineStyle = .ReadProperty("LineStyle")
      
        uLegendCaption = .ReadProperty("LegendCaption")
        uLegendPrintMode = .ReadProperty("LegendPrintMode", legPrintGraph)
        uOldSelection = -1
        uRightMarginOrg = uRightMargin
    End With
End Sub
Private Sub UserControl_Resize() '2
    bResize = True
    DrawChart
    bResize = False
End Sub
Public Property Get LineColor() As OLE_COLOR
    LineColor = uLineColor
End Property
Public Property Let LineColor(lngVal As OLE_COLOR)
    If lngVal <> uLineColor Then
        uLineColor = lngVal
        DrawChart
        PropertyChanged "LineColor"
    End If
End Property
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    With PropBag
        .WriteProperty "uTopMargin", uTopMargin
        .WriteProperty "uBottomMargin", uBottomMargin
        .WriteProperty "uLeftMargin", uLeftMargin
        .WriteProperty "uRightMargin", uRightMargin
        .WriteProperty "uContentBorder", uContentBorder
        .WriteProperty "uSelectable", uSelectable
        .WriteProperty "uHotTracking", uHotTracking
        .WriteProperty "uSelectedColumn", uSelectedColumn
        .WriteProperty "uChartTitle", uChartTitle
        .WriteProperty "uChartSubTitle", uChartSubTitle
        .WriteProperty "uAxisXOn", uAxisXOn
        .WriteProperty "uAxisYOn", uAxisYOn
        .WriteProperty "uColorBars", uColorBars
        .WriteProperty "uIntersectMajor", uIntersectMajor
        .WriteProperty "uIntersectMinor", uIntersectMinor
        .WriteProperty "uMaxYValue", uMaxYValue
        .WriteProperty "uDisplayDescript", uDisplayDescript
        .WriteProperty "uXAxisLabel", uXAxisLabel
        .WriteProperty "uYAxislabel", uYAxisLabel
        .WriteProperty "BackColor", UserControl.BackColor
        .WriteProperty "ForeColor", UserControl.ForeColor
        .WriteProperty "MinY", uMinYValue
        .WriteProperty "BarColor", uBarColor
        .WriteProperty "SelectedBarColor", uSelectedBarColor
        .WriteProperty "MajorGridColor", uMajorGridColor
        .WriteProperty "InfoBackColor", uInfoBackColor
        .WriteProperty "InfoForeColor", uInfoForeColor
        .WriteProperty "XAxisLabelColor", uXAxisLabelColor
        .WriteProperty "YAxisLabelColor", uYAxisLabelColor
        .WriteProperty "XAxisItemsColor", uXAxisItemsColor
        .WriteProperty "YAxisItemsColor", uYAxisItemsColor
        .WriteProperty "ChartTitleColor", uChartTitleColor
        .WriteProperty "ChartSubTitleColor", uChartSubTitleColor
        .WriteProperty "ChartType", uChartType
        .WriteProperty "MenuItems", uMenuItems
        .WriteProperty "CustomMenuItems", uCustomMenuItems
        .WriteProperty "InfoItems", uInfoItems
        .WriteProperty "SaveAsCaption", uSaveAsCaption
        .WriteProperty "AutoRedraw", uAutoRedraw
        .WriteProperty "BarWidthPercentage", uBarWidthPercentage
        .WriteProperty "BarPicture", uBarPicture, Nothing
        .WriteProperty "Picture", uPicture, Nothing
        .WriteProperty "MinorGridOn", uMinorGridOn
        .WriteProperty "MajorGridOn", uMajorGridOn
        .WriteProperty "LineWidth", uLineWidth
        .WriteProperty "LineColor", uLineColor
        .WriteProperty "BarFillStyle", uBarFillStyle
        .WriteProperty "LineStyle", uLineStyle
        .WriteProperty "MeanColor", uMeanColor
        .WriteProperty "MeanCaption", uMeanCaption
        .WriteProperty "DataFormat", uDataFormat
        .WriteProperty "PrinterFit", uPrinterFit
        .WriteProperty "PrinterOrientation", uPrinterOrientation
        .WriteProperty "LegendCaption", uLegendCaption
        .WriteProperty "LegendPrintMode", uLegendPrintMode
    End With
End Sub


⌨️ 快捷键说明

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