Android Question [solved] Set PieChart visibility

stevel05

Expert
Licensed User
Longtime User
It is implemented as a CustomView, you can probably get the base pane(l) with something like GetBase and set the visibility on that.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Several solutions:

1. Change Private mBase As B4XView to Public mBase As B4XView in the PieChart CustomView module.
Then you can change the Visible property like PieChart1.mBase.Visible = False.

2. Add the Visible property routines in the PieChart CustomView module:
B4X:
'gets or sets the Visible propety
Public Sub setVisible(Visible As Boolean)
    mBase.Visible = Visible
End Sub

Public Sub getVisible As Boolean
    Return mBase.Visible
End Sub
Then you can change the Visible property like PieChart1.Visible = False.

3. Use the xChart Class.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I do not want to run over klaus's good post, but if he does not want to make changes to the class, as a fourth option, he can put the PieChart on a panel and set the panel visibility:
B4X:
Sub Globals
    Private PieChart1 As PieChart  'the parent is Panel1
    Private xui As XUI
    Private Panel1 As Panel
    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("MAIN")
    Dim data As List
    data.Initialize
    data.Add(PieChart1.CreateSlice("Slice #1", 234, 0)) '0 = random color
    data.Add(PieChart1.CreateSlice("Slice #2", 500, xui.Color_Red))
    data.Add(PieChart1.CreateSlice("Slice #3", 20, 0))
    data.Add(PieChart1.CreateSlice("Slice #4", 200, 0))
    PieChart1.SetData(data)
End Sub

Sub Button1_Click
    Panel1.Visible=Not (Panel1.Visible)
End Sub
 
Upvote 0

Almog

Active Member
Licensed User
It is implemented as a CustomView, you can probably get the base pane(l) with something like GetBase and set the visibility on that.
Several solutions:

1. Change Private mBase As B4XView to Public mBase As B4XView in the PieChart CustomView module.
Then you can change the Visible property like PieChart1.mBase.Visible = False.

2. Add the Visible property routines in the PieChart CustomView module:
B4X:
'gets or sets the Visible propety
Public Sub setVisible(Visible As Boolean)
    mBase.Visible = Visible
End Sub

Public Sub getVisible As Boolean
    Return mBase.Visible
End Sub
Then you can change the Visible property like PieChart1.Visible = False.

3. Use the xChart Class.
I do not want to run over klaus's good post, but if he does not want to make changes to the class, as a fourth option, he can put the PieChart on a panel and set the panel visibility:
B4X:
Sub Globals
    Private PieChart1 As PieChart  'the parent is Panel1
    Private xui As XUI
    Private Panel1 As Panel
    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("MAIN")
    Dim data As List
    data.Initialize
    data.Add(PieChart1.CreateSlice("Slice #1", 234, 0)) '0 = random color
    data.Add(PieChart1.CreateSlice("Slice #2", 500, xui.Color_Red))
    data.Add(PieChart1.CreateSlice("Slice #3", 20, 0))
    data.Add(PieChart1.CreateSlice("Slice #4", 200, 0))
    PieChart1.SetData(data)
End Sub

Sub Button1_Click
    Panel1.Visible=Not (Panel1.Visible)
End Sub

Thank you very much!!! :)
 
Upvote 0
Top