回复 20楼 yuma
应该比较麻烦
以下是引用kings12333在2023-2-13 18:54:27的发言:
如果左,右两边的刻度不一样,该如何绘制两组数据(即一组数据参考左边的刻度,一组参考右边的刻度)
如果左,右两边的刻度不一样,该如何绘制两组数据(即一组数据参考左边的刻度,一组参考右边的刻度)
双轴双柱图,EXCEL和PowerPoint的图表是支持的
Option Explicit Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Declare Function SetTextAlign Lib "gdi32" (ByVal hDc As Long, ByVal wFlags As Long) As Long Private Declare Function GetTextMetricsA Lib "gdi32" (ByVal hDc As Long, lpMetrics As Any) As Long Private Type POLYTEXT X As Long Y As Long cCh As Long lpStr As Long uiFlags As Long Rcl(3) As Long pDx As Long End Type Private Declare Function PolyTextOutW Lib "gdi32" (ByVal hDc As Long, pPTxt As POLYTEXT, ByVal cStrings As Long) As Long Private Sub Command1_Click() Call strVertical(10, 0, Me.hDc, "VB竖排文字") End Sub Private Sub strVertical(ByVal X As Long, ByVal Y As Long, ByVal hDc As Long, ByVal Text As String) Dim sLen As Long, P As Long, teY As Long, oldAlign As Long, tmHeight As Long, tmExternalLeading As Long Dim iPT() As POLYTEXT Dim iStr() As String Dim lpMetrics() As Byte oldAlign = SetTextAlign(hDc, 6) ReDim lpMetrics(52) As Byte Call GetTextMetricsA(hDc, lpMetrics(0)) Call CopyMemory(tmHeight, lpMetrics(0), 4) Call CopyMemory(tmExternalLeading, lpMetrics(16), 4) sLen = Len(Text) - 1 ReDim iPT(sLen) As POLYTEXT ReDim iStr(sLen) As String For P = 0 To sLen iStr(P) = Mid$(Text, P + 1, 1) With iPT(P) .X = X .Y = Y + teY .cCh = 1 .lpStr = StrPtr(iStr(P)) End With teY = teY + tmHeight + tmExternalLeading Next Call PolyTextOutW(hDc, iPT(0), sLen + 1) Call SetTextAlign(hDc, oldAlign) Erase lpMetrics(), iPT(), iStr() End Sub
Private Sub Form_Load() Randomize Timer Dim i As Integer, jls As Integer Dim Values(1 To 15, 1 To 3) For i = 1 To 15 Values(i, 1) = "T" & Format(i, "00") Next i For i = 1 To 15 Values(i, 3) = Rnd * 100 Next i MSChart1.chartType = VtChChartType2dCombination MSChart1.Plot.SeriesCollection.Item(1).SeriesType = VtChSeriesType2dLine MSChart1.Plot.SeriesCollection.Item(2).SeriesType = VtChSeriesType2dBar MSChart1.ChartData = Values End Sub