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

fwizardy

Member
I try to use this chart, but i get index error if i use less than 12 data...

I Use the sample above but i reduce it to only below 12 data and MpChartLib v 1.20 from first post
How i do solve it ? Thank you ?


Error occurred on line: 127 (Main)
java.lang.ArrayIndexOutOfBoundsException: length=10; index=10
at mpandroidchartwrapper.multiLineBarChartWrapper.generateLineData1(multiLineBarChartWrapper.java:388)
at mpandroidchartwrapper.multiLineBarChartWrapper.DrawCharts(multiLineBarChartWrapper.java:337)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at JHS.MPMultiLineBarChart.main.afterFirstLayout(main.java:105)
at JHS.MPMultiLineBarChart.main.access$000(main.java:17)
at JHS.MPMultiLineBarChart.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7698)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
 
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Try with the attached - The library should show as V1.21 in the B4A IDE

Have also posted V1.21 in Post #1 of this thread
 

Attachments

  • mpChartLib.zip
    358 KB · Views: 345
  • b4aMPMultiLineBarChart.zip
    29.5 KB · Views: 334

fwizardy

Member
Thank you... It Work....
?

As you can see there should be significant digit on chart, but now is not (the show of marker is same without significant digit).
can we have like multilinechart, it will be zero without significant digit if zero, but if there is value, we can set the significant digit.

Or how can i set it ?

Thank you
 

Johan Schoeman

Expert
Licensed User
Longtime User

Try with the attached project and lib files - It should show as V1.22 in the IDE

This is where I leave this project.....

 

Attachments

  • mpChartLibV1.22.zip
    359.2 KB · Views: 376
  • b4aMPMultiLineBarChart.zip
    29.6 KB · Views: 329

mhk1368

Member
hi
I have data as below which has null value in some places, I want this data not to be shown and the chart is divided into several pieces. It means several separate graphs. The number of these points may reach 100 points. How can I do this? I saw somewhere that you posted a solution, but that command doesn't work anymore, and it only removed the zero points.
https://www.b4x.com/android/forum/threads/mpandroidcharts-skipping-a-value.111796/post-697284
https://stackoverflow.com/questions/50407907/how-to-make-empty-space-in-a-linechart

B4X:
mbc1.LegendText = Array As String("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20","21", "22", "23", "24")
mbc1.ChartData = Array As Float(52, null, null, 70, -48, 0, 0, 79, null, 6.05, 5.5, 55, 0, 0, -3, 20, 48.0, 38.0, 25.0, 53.0, 66.0, 46.0, 67.0, 75.0)


 
Last edited:

RenewMe

Member
Hi, i'm having big problems using mpchartlib v1.22 to design a piechart, I can't find any correct documentation to methods and properties.
Please can anyone tell me where to look for ?
Thank you in advance.
Here is my humble code that's not working:

Pie chart code with mpchartlib V1.22:
#Region  Activity Attributes
    #FullScreen: true
    #IncludeTitle: false
#End Region

Sub Process_Globals
    Public ValoriStatistiche() As Float
    Public NomeMacchina As String
    Public DataRiferimento As String
End Sub

Sub Globals
    ' Deve avere lo STESSO nome che hai messo nel Designer
    Private pie As PieChart
    Private lblTitolo As Label
    Private btnChiudi As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ' 1. Carica il layout del Designer
    Activity.LoadLayout("ChartPie") ' Sostituisci con il nome del tuo file .bal
    Activity.Color = Colors.RGB(33, 33, 33)
    ' 2. Controllo dati di sicurezza
    If ValoriStatistiche = Null Or ValoriStatistiche.Length < 3 Then
        ValoriStatistiche = Array As Float(0, 0, 0)
    End If

    ' 3. Configurazione Grafica (Proprietà sicure)
    pie.ChartDescription = "Distribuzione Stati"
    pie.ChartDescriptionColor = Colors.LightGray
    pie.DrawHoleEnabled = True
    pie.HoleRadius = 45.0
    pie.CenterText = "STATI MACCHINA"
    pie.CenterTextColor = Colors.White
    pie.UsePercentValues = True
    pie.ValueTextColor = Colors.White
    pie.ValueTextSize = 12
    pie.DrawSliceText = True

    ' 4. CARICAMENTO DATI
    pie.LegendText = Array As String("MARCIA", "EMERGENZA", "ALTRO")
    pie.PieColors = Array As Int(Colors.Green, Colors.Red, Colors.Yellow)
    pie.ChartData = ValoriStatistiche
    pie.PieData = 3

    ' 5. GESTIONE CRITICA LEGENDA
    ' Usiamo un piccolo ritardo per dare tempo alla libreria di creare l'oggetto Legend internamente
    'pie.TheLegendTextColor = Colors.White
    'pie.TheLegendTextSize = 12
    pie.TheLegendPosition = "BELOW_CHART_LEFT"

    'pie.Invalidate

    ' --- UI ---
    'lblTitolo.Initialize("")
    lblTitolo.TextColor = Colors.White
    lblTitolo.TextSize = 16
    lblTitolo.Gravity = Gravity.CENTER
    lblTitolo.Text = "REPORT: " & NomeMacchina & CRLF & DataRiferimento
    Activity.AddView(lblTitolo, 0, 5dip, 100%x, 60dip)

    btnChiudi.Text = "CHIUDI"
    btnChiudi.Color = Colors.RGB(200, 0, 0)
End Sub

Sub btnChiudi_Click
    Activity.Finish
End Sub
 

Johan Schoeman

Expert
Licensed User
Longtime User
Please zip your b4a project and upload it so that I can take a look at it. The project in post #1 should be suffiencient to a pie chart.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Thank you
What Datepicker library / class are you using in your project? I do not have that library in my B4A libraries folder
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…