#Region Project Attributes
#ApplicationLabel: AndroidLineChart
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim t As Timer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
' private pv1 as PieView 'see project posted here ----->>>> https://www.b4x.com/android/forum/threads/pie-chart-bar-chart.57760/
' private bv1 as BarView 'see project posted here ----->>>> https://www.b4x.com/android/forum/threads/pie-chart-bar-chart.57760/#post-363503
Private lv1 As LineView
Private l1, l2 As Label
Dim canvas1 As Canvas
Dim panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
t.Initialize("t", 500)
lv1.Initialize("")
l1.Initialize("")
l2.Initialize("")
panel1.Initialize("")
Activity.AddView(lv1, 8%x, 12.5%y, 80%x, 75%y)
Activity.AddView(l1, 8%x, 2%y, 80%x, 10%y)
Activity.AddView(l2, 8%x, 90%y, 80%x, 10%y)
Activity.AddView(panel1, 1%x, 12.5%y, 5%x, 75%y)
SideWays("mm of rainfall")
l1.Text = "AVERAGE RAINFALL PER MONTH (mm) - 2014"
l1.Color = Colors.Transparent
l1.TextColor = Colors.Cyan
l1.TextSize = 20.0
l1.Gravity = Gravity.CENTER
l2.Text = "Month of the Year"
l2.Color = Colors.Transparent
l2.TextColor = Colors.Red
l2.Typeface = Typeface.DEFAULT_BOLD
l2.TextSize = 20.0
l2.Gravity = Gravity.CENTER
Dim linebottomtext() As String = Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") 'keep the sequence of calling lv1.BottomTextList = linebottomtext and then lv1.DataList = linedata
lv1.BottomTextList = linebottomtext
'values passed in the below linedata() array should be limited to 100 and not greater than 100 - meant to be percentages
Dim linedata() As Int = Array As Int(317, 15, 75, 295, 13, 48, 355, 33, 55, 257, 21, 85)' 'need to have the same number of elements in the array as what linebottomtext() has
lv1.DataList = linedata
lv1.BottomTextColor = Colors.Yellow
lv1.DrawDotLine = True
lv1.BackgroudLineColor = 0xffccccff
lv1.GraphLineColor = Colors.RGB(255,0,255)
lv1.BigCircleColor = Colors.Yellow
lv1.SmallCircleColor = Colors.White
lv1.BottomTextSize = 15.0
End Sub
Sub Activity_Resume
t.Enabled = True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
t.Enabled = False
End Sub
Sub SideWays(text As String)
canvas1.Initialize(panel1) 'this sets the canvas to be the background of Panel1 and to draw on it's bitmap ... I think :)
'first delete anything already written by writing a big white rectangle on it!
Dim Rect1 As Rect
Rect1.Initialize(0, 0, panel1.Width, panel1.Height)
canvas1.DrawRect(Rect1, Colors.Transparent, True, 1)
'Then draw the text on the canvas at 90degrees where 'CENTER' is the middle of the panel
canvas1.DrawTextRotated(text, panel1.Width / 2, panel1.Height / 2, Typeface.DEFAULT_BOLD, 20, Colors.Red, "CENTER", 270)
'and thusly your panel is your label!
End Sub
Sub t_tick
lv1.GraphLineColor = Colors.RGB(Rnd(0,255),Rnd(0, 255), Rnd(0,255))
' Dim linebottomtext() As String = Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") 'keep the sequence of calling lv1.BottomTextList = linebottomtext and then lv1.DataList = linedata
' lv1.BottomTextList = linebottomtext
'values passed in the below linedata() array should be limited to 100 and not greater than 100 - meant to be percentages
' Dim linedata() As Int = Array As Int(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 255) , Rnd(0, 255)) 'need to have the same number of elements in the array as what linebottomtext() has
Dim linedata(12) As Int
For i = 0 To linedata.Length - 1
linedata(i) = Rnd(0,301)
Next
lv1.DataList = linedata
End Sub