B4A Library Android-Charts : Another Charting / Graphing Library - (30 Oct) Added Spider Web Charts

I have started wrapping this Github charting library. Have completed Pie Charts and Donut Charts. Will post the other available charts as and when I complete each of them. The "no show" of the main chart title is still a mystery that I need to trace in the Github project. Posting the following:

1. B4A project
2. B4A library files

Some sample code for the Pie and Donut charts:

B4X:
#Region  Project Attributes
    #ApplicationLabel: Android_Charts
    #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.

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 pc1 As PieChart
    Private dc1 As DonutChart
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")
  
'   *********************************************** PIE CHART STARTS HERE    *********************************************************  
  
    pc1.BorderColor = Colors.Blue                        'border color for the square border around the pie chart
    pc1.BorderWidth = 7.0                                'border width for the square border around the pie chart
    pc1.CircleBorderColor = Colors.Cyan
    pc1.CircleBorderWidth = 15.0                       
  
    pc1.DisplayBorder = True                            'display / don't display the square border around the pie chart                     
                       
    pc1.LongitudeColor = Colors.Black                    'color of the dividing lines between the pie slices
  
    pc1.PieTextColor = Colors.black
    pc1.PieTextSize = 15.0
  
'    pc1.Title = "My Pie Chart"                          'This does not work yet - need to trace why the Github project does not draw the main chart title
    pc1.setTitlePosition(pc1.Left + 5%x, pc1.Top + 2%y)
  
    'the following 3 arrays need to have/contain the same number of elements
    Dim piecolors() As Int = Array As Int(Colors.Red, Colors.Blue, Colors.Yellow, Colors.Green, Colors.LightGray)
    Dim pievalues() As Int = Array As Int(2, 3, 5, 4, 7)
    Dim pietitles() As String = Array As String("First", "Second", "Third", "Fourth", "Fifth")

    pc1.PieSliceColors = piecolors
    pc1.PieSliceValues = pievalues
    pc1.PieSliceTitles = pietitles

    pc1.initPieChart
  
'   *********************************************** DONUT CHART STARTS HERE    *********************************************************
  
    dc1.BorderColor = Colors.Red                         'border color for the square border around the pie chart
    dc1.BorderWidth = 7.0                                'border width for the square border around the pie chart
    dc1.CircleBorderColor = Colors.Cyan
    dc1.CircleBorderWidth = 15.0 
  
    dc1.Color = Colors.DarkGray                    
  
    dc1.DisplayBorder = True                            'display / don't display the square border around the pie chart                     
                       
    dc1.DonutTextColor = Colors.White
    dc1.DonutTextSize = 15.0
  
'    dc1.Title = "My Donut Chart"                        'This does not work yet - need to trace why the Github project does not draw the main chart title
    dc1.setTitlePosition(dc1.Left + 5%x, dc1.Top + 2%y)
  
    'the following 3 arrays need to have/contain the same number of elements
    Dim donutcolors() As Int = Array As Int(Colors.Red, Colors.Blue, Colors.Yellow, Colors.Green, Colors.LightGray)
    Dim donutvalues() As Int = Array As Int(2, 3, 5, 4, 7)
    Dim donuttitles() As String = Array As String("First", "Second", "Third", "Fourth", "Fifth")

    dc1.DonutSliceColors = donutcolors
    dc1.DonutSliceValues = donutvalues
    dc1.DonutSliceTitles = donuttitles
  
    dc1.initDonutChart  

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

1.png



