B4J Question [ABMaterial] ABMChart setting values at run time

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

I am using ABM 4.03 and have not upgraded to 4.25

I create an ABMChart as follows in the ConnectPage. Then I read the values from database and thenn update/refresh the graph
B4X:
public Sub ConnectPage()
    ...
    ...

    Dim MyContainer As ABMContainer
     MyContainerInitialize(page, " MyContainer","tabpagewhite")

    Dim chartSales As ABMChart
    chartSales.Initialize(page, "chartSales", ABM.CHART_TYPEBAR,     ABM.CHART_RATIO_GOLDENSECTION, "chart4theme")
    ' set some options
    'chartSales.OptionsBar.AxisXOnlyInteger=True
    chartSales.OptionsBar.StackBars = True
    chartSales.OptionsBar.HorizontalBars = True

    ' add the labels
    chartSales.AddLabels(Array As String("Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",     "Nov", "Dec", "Jan", "Feb", "Mar"))
  
    ' add some series
    Dim Serie4A As ABMChartSerie
    Serie4A.InitializeForBar
    ' Initial values Zero, later these values are read from database and then updated in the graph
    Serie4A.SetValues(Array As Int(0,0,0,0,0,0,0,0,0,0,0,0))
    chartSales.AddSerie(Serie4A)
    chartSales.OptionsBar.AxisYShowLabel=True
  
    ' add the chart to the cell
    MyContainer.Cell(5,1).AddComponent(chartSales)

    ..
    ..
    'Here in this Sub I read the real values from Database
    CallSubDelayed2(Me,"GetMyValues","SomeValues")
End Sub

Sub GetMyValues(Target As String)
    Dim SQL As SQL = DBM.GetSQL
  
    'Get the Values from Database via SQL and filled the values in an Array of Int
    Dim nValues() As Int = Array As Int ( 10,20,30,40,50,60,70,80,90,100,110,120)
  
    DBM.CloseSQL(SQL)
  
    Dim  MyContainer As ABMContainer = page.Component("MyContainer")
    Dim chartSales As ABMChart =  MyContainer.Component("chartSales")
    chartSales.RemoveSerie("A")

    Dim DataSerie As ABMChartSerie
    DataSerie.InitializeForBar
    'Set the values with the values that you read from the database
    DataSerie.SetValues( nValues )
    chartSales.AddSerie(Serie4A)

    chartSales.Refresh
  
End Sub

Unfortunately, I don't see any changes in the graph.

Any help will be appreciated.
 

Anser

Well-Known Member
Licensed User
Longtime User
I am adding the Container "MyContainer" on to a TAB, and the TAB is then added to the page.
B4X:
Dim tabs As ABMTabs
tabs.Initialize2(page, "tabs", 48,-8, 8, "tabs")
tabs.AddTab("tab1", "{B}Sales{/B}", MyContainer,3,3,3,12,12,12,True,True, "", "")
page.Cell(2,1).AddComponent(tabs)


I thought that it was not relevant to show that in the sample code that I posted above, hence did not include that in the post
 
Last edited:
Upvote 0

Anser

Well-Known Member
Licensed User
Longtime User
Do you see errors in the browsers console log?
To view browser's console log, I added these 2 lines in BuldPage()
B4X:
page.DebugConsoleB4JStart
page.DebugConsoleEnable(True, 300)

And this is the error that I see in the console

1.0 Uncaught TypeError: Cannot read property 'update' of undefined<br /><span>http://192.168.0.154:5100/PGSales/DashboardSalesService/<strong>DashboardSalesService.1522044289868.js</strong> | Line: <strong>35</strong></span>

This is the code that I use to re-assign the new values to the chart at run time

B4X:
' Re-assigning the values at run time
Dim nValues() As Int = Array As Int ( 10,20,30,40,50,60,70,80,90,100,110,120)

chartSales.RemoveSerie("A")
Dim DataSerie As ABMChartSerie
DataSerie.InitializeForBar
'Set the values with the values that you read from the database
DataSerie.SetValues( nValues ) 'Reset with new values
chartSales.AddSerie(DataSerie)
chartSales.Refresh
 
Upvote 0

Anser

Well-Known Member
Licensed User
Longtime User
ABMTabs, already has a container for each "tab"
I know that this question is out of topic in this thread

How do I create TAB without a container for the Tab pages ? I am unable to create the TAB's without a container. It gives compilation error

If I do not pass the container parameter name while creating the TAB, I get the "Missing Parameter" error message ie
B4X:
'Trying to avoid the 3rd parameter ie Container name
tabs.AddTab("tab2", "Sales",  ,3,3,3,12,12,12,True,False, "", "")

If I pass an empty string instead of leaving the 3rd parameter (container) empty ie
B4X:
'Trying to avoid the 3rd parameter ie Container name and pass empty string
tabs.AddTab("tab2", "Sales", "" ,3,3,3,12,12,12,True,False, "", "")
then I get the following compilation error "String cannot be converted to ABMContainer"
 
Upvote 0
Top