I have started wrapping version 0.6.2 of this charting/graphing project. The attached project draws multiple line charts. See the sample code (or attached B4A project) for various settings of the graphs and the plot layout.
This has really been a very challenging project thus far - way more complicated than MPAndroidCharts. Will post updates and additional type of charts going forward (but one thing that I will not do is to accommodate any special requests that would require modifying the original code - there are at present over 1400 lines of code in the wrapper just to wrap the multi-line chart part of the original project).
The attached project will allow you to draw up to 5 line chats in a single plot. Most of the exposed methods in the library (I think just about all...) have been used in the attached project.
Posting the following:
1. B4A project demonstrating this wrapper (i.e multi line chart)
2. B4A library files - copy them to your additional library folder
Sample code:
The library as it stands at present:
AndroidPlot_0_6_2
Author: Wrapped by Johan Schoeman
Version: 1
Fields:
You can download and test any posting of mine in this thread but if you want to use it then you need to
This has really been a very challenging project thus far - way more complicated than MPAndroidCharts. Will post updates and additional type of charts going forward (but one thing that I will not do is to accommodate any special requests that would require modifying the original code - there are at present over 1400 lines of code in the wrapper just to wrap the multi-line chart part of the original project).
The attached project will allow you to draw up to 5 line chats in a single plot. Most of the exposed methods in the library (I think just about all...) have been used in the attached project.
Posting the following:
1. B4A project demonstrating this wrapper (i.e multi line chart)
2. B4A library files - copy them to your additional library folder
Sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: AndroidPlot_PieChart
#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 lc1 As LineChart
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")
lc1.GraphBackgroundColor = Colors.DarkGray
lc1.GraphFrameColor = Colors.Blue
lc1.GraphFrameWidth = 4.0
lc1.GraphPlotAreaBackgroundColor = Colors.ARGB(50, 0, 0, 255)
lc1.GraphTitleTextSize = 15
lc1.GraphTitleColor = Colors.White
lc1.GraphTitleSkewX = -0.25
lc1.GraphTitleUnderline = True
lc1.GraphTitleBold = True
lc1.GraphTitle = "MONTHLY RAINFALL FOR SOME PLACE IN THE WORLD - 2010 TO 2014" 'put this statement last
lc1.LegendBackgroundColor = Colors.White 'it will be converted to an Alpha = 100
lc1.LegendTextColor = Colors.Black
lc1.LegendTextSize = 15.0
lc1.DomianLabel = "MONTH OF THE YEAR"
lc1.DomainLabelColor = Colors.Green
lc1.DomainLabelTextSize = 18.0
lc1.XaxisGridLineColor = Colors.ARGB(100,255,255,255)
lc1.XaxisGridLineWidth = 2.0
lc1.XaxisLabelTicks = 1
lc1.XaxisLabelOrientation = 0
lc1.XaxisLabelTextColor = Colors.Red
lc1.XaxisLabelTextSize = 15.0
lc1.XAxisLabels = Array As String("Jan","Feb", "Mar","Apr", "May","Jun","Jul", "Aug","Sep","Oct") ', "Nov","Dec")
lc1.YaxisDivisions = 8
' lc1.YaxisRange(0, 9000) 'enable this line if you want to set the y-axis minimum and maximum values - else it will be scaled automatically
lc1.YaxisValueFormat = lc1.ValueFormat_0 'could be ValueFormat_0, ValueFormat_1, ValueFormat_2, or ValueFormat_3
lc1.YaxisGridLineColor = Colors.Black
lc1.YaxisGridLineWidth = 2
lc1.YaxisLabelTicks = 1
lc1.YaxisLabelColor = Colors.Yellow
lc1.YaxisLabelOrientation = -30
lc1.YaxisLabelTextSize = 12
lc1.YaxisTitleColor = Colors.Green
lc1.YaxisTitleFakeBold = False
lc1.YaxisTitleTextSize = 20.0
lc1.YaxisTitleUnderline = True
lc1.YaxisTitleTextSkewness = 0
lc1.YaxisLabelAndTitleDistance = 60.0
lc1.YaxisTitle = "mm of rainfall recorded" 'put this statement last
lc1.MaxNumberOfEntriesPerLineChart = 10 'this value must be equal to the number of x-axis labels that you pass
lc1.Line_1_LegendText = "2010"
lc1.Line_1_Data = Array As Float (1000.0, 1500.0, 1700.0, 2000.0, 1800.0, 2500.0, 2700.0, 2800.0, 3100.0, 1600.0)
lc1.Line_1_PointLabelTextColor = Colors.Yellow
lc1.Line_1_PointLabelTextSize = 15.0
lc1.Line_1_LineColor = Colors.LightGray
lc1.Line_1_LineWidth = 2.0
lc1.Line_1_PointColor = Colors.Red
lc1.Line_1_PointSize = 20.0
lc1.Line_1_PointShape = lc1.SHAPE_ROUND
lc1.Line_1_DrawDash = True
lc1.Line_1_DrawCubic = True
lc1.Line_2_LegendText = "2011"
lc1.Line_2_Data = Array As Float (2200.0, 2700.0, 2900.0, 2800.0, 2600.0, 3000.0, 3300.0, 3400.0, 3900.0, 1400.0)
lc1.Line_2_PointLabelTextColor = Colors.Black
lc1.Line_2_PointLabelTextSize = 15.0
lc1.Line_2_LineColor = Colors.Green
lc1.Line_2_LineWidth = 5.0
lc1.Line_2_PointColor = Colors.Cyan
lc1.Line_2_PointSize = 20.0
lc1.Line_2_PointShape = lc1.SHAPE_SQUARE
lc1.Line_2_DrawDash = True
lc1.Line_2_DrawCubic = False
lc1.Line_3_LegendText = "2012"
lc1.Line_3_Data = Array As Float (3200.0, 3700.0, 3900.0, 3800.0, 3600.0, 4000.0, 4300.0, 4400.0, 4900.0, 400.0)
lc1.Line_3_PointLabelTextColor = Colors.Green
lc1.Line_3_PointLabelTextSize = 15.0
lc1.Line_3_LineColor = Colors.White
lc1.Line_3_LineWidth = 3.0
lc1.Line_3_PointColor = Colors.Green
lc1.Line_3_PointSize = 15.0
lc1.Line_3_PointShape = lc1.SHAPE_BUTT
lc1.Line_3_DrawDash = False
lc1.Line_3_DrawCubic = True
lc1.Line_4_LegendText = "2013"
lc1.Line_4_Data = Array As Float (5000.0, 5300.0, 5400.0, 5900.0, 1600.0, 4200.0, 4700.0, 4900.0, 4800.0, 4600.0)
lc1.Line_4_PointLabelTextColor = Colors.LightGray
lc1.Line_4_PointLabelTextSize = 15.0
lc1.Line_4_LineColor = Colors.Red
lc1.Line_4_LineWidth = 7.0
lc1.Line_4_PointColor = Colors.Black
lc1.Line_4_PointSize = 18.0
lc1.Line_4_PointShape = lc1.SHAPE_ROUND
lc1.Line_4_DrawDash = False
lc1.Line_4_DrawCubic = False
lc1.Line_5_LegendText = "2014"
lc1.Line_5_Data = Array As Float (7700.0, 7900.0, 7800.0, 7600.0, 8000.0, 8300.0, 8400.0, 8900.0, 7400.0, 6200.0)
lc1.Line_5_PointLabelTextColor = Colors.Transparent 'make the point label text to appear "invisible"
lc1.Line_5_PointLabelTextSize = 15.0
lc1.Line_5_LineColor = 0xFFFF1493
lc1.Line_5_LineWidth = 5.0
lc1.Line_5_PointColor = Colors.Transparent 'make the point to appear "invisible"
lc1.Line_5_PointSize = 10.0
lc1.Line_5_PointShape = lc1.SHAPE_SQUARE
lc1.Line_5_DrawDash = True
lc1.Line_5_DrawCubic = True
lc1.NumberOfLineCharts = 5 'set the number of graphs to draw from the 1 to 5 graph that has been set up above
lc1.DrawTheGraphs
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
The library as it stands at present:
AndroidPlot_0_6_2
Author: Wrapped by Johan Schoeman
Version: 1
Fields:- Labels As String[]
- clone As Object
- format (obj As Object, toAppendTo As StringBuffer, pos As FieldPosition) As StringBuffer
- formatToCharacterIterator (arg0 As Object) As AttributedCharacterIterator
- parseObject (string As String, position As ParsePosition) As Object
Fields:
- SHAPE_BUTT As String
draw the point on the line as BUTT - SHAPE_ROUND As String
draw the point on the line as ROUND - SHAPE_SQUARE As String
draw the point on the line as SQUARE - ValueFormat_0 As String
value will be displayed without and decimals - ValueFormat_1 As String
value will be displayed with one decimal - ValueFormat_2 As String
value will be displayed with two decimals - ValueFormat_3 As String
value will be displayed with three decimals - ba As BA
- BringToFront
- DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
- DrawTheGraphs
- 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)
- YaxisRange (mimimum As Float, maximum As Float)
Set the minimum and maximum range of the y-axis
If not set then they y-axis min and max will be set automatically
- Background As Drawable
- Color As Int [write only]
- DomainLabelColor As Int [write only]
set the color of the domain label - DomainLabelTextSize As Float [write only]
set the text size of the domain label - DomianLabel As String [write only]
set the domain label - Enabled As Boolean
- GraphBackgroundColor As Int [write only]
set graph background color - GraphFrameColor As Int [write only]
set the color of the outer frame around the graph - GraphFrameWidth As Float [write only]
set the width of the outer frame around the graph - GraphLegendVisibility As Boolean [write only]
set the legend visibility - GraphPlotAreaBackgroundColor As Int [write only]
set the background color of the plot area - GraphTitle As String [write only]
set the graph title - GraphTitleBold As Boolean [write only]
set bold text of the graph main title - GraphTitleColor As Int [write only]
set the color main graph title - GraphTitleSkewX As Float [write only]
set the skewness to the main graph title
a float value ranging from -1.0 to 1.0 - GraphTitleTextSize As Int [write only]
set the text size of the graph main title - GraphTitleUnderline As Boolean [write only]
set undelining of the graph main title - Height As Int
- Left As Int
- LegendBackgroundColor As Int [write only]
Set the background color of the legend - LegendTextColor As Int [write only]
Set the legend text color - LegendTextSize As Float [write only]
Set the legend text size - Line_1_Data() As Float [write only]
set line 1 data to plot - Line_1_DrawCubic As Boolean [write only]
draw Line_1's line graph as a cubic line - Line_1_DrawDash As Boolean [write only]
draw Line_1's line graph as a dashed line - Line_1_LegendText As String [write only]
set line 1 legend text - Line_1_LineColor As Int [write only]
set the color of Line_1's graph - Line_1_LineWidth As Float [write only]
set the width of Line_1's line graph - Line_1_PointColor As Int [write only]
set the color of the points on Line_1's line graph - Line_1_PointLabelTextColor As Int [write only]
set line 1 point label text color - Line_1_PointLabelTextSize As Float [write only]
set line 1 point label text size - Line_1_PointShape As String [write only]
set the shape of the points on Line_1's line graph - Line_1_PointSize As Float [write only]
set the size of the points on Line_1's line graph - Line_2_Data() As Float [write only]
set line 2 data to plot - Line_2_DrawCubic As Boolean [write only]
draw Line_2's line graph as a cubic line - Line_2_DrawDash As Boolean [write only]
draw Line_2's line graph as a dashed line - Line_2_LegendText As String [write only]
set line 2 legend text - Line_2_LineColor As Int [write only]
set the color of Line_2's graph - Line_2_LineWidth As Float [write only]
set the width of Line_2's line graph - Line_2_PointColor As Int [write only]
set the color of the points on Line_2's line graph - Line_2_PointLabelTextColor As Int [write only]
set line 2 point label text color - Line_2_PointLabelTextSize As Float [write only]
set line 2 point label text size - Line_2_PointShape As String [write only]
set the shape of the points on Line_2's line graph - Line_2_PointSize As Float [write only]
set the size of the points on Line_2's line graph - Line_3_Data() As Float [write only]
set line 3 data to plot - Line_3_DrawCubic As Boolean [write only]
draw Line_3's line graph as a cubic line - Line_3_DrawDash As Boolean [write only]
draw Line_3's line graph as a dashed line - Line_3_LegendText As String [write only]
set line 3 legend text - Line_3_LineColor As Int [write only]
set the color of Line_3's graph - Line_3_LineWidth As Float [write only]
set the width of Line_3's line graph - Line_3_PointColor As Int [write only]
set the color of the points on Line_3's line graph - Line_3_PointLabelTextColor As Int [write only]
set line 3 point label text color - Line_3_PointLabelTextSize As Float [write only]
set line 3 point label text size - Line_3_PointShape As String [write only]
set the shape of the points on Line_3's line graph - Line_3_PointSize As Float [write only]
set the size of the points on Line_3's line graph - Line_4_Data() As Float [write only]
set line 4 data to plot - Line_4_DrawCubic As Boolean [write only]
draw Line_4's line graph as a cubic line - Line_4_DrawDash As Boolean [write only]
draw Line_4's line graph as a dashed line - Line_4_LegendText As String [write only]
set line 4 legend text - Line_4_LineColor As Int [write only]
set the color of Line_4's graph - Line_4_LineWidth As Float [write only]
set the width of Line_4's line graph - Line_4_PointColor As Int [write only]
set the color of the points on Line_4's line graph - Line_4_PointLabelTextColor As Int [write only]
set line 4 point label text color - Line_4_PointLabelTextSize As Float [write only]
set line 4 point label text size - Line_4_PointShape As String [write only]
set the shape of the points on Line_4's line graph - Line_4_PointSize As Float [write only]
set the size of the points on Line_4's line graph - Line_5_Data() As Float [write only]
set line 5 data to plot - Line_5_DrawCubic As Boolean [write only]
draw Line_5's line graph as a cubic line - Line_5_DrawDash As Boolean [write only]
draw Line_5's line graph as a dashed line - Line_5_LegendText As String [write only]
set line 5 legend text - Line_5_LineColor As Int [write only]
set the color of Line_5's graph - Line_5_LineWidth As Float [write only]
set the width of Line_5's line graph - Line_5_PointColor As Int [write only]
set the color of the points on Line_5's line graph - Line_5_PointLabelTextColor As Int [write only]
set line 5 point label text color - Line_5_PointLabelTextSize As Float [write only]
set line 5 point label text size - Line_5_PointShape As String [write only]
set the shape of the points on Line_5's line graph - Line_5_PointSize As Float [write only]
set the size of the points on Line_5's line graph - MaxNumberOfEntriesPerLineChart As Int [write only]
set the number of entries per Line graph - NumberOfLineCharts As Int [write only]
- Tag As Object
- Top As Int
- Visible As Boolean
- Width As Int
- XAxisLabels() As String [write only]
set the x-axis labels - XaxisGridLineColor As Int [write only]
set the color of the major grid lines parallel to the x-axis - XaxisGridLineWidth As Float [write only]
set the width of the major grid lines parallel to the x-axis - XaxisLabelOrientation As Float [write only]
set x-axis label orientation (degrees) - XaxisLabelTextColor As Int [write only]
set x-axis label text color - XaxisLabelTextSize As Float [write only]
set x-axis label text size - XaxisLabelTicks As Int [write only]
set the number of x-axis ticks between consecutive labels - YaxisDivisions As Int [write only]
Set the number of y-axis divisions - YaxisGridLineColor As Int [write only]
set the color of the major grid lines parallel to the y-axis - YaxisGridLineWidth As Float [write only]
set the width of the major grid lines parallel to the y-axis - YaxisLabelAndTitleDistance As Float [write only]
set the distance between yaxis labels and the y-axis title - YaxisLabelColor As Int [write only]
set the color of the y-axis labels - YaxisLabelOrientation As Float [write only]
set the text orientation of the y-axis labels - YaxisLabelTextSize As Float [write only]
set the text size of the y-axis labels - YaxisLabelTicks As Int [write only]
set the number of y-axis ticks between consecutive labels - YaxisTitle As String [write only]
set the range label (i.e the y-axis title) - YaxisTitleColor As Int [write only]
set the y-axis title color - YaxisTitleFakeBold As Boolean [write only]
set fake bold of the y-axis title - YaxisTitleTextSize As Float [write only]
set the y-axis title text size - YaxisTitleTextSkewness As Float [write only]
set the y-axis title text skewness
a float value ranging from -1.0 to 1.0 - YaxisTitleUnderline As Boolean [write only]
set underlining of the y-axis title - YaxisValueFormat As String [write only]
set the y-axis value format
(eg 99, 99.1, 99.12, 99.123)
pass the required ValueFormat_x string eg
lc1.YaxisValueFormat = lc1.ValueFormat_3
You can download and test any posting of mine in this thread but if you want to use it then you need to
Attachments
Last edited: