Italian andare in una altra interfaccia

MarcoRome

Expert
Licensed User
Longtime User
uao!!! funziona! e sto imparando tantissimo!

ora ho una necessità, vorrei creare un grafico con i valori, praticamente ho una tabella con su

Numero - Euro - Data
1 30 1/12/2015
1 40 2/1/2016
1 50 4/2/2016
ecc..

vorrei far in modo di poter raggruppare per mese la cifra, e creare un grafico in base al mese.

come faccio?
Puoi utilizzare QUESTA libreria by @Johan Schoeman
 

Nikeddy

Active Member
Licensed User
Longtime User
ho visto la libreria e ho creato un panel e messo una custom view.

ho caricato tramite tool--->configure path --> la libreria del grafico (che infatti mi appare su libraries)

poi ho messo questo :

B4X:
Sub caricagrafico
    panel4.Visible=False
    Panel3.Visible= False
    Panel2.Visible= False
    Panel1.Visible= False
    panel5.Visible= False
    panel6.Visible= True
   
    mbc1.LegendShapeSize = 7.0        'this line of code needs to be before mbc1.setTheLegendPositionAndForm("BELOW_CHART_CENTER", "CIRCLE")
    mbc1.setTheLegendPositionAndForm("BELOW_CHART_CENTER", "CIRCLE")    'pass strings from the above comments
    mbc1.TheLegendColor = Colors.yellow
    mbc1.TheLegendTextSize = 20.0
    mbc1.LegendTitle = ""
    mbc1.ChartDescription = "TITLE : Some Arbitrary Data"
    mbc1.ChartDescriptionColor = Colors.Blue
    mbc1.ChartDescriptionTextSize = 17
    mbc1.setDescriptionPosition(mbc1.left + 14%x ,mbc1.top + 1%y)
    mbc1.ValueTextColor = Colors.Black
    mbc1.ValueTextSize = 10.0
    mbc1.BarColors = Array As Int(Colors.Blue, Colors.Yellow, Colors.Green, Colors.Red, Colors.Magenta, Colors.Cyan, Colors.Blue, Colors.Yellow, Colors.Green, Colors.Red, Colors.Magenta, Colors.Cyan)
    mbc1.LegendText = Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    mbc1.ChartData = Array As Float(52.3, -16.7, 46.0, -40.5, 101.6, 40.9, 15.7, 25.9, 35.6, -25.3, 67.5, 75.2)    'values - it will be converted to %

    mbc1.DoubleTapToZoomEnabled = True
    mbc1.DrawBarShadow = False
    mbc1.GridBackgroundColor = Colors.white
    mbc1.ValueTextColor = 0XFFFFA500
    mbc1.DrawBorders = True
    mbc1.DrawGridBackground = True
    mbc1.DrawHighlightArrow = True
    mbc1.DrawValueAboveBar = True
    mbc1.PinchZoom = True
    mbc1.ScaleEnabled = True
    mbc1.BorderColor = Colors.Yellow
    mbc1.BorderWidth = 3.0

    '   TOP, BOTTOM, BOTH_SIDED, TOP_INSIDE, BOTTOM_INSIDE
    mbc1.XaxisLabelPosition = "BOTTOM"
    mbc1.XaxisTextSize = 15.0
    mbc1.XaxisTextColor = Colors.Magenta
   
    mbc1.DrawYaxisGridLines = True
    mbc1.YaxisTextColor = Colors.Green
    mbc1.YaxisTextSize = 15.0

   
    mbc1.BarData = 12   'this number must be the same as the number of elements in the above arrays
End Sub

e nel sub global ho aggiunto :

B4X:
Sub Globals
 
    Private mbc1 As BarChart

   
End Sub


ma mi da errore :
** Activity (main) Create, isFirst = true **
Error occurred on line: 53 (Main)
java.lang.RuntimeException: java.lang.RuntimeException: Field mbc1 was declared with the wrong type.
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.samples.mysql.main.afterFirstLayout(main.java:102)
at anywheresoftware.b4a.samples.mysql.main.access$000(main.java:17)
at anywheresoftware.b4a.samples.mysql.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.RuntimeException: Field mbc1 was declared with the wrong type.
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:399)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:425)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:144)
... 17 more
** Activity (main) Resume **


come mai?
 

semar

Active Member
Licensed User
Longtime User
Il messaggio di errore dice che hai dichiarato la variabile mpc1 in modo errato:
java.lang.RuntimeException: java.lang.RuntimeException: Field mbc1 was declared with the wrong type.

Un estratto dell' esempio della libreria in questione e'
Private mpc1 As PieChart

Nel tuo codice invece risulta:
Private mbc1 As BarChart

Spero di esserti stato d' aiuto.
Sergio
 
Top