B4A Library MPAndroidCharts - Various type of graphs / charts (Latest library V1.22 in post #1)

Edit 6 Sep 2015: Post #3 adds Single Vertical Bar Charts and update for Pie Charts
Edit 8 Sep 2015 Post #6 update for Single Vertical Bar Charts
Edit 11 Sep 2015 Post #7 adds Single Line Charts
Edit 12 Sep 2015 Post #8 update for Single Line Charts
Edit 12 Sep 2015 Post #9 adds Single Horizontal Bar Charts
Edit 12 Sep 2015 Post #11 adds Radar Charts
Edit 13 Sep 2015 Post #12 update for Single Line and Single Bar Charts
Edit 14 Sep 2015 Post #16 update for Radar Charts
Edit 16 Sep 2015 Post #19 adds Multiple Line Charts
Edit 17 Sep2016 Post #21 adds Multi Vertical Bar Charts
Edit 19 Sep 2015 Post #23 adds Multi Bubble Charts
Edit 19 Sep 2015 Post #24 adds Multi Horizontal Bar Charts
Edit 19 Sep 2015 Post #25 adds Multi Scatter Charts
Edit 19 Sep 2015 Post #26 adds Stacked Bar Charts
Edit 20 Sep 2015 Post #27 adds Candlestick Charts
Edit 20 Sep 2015 Post #28 adds Combined Line & Bar Charts
Edit 23 Sep 2015 Post #31 fixed no-show of Chart Title for Combined Charts and added ability to rotate X-axis labels between -30 and + 30 degrees

I am busy wrapping this Github project. Attached is the Pie Chart functionality of the project/library. Posting the B4A project and Library files. Copy the library files to your additional library folder.

Some remarks about the Pie Chart:
1. It will display the values passed as a percentage of the total of the values that you pass
2. There are 3 x arrays that are passed to the library. Ensure that you pass the same number of elements in each of the arrays.
3. When you click on a pie slice the slice will increase in radial size (see pics below)
4. If you click on the radial increased slice it will return to normal size.
5. You can spin the pie chart around its centre point (CW and ACW) with your finger.

Untouched ...

Pie.gif


1.png


Green slice touched ...

2.png


Pie Chart rotated with finger...

3.png



Some sample code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: MPChart
    #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 mpc1 As PieChart
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")

mpc1.DrawHoleEnabled = True
mpc1.HoleColorTransparent = True

mpc1.TransparentCircleColor = Colors.White
mpc1.TransparentCircleAlpha = 110

mpc1.HoleRadius = 58.0
mpc1.TransparentCircleRadius = 61.0

mpc1.DrawCenterText = True

mpc1.CenterText = "Wrapped by Johan"
mpc1.CenterTextColor = Colors.White
mpc1.CenterTextRadiusPercent = 100.0
mpc1.CenterTextSize = 15.0

mpc1.DrawSliceText = True
mpc1.HoleColor = Colors.Black
mpc1.TransparentCircleColor = Colors.Transparent

mpc1.setTheLegendPosition
mpc1.TheLegendColor = Colors.yellow
mpc1.TheLegendTextSize = 12.0
mpc1.LegendTitle = "MONTHS"

mpc1.ChartDescription = "TITLE : Some Arbitrary Data"
mpc1.ChartDescriptionColor = Colors.ARGB(200,0,255,255)
mpc1.ChartDescriptionTextSize = 17

mpc1.ValueTextColor = Colors.Black
mpc1.ValueTextSize = 15.0

mpc1.PieColors = Array As Int(Colors.Blue, Colors.Yellow, Colors.Green, Colors.Red, Colors.Magenta, Colors.Cyan)
mpc1.LegendText = Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun")
mpc1.ChartData = Array As Float(128.0, 16.0, 46.0, 40.0, 30.0, 40.0)    'values - it will be converted to %

mpc1.PieData = 6

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • b4aMPChart.zip
    7.9 KB · Views: 1,408
  • mpChartLibraryFiles.zip
    221.5 KB · Views: 1,494
  • mpChartLibV1.15.zip
    355.2 KB · Views: 607
  • mpChartLibV1.16.zip
    355.7 KB · Views: 607
  • mpChartLibV1.17.zip
    355.8 KB · Views: 775
  • mpChartLibV1.18.zip
    356.4 KB · Views: 685
  • mpChartLibV1.20.zip
    358.1 KB · Views: 467
  • mpChartLibV1.21.zip
    358 KB · Views: 41
  • mpChartLibV1.22.zip
    359.2 KB · Views: 66
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User

Attachments

  • mpChartLib.jar
    366.7 KB · Views: 201
  • mpChartLib.xml
    383.9 KB · Views: 193
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User
How come you didn't add the new files to the first post, I doubt if I were using this library that I would make it all the way to page 17 post number #322 :)
@Peter Simpson - I started this wrapper when I was young, "clever", and "smart looking". Now I am only old.....:D. It reads like a story book from post 1 to post 324. This is the closest that I will ever get to have "published" a novel (LOL).

One day, when I have some "serious" spare time on hand, I might just do what you are suggesting....until then - please bite the bullet....;)
 
