Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

XYSCATTERPOLTnoMarker

newtovbnewtovb Member Posts: 1
The below is what I have done so far. I want to

- change the line style, color and weight on SeriesCollection(1)
- the grid lines to appera ever hour (5, 6, 7, 8....)


'Second Graph
Dim objChart As Object 'Object reference to Excel Chart
Dim objXL As Object 'Object reference for Excel App
Dim objSheet As Object 'Object reference to Excel Worksheet
Dim rct As Integer
Dim statime As Date
statime = frmMain.Text1


' Embed a new Excel Chart into the OLE control:
OLE1.CreateEmbed "", "Excel.Chart.5"

'BEGIN FIX FOR DIFFERING OBJECT MODELS BETWEEN VERSIONS 7 & 8
' Set object references to Chart, Worksheet, and Application objects:
If Left(OLE1.object.Application.Version, 5) = "7" Then
'Excel 95's object model is different from Excel 97's
Set objChart = OLE1.object
'Chart1 default chart
Else 'assume all future excel object models are going to be the same
Set objChart = OLE1.object.ActiveChart
'ole1.object is in Excel 97 the workbook
End If
Set objSheet = objChart.Parent.Worksheets(1)
' Sheet1 default data
Set objXL = objChart.Application

' Create Series Labels on Worksheet:
objSheet.Cells(1, 1).Value = "Time"
objSheet.Cells(1, 2).Value = "% Power"
objSheet.Cells(1, 3).Value = "% Xenon"

For rct = 1 To numout
objSheet.Cells(rct + 1, 1).Value = FormatDateTime(outdata(rct - 1).timdat / 86400# + statime)
Next rct

For rct = 1 To numout
objSheet.Cells(rct + 1, 2).Value = Format(outdata(rct - 1).power * 100# / ratpow, "#0.0")
Next rct

For rct = 1 To numout
objSheet.Cells(rct + 1, 3).Value = Format(outdata(rct - 1).xeper, "#0.0")
Next rct

OLE1.object.ActiveChart.ChartType = 73
OLE1.object.ActiveChart.PlotBy = xlColumns
OLE1.object.ActiveChart.SetSourceData Source:=objSheet.Range(objSheet.Cells(1, 1), objSheet.Cells(rct, 3))
OLE1.object.ActiveChart.SeriesCollection(1).Values = objSheet.Range(objSheet.Cells(2, 2), objSheet.Cells(rct, 2))
OLE1.object.ActiveChart.SeriesCollection(2).Values = objSheet.Range(objSheet.Cells(2, 3), objSheet.Cells(rct, 3))
OLE1.object.ActiveChart.SeriesCollection(2).Broder.LineStyle = xlDash






With objChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
.Axes(xlCategory, xlPrimary).AxisTitle.Font.Size = 10
.Axes(xlValue, xlPrimary).HasTitle = False

If Y1min < Y2min Then
.Axes(xlValue).MinimumScale = CDbl(CLng(Y1min))
Else
.Axes(xlValue).MinimumScale = CDbl(CLng(Y2min))
End If

If Y1max < Y2max Then
.Axes(xlValue).MaximumScale = CDbl(Format(Y2max + 0.5, "###"))
Else
.Axes(xlValue).MaximumScale = CDbl(Format(Y1max + 0.5, "###"))
End If
.Axes(xlCategory).MinimumScale = statime

.Axes(xlCategory).MaximumScale = FormatDateTime(outdata(numout - 1).timdat / 86400# + statime)
.Axes(xlValue).TickLabels.Font.Size = 8
.Axes(xlValue).TickLabels.Orientation = xlHorizontal
.Axes(xlCategory).TickLabels.Font.Size = 10
.PlotArea.Interior.ColorIndex = xlNone
.PlotArea.Height = 4454
.PlotArea.Top = 0
.PlotArea.Width = 9000
.ChartArea.Font.Name = "Arial"
.ChartArea.Font.FontStyle = "Regular"
.ChartArea.Font.Size = 9
.Axes(xlCategory).MajorUnit = 0.208333333333333
.Axes(xlCategory).MinorUnit = 0.002

End With

With objChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False

End With

With objChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
objChart.HasLegend = True
objChart.Legend.Position = xlTop
objChart.Legend.Font.Size = 9


With objChart.PlotArea.Border
.ColorIndex = 0
.Weight = xlThin
.LineStyle = xlContinuous
End With

Set objXL = Nothing
Set objChart = Nothing
Set objSheet = Nothing

End Sub
Sign In or Register to comment.