Pertama-tama pastikan control MsChart sudah ada pada Toolbox.
Jika belum ada, klik kanan pada toolbox -> Components...
Kemudian akan muncul Components Dialog, check Microsoft Chart Control 6.0 dan klik OK.
Atur tampilan design form seperti berikut:
Berikut ini adalah code VB yang digunakan:
Private Sub Form_Load()
'List Combo: chart types
With Combo1
.AddItem "3D Bar"
.AddItem "2D Bar"
.AddItem "3D Line"
.AddItem "2D LIne"
.AddItem "3D Area"
.AddItem "2D Area"
.AddItem "3D Step"
.AddItem "2D Step"
.AddItem "3D Combination"
.AddItem "2D Combination"
.ListIndex = 1 'default:2D Bar
End With
Check1.Caption = "&Show Legends"
'2D array --> chart values
Dim X(1 To 7, 1 To 6) As Variant
X(1, 2) = "Jakarta"
X(1, 3) = "Bandung"
X(1, 4) = "Cirebon"
X(1, 5) = "Bogor"
X(1, 6) = "Sukabumi"
X(2, 1) = "JAN"
X(2, 2) = 3
X(2, 3) = 4
X(2, 4) = 5
X(2, 5) = 6
X(2, 6) = 7
X(3, 1) = "FEB"
X(3, 2) = 4
X(3, 3) = 5
X(3, 4) = 3
X(3, 5) = 8
X(3, 6) = 12
X(4, 1) = "MAR"
X(4, 2) = 1
X(4, 3) = 3
X(4, 4) = 8
X(4, 5) = 10
X(4, 6) = 9
X(5, 1) = "APR"
X(5, 2) = 4
X(5, 3) = 6
X(5, 4) = 12
X(5, 5) = 10
X(5, 6) = 14
X(6, 1) = "MAY"
X(6, 2) = 2
X(6, 3) = 9
X(6, 4) = 7
X(6, 5) = 12
X(6, 6) = 8
X(7, 1) = "JUN"
X(7, 2) = 12
X(7, 3) = 19
X(7, 4) = 5
X(7, 5) = 19
X(7, 6) = 10
'2D array --> chart data
MSChart1.ChartData = X
End Sub
Private Sub Check1_Click()
If Check1.Value = 1 Then
'Show Legends
MSChart1.ShowLegend = True
Check1.Caption = "&Hide Legends"
Else
'Hide Legends
MSChart1.ShowLegend = False
Check1.Caption = "&Show Legends"
End If
End Sub
Private Sub Combo1_Click()
'chart type -->run time.
MSChart1.chartType = Combo1.ListIndex
End Sub
Run applikasi untuk melihat hasil nya.
Coba ubah pilihan tipe chart dengan combobox dan centang checkbox Show/Hide Legend untuk menampilkan dan menyembunyikan legend.
- Home
- Tutorial Bahasa Indonesia
- _Visual Basic 6 (VB6)
- __VB6 Basic & General
- __VB6 MySQL
- _Visual Basic .NET
- __VB.NET Basic & General
- __VB.NET Ms Access
- __VB.NET MySQL
- __VB.NET Printing
- _ASP.NET
- _C#
- _PHP
- _Flutter
- _MySQL
- _SQL Server
- _SQL Reporting (SSRS)
- English Tutorial
- Youtube Channel
- About Me
- _About Me and This Blog
- _Stories Of Life
- _Portofolio
3 Comments
terima kasih..
http://rani-irsan.blogspot.com/2014/06/tutorial-visual-basic-6-vb6-dan-mysql.html
tinggal disesuaikan dengan code bikin chart