I don't know how to label the chart base on year..From the picture I attach below, you can see the label R2.How Could I label it?I successful label 2007 only. I want to change the default label R2 to "2006". How to do that?
Code:Dim db1 As Database Dim rs1 As Recordset Set db1 = OpenDatabase("C:\chart2\chart\demoproject.mdb") ' Set rs1 = db1.OpenRecordset("demoproject") Set rs1 = db1.OpenRecordset("table1") MSChart1.Enabled = True MSChart1.Visible = True rs1.MoveLast 'Storing all the values of the records in an array arr(m,n) 'where m is the number of records and n is the number of fields m = rs1.RecordCount n = rs1.Fields.Count - 1 rs1.MoveFirst ReDim arr(m, n) With rs1 For i = 1 To m For j = 1 To n If j = 1 Then arr(i, j) = !Max 'val1 = val1 + !Pondy 'MsgBox (arr(i, j)) End If If j = 2 Then arr(i, j) = !Min 'val2 = val2 + !kkl End If Next j .MoveNext Next i End With rs1.MoveLast With rs1 End With rs1.MoveFirst With MSChart1 ' Displays a 2d chart with 2 columns and 2 rows ' data. '.Rowlabel will give label to Rows in X axis '.Columnlabel will give label to Columns in Y axis .Title.Text = "Hasil Padi" .chartType = VtChChartType2dBar .ColumnCount = n .RowCount = m For Row = 1 To m For Column = 1 To n .Column = Column .Row = Row If Row = 1 Then .RowLabel = "2007" End If ' If Row = 2 Then '.RowLabel = "2006" 'End If If Column = 1 Then .ColumnLabel = "Max" End If If Column = 2 Then .ColumnLabel = "Min" End If '.data will accept the values to the datapoints. .Data = arr(Row, Column) Next Column Next Row ' Use the chart as the backdrop of the legend. .ShowLegend = True .SelectPart VtChPartTypePlot, index1, index2, index3, index4 .EditCopy .SelectPart VtChPartTypeLegend, index1, index2, index3, index4 .EditPaste End With With MSChart1.Plot .Axis(VtChAxisIdY).AxisTitle = "Hasil Padi per Kg/hektar" .Axis(VtChAxisIdX).AxisTitle = "Tahun" End With With MSChart1.Plot 'Filling colours for each item .SeriesCollection.Item(1).DataPoints.Item(-1).Brush.FillColor.Red = 133 .SeriesCollection.Item(2).DataPoints.Item(-1).Brush.FillColor.Green = 100 'To display the data values at the desired location over the datapoints of the item .SeriesCollection.Item(1).DataPoints.Item(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint .SeriesCollection.Item(2).DataPoints.Item(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint End With




Reply With Quote