Last edited:

jejeadsl

Member
Licensed User
Hi,
I'm very happy to use this great library. But I would like to disable interactivity.
When I touch a point on a chart, a marker and crosshair showing.
I don't see an option to disable this fonctionnality .:(
Thanks for your help and suggestions. :)
jerome
 
Last edited:

Paulsche

Well-Known Member
Licensed User
Longtime User
i become error in version 1.09, in version 1.06 no problem.
combinedchart.barcolor?


barcolor.jpg
 

Johan Schoeman

Expert
Licensed User
Longtime User
i become error in version 1.09, in version 1.06 no problem.
combinedchart.barcolor?

Please see if this sorts out your problem (V1.11 attached). If not, please post a small sample project so that I can trace the error.
 

Attachments

  • mpChartLib.xml
    384.1 KB · Views: 181
  • mpChartLib.jar
    366.6 KB · Views: 196

Johan Schoeman

Expert
Licensed User
Longtime User
Dear Johan, Is the library no longer available free?
regards,
Rajesh
Rajesh, see post #330 for V1.11 - have removed the date limitation (Xmas gift) but have at the same time reversed a change that I have done for @wimpie3 in the CombinedLineBarChart (post #319) as it did not make sense to do it that way.
 

rbghongade

Active Member
Licensed User
Longtime User
Dear Johan,
Thank you for the gift!
Getting an error related to resources. Tried making the Objects/res file to read only before compilation, still getting the same error.
 

Johan Schoeman

Expert
Licensed User
Longtime User

rbghongade

Active Member
Licensed User
Longtime User
Dear Johan,
Solved by copying the folder from your example. But it seems that XaxisTextAngle method is removed from the latest library, which is of utmost importance to my project!
 

Johan Schoeman

Expert
Licensed User
Longtime User
Dear Johan,
Solved by copying the folder from your example. But it seems that XaxisTextAngle method is removed from the latest library, which is of utmost importance to my project!
What project are you making use of i.e what graph are you trying to draw? Single Bar Chart, combined line and bar chart....?
 

Johan Schoeman

Expert
Licensed User
Longtime User
I am using Single Line Chart.
Here we go - have added as many additional features as what I could to LineChart of what is available in MultiLineChart. See the attached sample project. New lib files (V1.12) also attached.

3.png
 

Attachments

  • MPLineChart301217.zip
    290.8 KB · Views: 253
  • mpChartLib.jar
    367.1 KB · Views: 239
  • mpChartLib.xml
    386.1 KB · Views: 232

rbghongade

Active Member
Licensed User
Longtime User
Dear Johan,
This is New Year gift! Thanks a lot and have a great new year!

PS: A slight problem!
The y-axis grid spacing is not linear as seen in the screen shot attached.
 

Attachments

  • Screenshot.png
    Screenshot.png
    109.8 KB · Views: 197
Last edited:
Top