AW: UF-ChartSpace & Kerzenchart
19.03.2007 21:20:00
ingUR
Hallo,
nachdem Jan darauf verweist, dass die erste Arbeitsmappe, die ich hochgeladen habe, "nichts bringt" um als Vorlage zur Lösungsfindung dienen zu könne (Zitat Jan: «sorry, die Mappe bringt nichts , da ich alles auf Chartspace 11 umstricken müßte.»), starte ich einen zweiten Versuch meine Frage so darzustellen, das die Problematik nachvollzogen werden kann und ggf. Löungsansätze angegeben werden.
Hier also die neue Mappe: https://www.herber.de/bbs/user/41192.xls
Option Explicit
Private Sub UserForm_Initialize()
BuiltUFDiagramm_A 'page1
BuiltUFDiagramm_B 'page2
BindToSpreadsheet 'page3
End Sub
Private Sub BuiltUFDiagramm_A()
Dim chConstants
Dim dataX(), dataYO(), dataYH(), dataYL(), dataYC()
Dim dataYOHLC()
Dim ws As Worksheet
Dim maxr As Long
Dim r As Long, c As Integer
Dim rA As Long, cA As Integer
Dim chtChart1, asSeriesNames(3)
With Sheets("Tabelle1")
maxr = .Cells(.Rows.Count, 2).End(xlUp).Row
ReDim dataX(maxr - 2), dataYO(maxr - 2), dataYH(maxr - 2), dataYL(maxr - 2), dataYC(maxr - 2)
ReDim dataYOHLC(maxr - 2, 3)
For c = 2 To 5
cA = c - 2
For r = 2 To maxr
dataYOHLC(r - 2, cA) = .Cells(r, c)
Next r
Next c
asSeriesNames(0) = .Range("B1")
asSeriesNames(1) = .Range("C1")
asSeriesNames(2) = .Range("D1")
asSeriesNames(3) = .Range("E1")
For r = 2 To maxr
rA = r - 2
dataYO(rA) = .Cells(r, 2)
dataYH(rA) = .Cells(r, 3)
dataYL(rA) = .Cells(r, 4)
dataYC(rA) = .Cells(r, 5)
dataX(rA) = .Cells(r, 1)
Next r
End With
Set chtChart1 = ChartSpace1.Charts.Add
Set chConstants = ChartSpace1.Constants
With chtChart1
.HasTitle = True
.Title.Caption = "DAX-Index von WorkSheet-Tabelle1"
.Type = chConstants.chChartTypeLine
.SetData chConstants.chDimSeriesNames, chConstants.chDataLiteral, asSeriesNames
.SetData chConstants.chDimCategories, chConstants.chDataLiteral, dataX
.SeriesCollection(0).SetData chConstants.chDimValues, chConstants.chDataLiteral, dataYO
.SeriesCollection(1).SetData chConstants.chDimValues, chConstants.chDataLiteral, dataYH
.SeriesCollection(2).SetData chConstants.chDimValues, chConstants.chDataLiteral, dataYL
.SeriesCollection(3).SetData chConstants.chDimValues, chConstants.chDataLiteral, dataYC
' Problembeschreibung:
' mit den Anweisungen bisher wurden die vier Datenreihen (O H L C)
' als Linienschart im ChartSpace1 gezeichnet
' soll nun die Charttypenimwandlung mit nachfolgender Zeile in ein CharttypeStockOHLC
' gewandelt werden, verschwinden die Linien
'.Type = chConstants.chChartTypeStockOHLC
End With
Set chtChart1 = Nothing
Set chConstants = Nothing
End Sub
Entscheidend ist jedesmal die hier noch als Kommentar gekennzeichnete Zeile '.Type = chConstants.chChartTypeStockOHLC
Werden die Liniencharts noch wie gewünscht dargestellt werden, werden mit dem Änderung auf den StockOHLC-ChartType (Auskommentierung aufgehoben) die Kerzenen nicht dargestellt. Was habe ich nicht verstanden?
Gruß,
Uwe