The first time the button is clicked. I changed from Frappe Chart, because this ABMChart works better for me. But for some reason, I have to click 2 times the button to get the chart on the page. Below is the button's code. The ASPX get the correct dataset ALWAYS.
Thanks, Diego
Thanks, Diego
B4X:
Sub ABMBoton_clicked( target As String)
Dim serverurl As String
Dim job As HttpJob
' create a bar chart
Dim chart3 As ABMChart
chart3.Initialize(page, "chart3", ABM.CHART_TYPEBAR, ABM.CHART_RATIO_GOLDENSECTION, "")
' set some options
chart3.OptionsBar.AxisYOnlyInteger=True
chart3.OptionsBar.ChartPaddingRight=60
'FrappeChart1.Initialize(page, "FrappeChart1", "bar", "Estadistica por Hora", 250)
DateTime.DateFormat = "YYYYMMDD"
'fecini = ABMFecini.GetDate()
'fecfin = ABMFecfin.GetDate()
serverurl = "estadistica_hora.aspx"
job.Initialize("Job1",Me)
job.Download2(serverurl,Array As String("fecini",DateTime.Date(fecini),"fecfin",DateTime.Date(fecfin)))
Wait For (job) jobdone(j As HttpJob)
If j.Success Then
Dim parser As JSONParser
Dim response As String = job.GetString
valores.Initialize()
horas.Initialize
horas.Clear
valores.Clear
'Msgbox("entro","")
parser.Initialize(response)
Dim rows As List
rows = parser.NextArray
If rows.Size = 0 Then
'page.Msgbox("contraseña_i","Error de Usuario y/o Contraseña","Error","Aceptar",False,"","")
'Return
End If
'work with result
'rows is a List. Each item is a Map with the columns names as keys and the db values as the values.
For i = 0 To rows.Size - 1
'Log("Rows #" & i)
Dim m As Map
m = rows.Get(i)
' Msgbox(i,"")
'Msgbox(m.Get("idrepartidor"),"")
'page.Msgbox("contraseña_i",m.Get("idcliente"),"Error","Aceptar",False,"","")
valor = m.Get("cantidad")
valores.Add(valor)
hora = m.Get("HoraPedido")
horas.Add(hora)
'FrappeChart1.FrappeLabels.Add(hora)
'FrappeChart1.AddDataSet("Cant. Pedidos", "light-blue", Array As Int(25, 40, 30, 35, 8, 52, 17, -4), Array As String())
Next
page.Refresh()
Else
Return
End If
' add the labels
chart3.AddLabels(horas)
' add some series
Dim Serie3A As ABMChartSerie
Serie3A.InitializeForBar
Serie3A.SetValues(valores)
chart3.AddSerie(Serie3A)
'FrappeChart1.FrappeLabels.AddAll(horas)
'FrappeChart1.AddDataSet("Cant. Pedidos", "light-blue", valores, Array As String())
chart3.Refresh
page.Cell(2,1).AddComponent(chart3)
'page.Refresh()
End Sub