作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经使用 Chart 对象和 SeriesCollection.NewSeries 绘制了一些图
部分代码是这样的
Private Function AddSeriesAndFormats(PPSChart As Chart, shInfo As Worksheet, tests() As PPS_Test, RowCount As Integer, col As Integer, smoothLine As Boolean, lineStyle As String, transparency As Integer, lineWidth As Single, ByRef position As Integer) As Series
Dim mySeries As Series
Set mySeries = PPSChart.SeriesCollection.NewSeries
With mySeries
.Name = tests(0).GetString()
.XValues = "='" & shInfo.Name & "'!R" & RowCount - UBound(tests) - 1 & "C" & CInt(4 * (col + 1) - 2) & ":R" & RowCount - 1 & "C" & CInt(4 * (col + 1) - 2)
.Values = "='" & shInfo.Name & "'!R" & RowCount - UBound(tests) - 1 & "C" & CInt(4 * (col + 1) - 1) & ":R" & RowCount - 1 & "C" & CInt(4 * (col + 1) - 1)
.Smooth = smoothLine
.Format.line.Weight = lineWidth
.Format.line.DashStyle = GetLineStyle(lineStyle)
.Format.line.transparency = CSng(transparency / 100)
.MarkerStyle = SetMarkerStyle(position)
.MarkerSize = 9
.MarkerForegroundColorIndex = xlColorIndexNone
End With
Set AddSeriesAndFormats = mySeries
End Function
Private Function AddChartAndFormatting(chartName As String, chartTitle As String, integralBuffer As Integer, algoPropertyName As String) As Chart
Dim PPSChart As Chart, mySeries As Series
Set PPSChart = Charts.Add
With PPSChart
.Name = chartName
.HasTitle = True
.chartTitle.Characters.Text = chartTitle
.ChartType = xlXYScatterLines
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).HasTitle = True
If algoPropertyName <> "" Then 'case for Generic PPS plots
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = algoPropertyName
Else
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "PL/PR max(avg_" & integralBuffer & "ms) [mbar]" 'case for the bumper obsolate algorithm
End If
.Axes(xlCategory, xlPrimary).AxisTitle.Text = "Bumper Position [mm]"
End With
' delete random series that might be generated
For Each mySeries In PPSChart.SeriesCollection
mySeries.Delete
Next mySeries
Set AddChartAndFormatting = PPSChart
End Function
最佳答案
嗨,你可以尝试这样的事情:
Dim dMinValue as Double, dMaxValue as Double
With PPSChart
dMinValue = application.WorksheetFunction.Min("='" & _
shInfo.Name & "'!R" & RowCount - UBound(tests) - 1 _
& "C" & CInt(4 * (col + 1) - 2) & ":R" & RowCount - 1 _
& "C" & CInt(4 * (col + 1) - 2))
dMaxValue = application.WorksheetFunction.Max("='" & _
shInfo.Name & "'!R" & RowCount - UBound(tests) - 1 _
& "C" & CInt(4 * (col + 1) - 2) & ":R" & RowCount - 1 _
& "C" & CInt(4 * (col + 1) - 2))
....
.Axes(xlValue).MinimumScale = dMinValue
.Axes(xlValue).MaximumScale = dMaxValue
....
End With
Dim rSerie as Range
Set rSerie = Range("='" & _
shInfo.Name & "'!R" & RowCount - UBound(tests) - 1 _
& "C" & CInt(4 * (col + 1) - 2) & ":R" & RowCount - 1 _
& "C" & CInt(4 * (col + 1) - 2)))
With ....
dMinValue = Application.WorksheetFunction.Min(rSerie)
....
End with
关于vba - VBA Excel系列中的Y轴对称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40765466/
我是一名优秀的程序员,十分优秀!