|
本帖最后由 delete_007 于 2014-7-4 15:22 编辑
20140704-多系列散点图(delete_007).rar
(35.97 KB, 下载次数: 71)
在原过程Data_Generation End Sub 前添加一句代码Call InsertChart即可完成动态作图。
插入图表代码如下:- Public Sub InsertChart()
- Dim arr, i%, j%, d, PiHao, X, Y
- On Error Resume Next
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
-
- arr = Sheet1.Range("A1").CurrentRegion
- For i = 2 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
- d(arr(i, 1))(arr(i, 2)) = arr(i, 3)
- Next
- Sheet1.ChartObjects.Delete
- Charts.Add
- ActiveChart.SeriesCollection(1).Delete
- ActiveChart.Location where:=xlLocationAsObject, Name:="Sheet1"
- PiHao = d.keys
- For i = 0 To UBound(PiHao)
- X = d(PiHao(i)).keys
- Y = d(PiHao(i)).items
- ActiveChart.SeriesCollection.NewSeries
- With ActiveChart.SeriesCollection(i + 1)
- .Name = PiHao(i)
- .XValues = X
- .Values = Y
- End With
- Next
- With ActiveChart
- .ChartType = xlXYScatter
- .Axes(xlValue).MaximumScale = 1
- .Axes(xlValue).MajorUnit = 0.2
- .Axes(xlCategory).MaximumScale = 1
- .Axes(xlCategory).MajorUnit = 0.2
- .Axes(xlCategory).HasMajorGridlines = True
- .Axes(xlValue).MajorTickMark = xlNone
- .Axes(xlCategory).MajorTickMark = xlNone
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|