B4J Question [ABMaterial 4.25] [Solved] ABMChart in modalsheet

magi6162

Well-Known Member
Licensed User
the chart,
it does not appear in the modalsheet.
Surely I'm wrong, but what?o_O

thanks

in connect page:
B4X:
page.AddModalSheetTemplate(BuildGraficoModalSheet)
...
btnGrafico.InitializeFloating(page, "btnGrafico", "mdi-editor-insert-chart", "subgreen")
acbMap.AddMenuButton(btnGrafico)

page.AddActionButton(acbMap)
B4X:
Sub acbMap_Clicked(Target As String, SubTarget As String)
    If SubTarget = "" Then
        Log("clicked main button Map")
    Else if SubTarget = "btngrafico" Then
          page.ShowModalSheet("GraficoModal")    
    End If
End Sub
B4X:
Sub Page_ModalSheetReady(ModalSheetName As String)
    Log(ModalSheetName & " is ready!")
    If ModalSheetName = "graficomodal" Then
        Dim GraficoModal As ABMModalSheet = page.ModalSheet(ModalSheetName)
        Dim cht As ABMChart = GraficoModal.Content.Component("cht")
'        cht.Visibility = ABM.VISIBILITY_ALL
        CreaGrafico(DateTime.GetYear(DateTime.Now))
        cht.Refresh
    End If
End Sub
B4X:
Sub CreaGrafico(Anno As Int)
    Dim GraficoModal As ABMModalSheet = page.ModalSheet("GraficoModal")
    Dim SQLDB As SQL = ABMShared.SQLGet
    Dim lstR As List = DBM.SQLSelect(SQLDB,"SELECT Mese,SUM(Ore) AS Ore  FROM rapporti  WHERE IDC = ? AND Anno = ? GROUP BY Mese ORDER BY Mese", _
                                                Array As Object(ABMShared.IDC,Anno))
    SQLDB.Close
       
    Dim lblGAnno As ABMLabel = GraficoModal.Header.Cell(1,2).Component("lblGAnno")
    lblGAnno.Text = Anno
    lblGAnno.Refresh
    Dim cht As ABMChart = GraficoModal.Content.Component("cht")
    'cht.Clear
    Dim aOreM() As Int = Array As Int(0,0,0,0,0,0,0,0,0,0,0,0)
    For i = 0 To 11
        aOreM(i) = ABM.CHART_NULLVALUE
    Next
   
    For i = 0 To lstR.Size - 1
        Dim m As Map = lstR.Get(i)
        aOreM(m.Get("mese") - 1) = m.Get("ore")
    Next
    Dim SerieM As ABMChartSerie
    SerieM.InitializeForLine(ABM.CHART_SERIEINDEX_A)
    SerieM.SetValues(aOreM)
    cht.AddSerie(SerieM)
    cht.Refresh  
End Sub
B4X:
Sub BuildGraficoModalSheet() As ABMModalSheet
    Dim GraficoModal As ABMModalSheet
    GraficoModal.Initialize(page, "GraficoModal", False, ABM.MODALSHEET_TYPE_NORMAL, "modalheader_jw")
    GraficoModal.Content.UseTheme("modalcontent")
    GraficoModal.Footer.UseTheme("modalfooter_jw")
    GraficoModal.Size = ABM.MODALSHEET_SIZE_LARGE
    GraficoModal.IsDismissible = True
 
    ' create the grid for the content
    GraficoModal.Content.AddRows(1,True,"").AddCellsOS(1,0,0,0,12,12,12,"cellcenter")
    GraficoModal.Content.BuildGrid ' IMPORTANT!
 
    ' create a line chart
    Dim cht As ABMChart
    cht.Initialize(page, "cht", ABM.CHART_TYPELINE, ABM.CHART_RATIO_GOLDENSECTION, "chart1theme")
    ' add the labels
    cht.AddLabels(Array As String("Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"))
    ' set some options
    cht.OptionsLine.FullWidth=True

    cht.OptionsLine.ChartPaddingRight=60 ' because we set fullwidth, we have to adjust so the final label also fits
    cht.OptionsLine.Serie(ABM.CHART_SERIEINDEX_A).LineSmooth = ABM.CHART_LINESMOOTH_SIMPLE

    cht.AddPluginDefinition("Chartist.plugins.ctPointLabels({textAnchor: 'middle'})")
 
 
    cht.Refresh
    ' add the chart to the cell
    GraficoModal.Content.Cell(1,1).AddComponent(cht)
    Return GraficoModal
End Sub
 

magi6162

Well-Known Member
Licensed User
Solved:
in
BuildGraficoModalSheet()

B4X:
    Dim SerieM As ABMChartSerie
    SerieM.InitializeForLine(ABM.CHART_SERIEINDEX_A)
    SerieM.SetValues(Array As Int(ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE, _
                                    ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE,ABM.CHART_NULLVALUE))
    cht.AddSerie(SerieM)
    cht.Refresh
:)
 
Upvote 0
Top