Re: charting problem
- From: Christoph Basedau <e_tonne@xxxxxxxxxxx>
- Date: Sun, 19 Jun 2005 04:13:47 +0200
18.06.2005 02:10, RB Smissaert schrieb:
> How would I show age sex frequencies in a graph?
> The x axis should hold the 11 groups, 0 to 10, 11 to 20 etc. and the y axis
> should show both the frequencies in males as well as the frequencies in
> females.
> The male and female columns for the same age group should be beside each
> other.
> So the graph would be something like this:
>
> -
> -
> - - -
> - - - -
> - - - -
> - - - - etc.
> -------------------------------------------
> 0 - 10 11 - 20
>
> Hopefully the idea is clear.
> Ideally this graph should be based on one array, maybe an array with 3
> dimensions.
> Thanks for any advice.
Although MChart may be tricky this is an easy thing to do.
Option Explicit
Private Sub Form_Load()
Dim i%, j%, arr(1 To 11, 1 To 2)
'your data: first dimension specifies group/row
'second dimension series (male/female)
arr(1, 1) = 10
arr(1, 2) = 12
arr(2, 1) = 8
arr(2, 2) = 14
arr(3, 1) = 13
arr(3, 2) = 23
arr(4, 1) = 17
arr(4, 2) = 33
arr(5, 1) = 19
arr(5, 2) = 27
arr(6, 1) = 25
arr(6, 2) = 26
arr(7, 1) = 28
arr(7, 2) = 21
arr(8, 1) = 35
arr(8, 2) = 16
arr(9, 1) = 44
arr(9, 2) = 17
arr(10, 1) = 34
arr(10, 2) = 19
arr(11, 1) = 39
arr(11, 2) = 23
With MSChart1
.chartType = VtChChartType2dBar
.ChartData = arr
With .DataGrid
.SetSize 1, 1, 11, 2
'#set row labels for age
For i = 1 To .RowCount
j = ((i - 1) * 10) + 1
.RowLabel(i, 1) = IIf(j = 1, 0, j) & "-" & (j + 9)
Next
End With
With .Plot
'# group bars
.BarGap = 0.2
.xGap = 1.5
'# bar layout
With .SeriesCollection
With .Item(1).DataPoints(-1)
.DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
.DataPointLabel.VtFont.VtColor.Set 255, 0, 0 '# red
.Brush.FillColor.Set 255, 0, 0
End With
With .Item(2).DataPoints(-1)
.DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
.DataPointLabel.VtFont.VtColor.Set 0, 0, 255 '# blue
.Brush.FillColor.Set 0, 0, 255
End With '# s2
End With '#seriescoll
End With '# plot
End With '#chart
End Sub
--
Gruesse, Christoph
Rio Riay Riayo - Gordon Sumner, 1979
.
- Follow-Ups:
- Re: charting problem
- From: RB Smissaert
- Re: charting problem
- From: RB Smissaert
- Re: charting problem
- From: RB Smissaert
- Re: charting problem
- References:
- charting problem
- From: RB Smissaert
- charting problem
- Prev by Date: Re: wordpad format incompatible
- Next by Date: Re: Why? Compile Error: Expected: =
- Previous by thread: Re: charting problem
- Next by thread: Re: charting problem
- Index(es):
Relevant Pages
|