Private Function GetMaxSeries(MaxZSeries As Integer, Count As Integer) As Integer
If MaxZSeries <> 0 Then
If Count <= MaxZSeries Then
Result = Count
Else
Result = MaxZSeries
End If
Else
Result = Count
End If
GetMaxSeries = Result
End Function
Private Sub FillMSChart()
If Not PCX.MapActive Then
Exit Sub
End If
Dim i, j As Integer
Dim MaxZSeries As Integer
Dim X() As Variant
Measure = 0 'Summa
MaxZSeries = 0
With PCX.MapIntf
If (.ColumnsCount = 0) And (.RowsCount = 0) Then
Exit Sub
End If
If .RowDimCount = 0 Then
Exit Sub
End If
If .ColumnDimCount = 0 Then
Exit Sub
End If
k = GetMaxSeries(MaxZSeries, .TopColumns.ChildCount)
ReDim X(0 To k, 0 To .TopRows.ChildCount)
For i = 0 To .TopColumns.ChildCount - 1
If i > k Then
Exit For
End If
'sr1.Marks.Visible = ShowMarks
'sr1.Title := FTopColumn.Childs[i].Caption;
X(i + 1, 0) = .TopColumns.Childs(i).Caption
For j = 0 To .TopRows.ChildCount - 1
If .TopRows.Childs(j).IsNode And .TopRows.Childs(j).NodeExpanded Then
GoTo NextJI
End If
If Not .TopRows.Childs(j).Visible Then
GoTo NextJI
End If
X(i + 1, j + 1) = .Cells(.TopColumns.Childs(i).Position, .TopRows.Childs(j).Position, Measure)
X(0, j + 1) = .TopRows.Childs(j).Caption
NextJI:
Next j, i
End With
With MSChart1
.ToDefaults
.ChartData = X
.chartType = VtChChartType2dBar
' Establish the number of items in the group
numSeries = .Plot.SeriesCollection.Count
' Now add a black line to the border of each of the shapes
For iCount = 1 To numSeries
' .GraphObj.Plot.SeriesCollection(iCount).DataPoints(-1).Brush.FillColor.Set fillColours(iScheme, iCount, 1), fillColours(iScheme, iCount, 2), fillColours(iScheme, iCount, 3)
.Plot.SeriesCollection(iCount).DataPoints(-1).EdgePen.VtColor.Set 0, 0, 0
Next iCount
' Turn off the background grids
.Plot.Axis(VtChAxisIdX).AxisGrid.MajorPen.Style = VtPenStyleNull
.Plot.Axis(VtChAxisIdY).AxisGrid.MajorPen.Style = VtPenStyleNull
.Plot.Axis(VtChAxisIdY2).AxisGrid.MajorPen.Style = VtPenStyleNull
.Plot.Wall.Pen.Style = VtPenStyleNull
' Setup the colours of the pens
' For iCount = 1 To numSeries
' .Plot.SeriesCollection(iCount).Pen.VtColor.Set penColours(iScheme, iCount, 1), penColours(iScheme, iCount, 2), penColours(iScheme, iCount, 3)
' Next iCount
' Define the background colour to white
.Backdrop.Fill.Brush.FillColor.Set 255, 255, 255
.Backdrop.Fill.Style = VtFillStyleBrush
End With
MSChart1.Plot.AutoLayout = True
With MSChart1.Legend
' Add the legend in the required position
.Location.Visible = True
.VtFont.Name = "Arial"
.VtFont.Size = 8
.Location.LocationType = VtChLocationTypeTop
.VtFont.Effect = VtFontStyleBold
End With