问题
I dont get the line curve for the data given below however I see the data being plotted but not visible as a smooth line. Please help.
Column B Column C
x y
0.00 0.00
-0.10 0.29
-0.35 0.48
-0.65 0.48
-0.90 0.29
-1.00 0.00
Set ch = ActiveSheet.ChartObjects("Chart 1")
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ch.Activate
p=1
For i = 1 To 6
ser_count = ActiveChart.SeriesCollection.Count
p = ser_count + 1
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(p).XValues = ActiveSheet.Range("b" & i)
ActiveChart.SeriesCollection(p).Values = ActiveSheet.Range("c" & i)
ActiveChart.SeriesCollection(p).Format.Line.Visible = msoTrue
ActiveChart.SeriesCollection(p).Format.Line.ForeColor.RGB = RGB(255, 0, 0)
ActiveChart.SeriesCollection(p).Format.Line.Weight = 1
ActiveChart.SeriesCollection(p).Format.Line.DashStyle = msoLineSolid
Next i
回答1:
Try,
Dim objCh As ChartObject
Dim ch As Chart
Dim Srs As Series
Set objCh = ActiveSheet.ChartObjects("Chart 1")
'Set objCh = ActiveSheet.ChartObjects(1)
Set ch = objCh.Chart
With ch
.ChartType = xlXYScatterSmoothNoMarkers
Set Srs = .SeriesCollection.NewSeries
With Srs
.XValues = ActiveSheet.Range("b1").Resize(6)
.Values = ActiveSheet.Range("c1").Resize(6)
.Format.Line.Visible = msoTrue
.Format.Line.ForeColor.RGB = RGB(255, 0, 0)
.Format.Line.Weight = 1
.Format.Line.DashStyle = msoLineSolid
End With
End With
来源:https://stackoverflow.com/questions/64167500/vba-chart-data-points-not-visible-in-graph