Android_Charts
Author:
Johan Schoeman
Version: 1
  • DonutChart
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • initDonutChart
    • setTitlePosition (x As Int, y As Int)
      Set the chart title position
    Properties:
    • Background As Drawable
    • BorderColor As Int [write only]
    • BorderWidth As Float [write only]
    • CircleBorderColor As Int [write only]
    • CircleBorderWidth As Int [write only]
    • Color As Int [write only]
    • DisplayBorder As Boolean [write only]
    • DonutSliceColors() As Int [write only]
      Set the colors of the donut slices
    • DonutSliceTitles() As String [write only]
      Set the titles of the donut slices
    • DonutSliceValues() As Int [write only]
      Set the values of the donut slices
    • DonutTextColor As Int [write only]
      Set the color of the text of the percentages
    • DonutTextSize As Float [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Tag As Object
    • Title As String [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
PieChart
Fields:

  • ba As BA
Methods:
  • BringToFront
  • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
  • Initialize (EventName As String)
  • Invalidate
  • Invalidate2 (arg0 As Rect)
  • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
  • IsInitialized As Boolean
  • RemoveView
  • RequestFocus As Boolean
  • SendToBack
  • SetBackgroundImage (arg0 As Bitmap)
  • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
  • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
  • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
  • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
  • initPieChart
  • setTitlePosition (x As Int, y As Int)
    Set the chart title position
Properties:
  • Background As Drawable
  • BorderColor As Int [write only]
  • BorderWidth As Float [write only]
  • CircleBorderColor As Int [write only]
  • CircleBorderWidth As Int [write only]
  • Color As Int [write only]
  • DisplayBorder As Boolean [write only]
  • Enabled As Boolean
  • Height As Int
  • Left As Int
  • LongitudeColor As Int [write only]
  • PieSliceColors() As Int [write only]
    Set the colors of the pie slices
  • PieSliceTitles() As String [write only]
    Set the titles of the pie slices
  • PieSliceValues() As Int [write only]
    Set the values of the pie slices
  • PieTextColor As Int [write only]
    Set the color of the text of the percentages
  • PieTextSize As Float [write only]
    Set the text size of the text in the pie
  • Tag As Object
  • Title As String [write only]
  • Top As Int
  • Visible As Boolean
  • Width As Int
You can download and test any posting of mine in this thread but if you want to use it then you need to
 

Attachments

  • Android_Charts_LibFiles.zip
    92.1 KB · Views: 456
  • b4aAndroid_Charts.zip
    8.4 KB · Views: 409
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
The attached project adds Radar Charts. You can add a maximum of 5 charts to the Radar Chart. Posting:
1. New B4A library files
2. B4A project that demonstrates Pie Charts, Donut Charts, and Radar Charts.

I am sure you will figure out the relationship between the values of the charts and the number of concentric circles.

1.png


Some sample code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: Android_Charts
    #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.

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 pc1 As PieChart
    Private dc1 As DonutChart
    Private rc1 As RadarChart
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")
   
    drawPieChart
    drawDonutChart
    drawRadarChart
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub drawPieChart
   
    pc1.BorderColor = Colors.Blue                        'border color for the square border around the pie chart
    pc1.BorderWidth = 7.0                                'border width for the square border around the pie chart
    pc1.CircleBorderColor = Colors.Cyan
    pc1.CircleBorderWidth = 15.0                        
   
    pc1.DisplayBorder = True                            'display / don't display the square border around the pie chart                      
                        
    pc1.LongitudeColor = Colors.Black                    'color of the dividing lines between the pie slices
   
    pc1.PieTextColor = Colors.black
    pc1.PieTextSize = 15.0
   
'    pc1.Title = "My Pie Chart"                          'This does not work yet - need to trace why the Github project does not draw the main chart title
'    pc1.setTitlePosition(pc1.Left + 5%x, pc1.Top + 2%y)
   
    'the following 3 arrays need to have/contain the same number of elements
    Dim piecolors() As Int = Array As Int(Colors.Red, Colors.Blue, Colors.Yellow, Colors.Green, Colors.LightGray)
    Dim pievalues() As Int = Array As Int(2, 3, 5, 4, 7)
    Dim pietitles() As String = Array As String("First", "Second", "Third", "Fourth", "Fifth")

    pc1.PieSliceColors = piecolors
    pc1.PieSliceValues = pievalues
    pc1.PieSliceTitles = pietitles

    pc1.initPieChart   
   
End Sub


Sub drawDonutChart
   
    dc1.BorderColor = Colors.Red                         'border color for the square border around the pie chart
    dc1.BorderWidth = 7.0                                'border width for the square border around the pie chart
    dc1.CircleBorderColor = Colors.Cyan
    dc1.CircleBorderWidth = 15.0  
   
    dc1.Color = Colors.DarkGray                     
   
    dc1.DisplayBorder = True                            'display / don't display the square border around the pie chart                      
                        
    dc1.DonutTextColor = Colors.White
    dc1.DonutTextSize = 15.0
   
'    dc1.Title = "My Donut Chart"                        'This does not work yet - need to trace why the Github project does not draw the main chart title
    dc1.setTitlePosition(dc1.Left + 5%x, dc1.Top + 2%y)
   
    'the following 3 arrays need to have/contain the same number of elements
    Dim donutcolors() As Int = Array As Int(Colors.Red, Colors.Blue, Colors.Yellow, Colors.Green, Colors.LightGray)
    Dim donutvalues() As Int = Array As Int(2, 3, 5, 4, 7)
    Dim donuttitles() As String = Array As String("First", "Second", "Third", "Fourth", "Fifth")

    dc1.DonutSliceColors = donutcolors
    dc1.DonutSliceValues = donutvalues
    dc1.DonutSliceTitles = donuttitles
   
    dc1.initDonutChart       
   
End Sub


Sub drawRadarChart
   
'    rc1.Title = "My Radar Chart"                          'This does not work yet - need to trace why the Github project does not draw the main chart title
    rc1.setTitlePosition(pc1.Left + 5%x, pc1.Top + 2%y)   
    rc1.BorderColor = Colors.Green
    rc1.BorderWidth = 10.0

    rc1.DisplayBorder = True

    rc1.ConcentricWebColor = Colors.LightGray
    rc1.ConcentricWebWidth = 3
   
    rc1.RadialWebColor = Colors.Magenta
    rc1.RadialWebWidth = 3
   
    rc1.RadarChartInnerColor = Colors.Transparent
   
    rc1.RadarChartFontTextColor = Colors.Yellow
    rc1.RadarChartFontTextSize = 12.0
   
    'add a maximum of 5 colors - we can only draw a maximum of 5 radar charts
    Dim rcColors() As Int = Array As Int(Colors.Red, Colors.Yellow, Colors.Blue, Colors.Green, Colors.White)
    rc1.RadarChartColors = rcColors
   
    'the webtitles() and webvalues_x() arrays all need to have the same number of elements - in this case 7
    Dim webtitles() As String = Array As String("ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN")
    rc1.RadarTitles = webtitles
   
    Dim webvalues_1() As Float = Array As Float(3.0, 4.0, 9.0, 8.0, 10.0, 13.0, 6.0)
    rc1.RadarValues_1 = webvalues_1
   
    Dim webvalues_2() As Float = Array As Float(3.0, 12.0, 5.0, 6.0, 8.0, 12.0, 3.0)
    rc1.RadarValues_2 = webvalues_2
   
    Dim webvalues_3() As Float = Array As Float(2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0)
    rc1.RadarValues_3 = webvalues_3   
   
    Dim webvalues_4() As Float = Array As Float(0.0, 3.0, 7.5, 13.0, 18.6, 9.4, 13.6)
    rc1.RadarValues_4 = webvalues_4       
   
    Dim webvalues_5() As Float = Array As Float(16.0, 8.0, 4.0, 1.0, 5.0, 11.0, 18.0)
    rc1.RadarValues_5 = webvalues_5           
   
    rc1.LatitudeNum = 14                      'how many concentric circles it will draw

    rc1.initRadarChart   
   
   
End Sub

The library as it stands at present:

Android_Charts
Author:
Johan Schoeman
Version: 1
  • DonutChart
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • initDonutChart
    • setTitlePosition (x As Int, y As Int)
      Set the chart title position
    Properties:
    • Background As Drawable
    • BorderColor As Int [write only]
    • BorderWidth As Float [write only]
    • CircleBorderColor As Int [write only]
    • CircleBorderWidth As Int [write only]
    • Color As Int [write only]
    • DisplayBorder As Boolean [write only]
    • DonutSliceColors() As Int [write only]
      Set the colors of the donut slices
    • DonutSliceTitles() As String [write only]
      Set the titles of the donut slices
    • DonutSliceValues() As Int [write only]
      Set the values of the donut slices
    • DonutTextColor As Int [write only]
      Set the color of the text of the percentages
    • DonutTextSize As Float [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Tag As Object
    • Title As String [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • PieChart
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • initPieChart
    • setTitlePosition (x As Int, y As Int)
      Set the chart title position
    Properties:
    • Background As Drawable
    • BorderColor As Int [write only]
    • BorderWidth As Float [write only]
    • CircleBorderColor As Int [write only]
    • CircleBorderWidth As Int [write only]
    • Color As Int [write only]
    • DisplayBorder As Boolean [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • LongitudeColor As Int [write only]
    • PieSliceColors() As Int [write only]
      Set the colors of the pie slices
    • PieSliceTitles() As String [write only]
      Set the titles of the pie slices
    • PieSliceValues() As Int [write only]
      Set the values of the pie slices
    • PieTextColor As Int [write only]
      Set the color of the text of the percentages
    • PieTextSize As Float [write only]
      Set the text size of the text in the pie
    • Tag As Object
    • Title As String [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • RadarChart
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • initRadarChart
    • setTitlePosition (x As Int, y As Int)
      Set the chart title position
    Properties:
    • Background As Drawable
    • BorderColor As Int [write only]
    • BorderWidth As Float [write only]
    • Color As Int [write only]
    • ConcentricWebColor As Int [write only]
      Set the color of the concentric web circles
    • ConcentricWebWidth As Float [write only]
      Set the width of the concentric web lines
    • DisplayBorder As Boolean [write only]
    • Enabled As Boolean
    • Height As Int
    • LatitudeNum As Int [write only]
    • Left As Int
    • RadarChartColors() As Int [write only]
      Set the colors of the radar charts
    • RadarChartFontTextColor As Int [write only]
      Set the font text color
    • RadarChartFontTextSize As Float [write only]
      Set the font text size
    • RadarChartInnerColor As Int [write only]
      Set the inner background color of the radar chart
    • RadarTitles() As String [write only]
      Set the titles of the radar charts
    • RadarValues_1() As Float [write only]
      Set the values for the first radar chart
    • RadarValues_2() As Float [write only]
      Set the values for the second radar chart
    • RadarValues_3() As Float [write only]
      Set the values for the third radar chart
    • RadarValues_4() As Float [write only]
      Set the values for the fourth radar chart
    • RadarValues_5() As Float [write only]
      Set the values for the fifth radar chart
    • RadialWebColor As Int [write only]
      Set the color of the radial web lines
    • RadialWebWidth As Float [write only]
      Set the width of the radial web lines
    • Tag As Object
    • Title As String [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • b4aAndroid_Charts.zip
    8.9 KB · Views: 357
  • Android_Charts_LibFiles.zip
    98.2 KB · Views: 357

Johan Schoeman

Expert
Licensed User
Longtime User
The attached project adds Spider Web Charts. Posting
1. the B4A project (ignore the code that has been commented for the Rose Chart - the Rose Chart is Work-In-Progress)
2. the new B4A library files.

1.png


Click on the button to cycle through the four charts that have been added thus far.

Android_Charts
Author:
Johan Schoeman
Version: 1
SpiderWebChart
Fields:

  • ba As BA
Methods:
  • BringToFront
  • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
  • Initialize (EventName As String)
  • Invalidate
  • Invalidate2 (arg0 As Rect)
  • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
  • IsInitialized As Boolean
  • RemoveView
  • RequestFocus As Boolean
  • SendToBack
  • SetBackgroundImage (arg0 As Bitmap)
  • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
  • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
  • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
  • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
  • initSpiderWebChart
  • setTitlePosition (x As Int, y As Int)
    Set the chart title position
Properties:
  • Background As Drawable
  • BorderColor As Int [write only]
  • BorderWidth As Float [write only]
  • Color As Int [write only]
  • ConcentricWebColor As Int [write only]
    Set the color of the concentric web circles
  • ConcentricWebWidth As Float [write only]
    Set the width of the concentric web lines
  • DisplayBorder As Boolean [write only]
  • Enabled As Boolean
  • Height As Int
  • LatitudeNum As Int [write only]
  • Left As Int
  • RadialWebColor As Int [write only]
    Set the color of the radial web lines
  • RadialWebWidth As Float [write only]
    Set the width of the radial web lines
  • SpiderWebChartColors() As Int [write only]
    Set the colors of the radar charts
  • SpiderWebChartFontTextColor As Int [write only]
    Set the font text color
  • SpiderWebChartFontTextSize As Float [write only]
    Set the font text size
  • SpiderWebChartInnerColor As Int [write only]
    Set the inner background color of the radar chart
  • SpiderWebTitles() As String [write only]
    Set the titles of the spider web charts
  • SpiderWebValues_1() As Float [write only]
    Set the values for the first spider web chart
  • SpiderWebValues_2() As Float [write only]
    Set the values for the second spider web chart
  • SpiderWebValues_3() As Float [write only]
    Set the values for the third spider web chart
  • SpiderWebValues_4() As Float [write only]
    Set the values for the fourth spider web chart
  • SpiderWebValues_5() As Float [write only]
    Set the values for the fifth spider web chart
  • Tag As Object
  • Title As String [write only]
  • Top As Int
  • Visible As Boolean
  • Width As Int


Some sample code

B4X:
#Region  Project Attributes
    #ApplicationLabel: Android_Charts
    #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.

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 pc1 As PieChart
    Private dc1 As DonutChart
    Private rc1 As RadarChart
'    Private rose1 As RoseChart
    Private swc1 As SpiderWebChart
    Private Button1 As Button
  
    Dim flag As Int = 0
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")
  
    drawPieChart
    drawDonutChart
    drawRadarChart
    drawSpiderWebChart
  
    pc1.Visible = True
    dc1.Visible = False
    rc1.Visible = False
    swc1.Visible = False
  

  
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub drawPieChart
  
    pc1.BorderColor = Colors.Blue                        'border color for the square border around the pie chart
    pc1.BorderWidth = 7.0                                'border width for the square border around the pie chart
    pc1.CircleBorderColor = Colors.Cyan
    pc1.CircleBorderWidth = 5.0                       
  
    pc1.DisplayBorder = True                            'display / don't display the square border around the pie chart                     
                       
    pc1.LongitudeColor = Colors.Black                    'color of the dividing lines between the pie slices
  
    pc1.PieTextColor = Colors.black
    pc1.PieTextSize = 15.0
  
'    pc1.Title = "My Pie Chart"                          'This does not work yet - need to trace why the Github project does not draw the main chart title
'    pc1.setTitlePosition(pc1.Left + 5%x, pc1.Top + 2%y)
  
    'the following 3 arrays need to have/contain the same number of elements
    Dim piecolors() As Int = Array As Int(Colors.Red, Colors.Blue, Colors.Yellow, Colors.Green, Colors.LightGray)
    Dim pievalues() As Int = Array As Int(2, 3, 5, 4, 7)
    Dim pietitles() As String = Array As String("First", "Second", "Third", "Fourth", "Fifth")

    pc1.PieSliceColors = piecolors
    pc1.PieSliceValues = pievalues
    pc1.PieSliceTitles = pietitles

    pc1.initPieChart  
  
End Sub


Sub drawDonutChart
  
    dc1.BorderColor = Colors.Red                         'border color for the square border around the pie chart
    dc1.BorderWidth = 7.0                                'border width for the square border around the pie chart
    dc1.CircleBorderColor = Colors.Cyan
    dc1.CircleBorderWidth = 5.0 
  
    dc1.Color = Colors.DarkGray                    
  
    dc1.DisplayBorder = True                            'display / don't display the square border around the pie chart                     
                       
    dc1.DonutTextColor = Colors.White
    dc1.DonutTextSize = 15.0
  
'    dc1.Title = "My Donut Chart"                        'This does not work yet - need to trace why the Github project does not draw the main chart title
    dc1.setTitlePosition(dc1.Left + 5%x, dc1.Top + 2%y)
  
    'the following 3 arrays need to have/contain the same number of elements
    Dim donutcolors() As Int = Array As Int(Colors.Red, Colors.Blue, Colors.Yellow, Colors.Green, Colors.LightGray)
    Dim donutvalues() As Int = Array As Int(2, 3, 5, 4, 7)
    Dim donuttitles() As String = Array As String("First", "Second", "Third", "Fourth", "Fifth")

    dc1.DonutSliceColors = donutcolors
    dc1.DonutSliceValues = donutvalues
    dc1.DonutSliceTitles = donuttitles
  
    dc1.initDonutChart      
  
End Sub


Sub drawRadarChart
  
'    rc1.Title = "My Radar Chart"                          'This does not work yet - need to trace why the Github project does not draw the main chart title
'    rc1.setTitlePosition(pc1.Left + 5%x, pc1.Top + 2%y)  
    rc1.BorderColor = Colors.Green
    rc1.BorderWidth = 5.0

    rc1.DisplayBorder = True

    rc1.ConcentricWebColor = Colors.LightGray
    rc1.ConcentricWebWidth = 3
  
    rc1.RadialWebColor = Colors.Magenta
    rc1.RadialWebWidth = 3
  
    rc1.RadarChartInnerColor = Colors.Transparent
  
    rc1.RadarChartFontTextColor = Colors.Yellow
    rc1.RadarChartFontTextSize = 12.0
  
    'add a maximum of 5 colors - we can only draw a maximum of 5 radar charts
    Dim rcColors() As Int = Array As Int(Colors.Red, Colors.Yellow, Colors.Blue, Colors.Green, Colors.White)
    rc1.RadarChartColors = rcColors
  
    'the webtitles() and webvalues_x() arrays all need to have the same number of elements - in this case 7
    Dim webtitles() As String = Array As String("ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN")
    rc1.RadarTitles = webtitles
  
    Dim webvalues_1() As Float = Array As Float(3.0, 4.0, 9.0, 8.0, 10.0, 13.0, 6.0)
    rc1.RadarValues_1 = webvalues_1
  
    Dim webvalues_2() As Float = Array As Float(3.0, 12.0, 5.0, 6.0, 8.0, 12.0, 3.0)
    rc1.RadarValues_2 = webvalues_2
  
    Dim webvalues_3() As Float = Array As Float(2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0)
    rc1.RadarValues_3 = webvalues_3  
  
    Dim webvalues_4() As Float = Array As Float(0.0, 3.0, 7.5, 13.0, 18.6, 9.4, 13.6)
    rc1.RadarValues_4 = webvalues_4      
  
    Dim webvalues_5() As Float = Array As Float(16.0, 8.0, 4.0, 1.0, 5.0, 11.0, 18.0)
    rc1.RadarValues_5 = webvalues_5          
  
    rc1.LatitudeNum = 14                      'how many concentric circles it will draw

    rc1.initRadarChart  
  
  
End Sub


Sub drawSpiderWebChart
  
'    swc1.Title = "My SpiderWeb Chart"                          'This does not work yet - need to trace why the Github project does not draw the main chart title
'    swc1.setTitlePosition(swc1.Left + 5%x, swc1.Top + 2%y)  
    swc1.BorderColor = Colors.Green
    swc1.BorderWidth = 5.0

    swc1.DisplayBorder = True

    swc1.ConcentricWebColor = Colors.DarkGray
    swc1.ConcentricWebWidth = 2
  
    swc1.RadialWebColor = Colors.Cyan
    swc1.RadialWebWidth = 3
  
    swc1.SpiderWebChartInnerColor = Colors.Transparent
  
    swc1.SpiderWebChartFontTextColor = Colors.White
    swc1.SpiderWebChartFontTextSize = 12.0
  
    'add a maximum of 5 colors - we can only draw a maximum of 5 spider web charts
    Dim swcColors() As Int = Array As Int(Colors.Red, Colors.Yellow, Colors.Blue, Colors.Green, Colors.White)
    swc1.SpiderWebChartColors = swcColors
  
    'the webtitles() and webvalues_x() arrays all need to have the same number of elements - in this case 7
    Dim webtitles() As String = Array As String("ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN")
    swc1.SpiderWebTitles = webtitles
  
    Dim webvalues_1() As Float = Array As Float(3.0, 4.0, 9.0, 8.0, 10.0, 13.0, 6.0)
    swc1.SpiderWebValues_1 = webvalues_1
  
    Dim webvalues_2() As Float = Array As Float(3.0, 12.0, 5.0, 6.0, 8.0, 12.0, 3.0)
    swc1.SpiderWebValues_2 = webvalues_2
  
    Dim webvalues_3() As Float = Array As Float(2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0)
    swc1.SpiderWebValues_3 = webvalues_3  
  
    Dim webvalues_4() As Float = Array As Float(0.0, 3.0, 7.5, 13.0, 18.6, 9.4, 13.6)
    swc1.SpiderWebValues_4 = webvalues_4      
  
    Dim webvalues_5() As Float = Array As Float(16.0, 8.0, 4.0, 1.0, 5.0, 11.0, 18.0)
    swc1.SpiderWebValues_5 = webvalues_5          
  
    swc1.LatitudeNum = 5                      'how many concentric webs it will draw

    swc1.initSpiderWebChart  
  
  
End Sub

'Sub drawRoseChart
'  
'    rose1.BorderColor = Colors.Blue                        'border color for the square border around the pie chart
'    rose1.BorderWidth = 7.0                                'border width for the square border around the pie chart
'    rose1.CircleBorderColor = Colors.Cyan
'    rose1.CircleBorderWidth = 15.0                       
'  
'    rose1.DisplayBorder = True                            'display / don't display the square border around the pie chart                     
'                       
'    rose1.LongitudeColor = Colors.Black                    'color of the dividing lines between the pie slices
'  
'    rose1.RoseTextColor = Colors.black
'    rose1.RoseTextSize = 15.0
'  
''    rose1.Title = "My Pie Chart"                          'This does not work yet - need to trace why the Github project does not draw the main chart title
''    rose1.setTitlePosition(rose1.Left + 5%x, rose1.Top + 2%y)
'  
'    'the following 3 arrays need to have/contain the same number of elements
'    Dim rosecolors() As Int = Array As Int(Colors.Red, Colors.Blue, Colors.Yellow, Colors.Green, Colors.LightGray)
'    Dim rosevalues() As Int = Array As Int(2, 3, 5, 4, 7)
'    Dim rosetitles() As String = Array As String("First", "Second", "Third", "Fourth", "Fifth")
'
'    rose1.RoseSliceColors = rosecolors
'    rose1.RoseSliceValues = rosevalues
'    rose1.RoseSliceTitles = rosetitles
'
'    rose1.initRoseChart  
'  
'End Sub


Sub Button1_Click
  
    flag = flag + 1
    If flag = 1 Then
      dc1.Visible = True
      pc1.Visible = False
      rc1.Visible = False
      swc1.Visible = False
    else if flag = 2 Then
      dc1.Visible = False
      pc1.Visible = False
      rc1.Visible = True
      swc1.Visible = False      
    else if flag = 3 Then
      dc1.Visible = False
      pc1.Visible = False
      rc1.Visible = False
      swc1.Visible = True      
    Else
      flag = 0
      dc1.Visible = False
      pc1.Visible = True
      rc1.Visible = False
      swc1.Visible = False
    End If
  
End Sub
 

Attachments

  • Android_ChartsLibFiles.zip
    174.2 KB · Views: 385
  • b4aAndroid_Charts.zip
    9.6 KB · Views: 351

PABLO2013

Well-Known Member
Licensed User
Longtime User
thanks
for your library really is very good , I wonder if you can declare gird chart or line chart, thanks
 

Johan Schoeman

Expert
Licensed User
Longtime User
Top