Hi,
I'm trying to add some custom gauges with ABMCustomComponent and this code:
GaugeClass
My question is: How can update gauge value once page is already loaded? It's possible to make something like this?
Thanks in advance.
I'm trying to add some custom gauges with ABMCustomComponent and this code:
B4X:
page.AddExtraJavaScriptFile("custom/justgage.js")
page.AddExtraJavaScriptFile("custom/raphael-2.1.4.min.js")
B4X:
Dim custGauge As GaugeClass
custGauge.Initialize(page, "custGauge", 25, "Test")
page.Cell(2,1).AddComponent(custGauge.ABMComp)
GaugeClass
B4X:
Sub Class_Globals
Dim ABMComp As ABMCustomComponent
Private myValue As Int
Private myLabel As String
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(InternalPage As ABMPage, ID As String, value As Int, name As String)
ABMComp.Initialize("ABMComp", Me, InternalPage, ID)
myValue = value
myLabel = name
End Sub
Sub ABMComp_Build(internalID As String) As String
Return $"<div id="${internalID}"></div>"$
End Sub
' Is useful to run some initalisation script.
Sub ABMComp_FirstRun(InternalPage As ABMPage, internalID As String)
Dim script As String = $"
var g1 = new JustGage({
id: "${internalID}",
value: ${myValue},
Min: 0,
Max: 100,
relativeGaugeSize: true,
title: "${myLabel}"
});"$
InternalPage.ws.Eval(script, Array As Object(ABMComp.ID))
' flush not needed, it's done in the refresh method in the lib
End Sub
' runs when a refresh is called
Sub ABMComp_Refresh(InternalPage As ABMPage, internalID As String)
End Sub
' do the stuff needed when the object is removed
Sub ABMComp_CleanUp(InternalPage As ABMPage, internalID As String)
End Sub
My question is: How can update gauge value once page is already loaded? It's possible to make something like this?
B4X:
Dim mygauge As GaugeClass = page.Component("custGauge")
mygauge.update(50)
Thanks in advance.