B4J Question Add jChart (Area chart) to a tab pane

rgarnett1955

Active Member
Licensed User
Longtime User
Hi,

I have a main form with a Tab container. I wish to add a JChart object (Area chart) to one of my tab layouts programmatically as the jChart is not a custom view and can't be added in the Designer.

How can I do this?

Thanks
Rob
 

Chris2

Active Member
Licensed User
Longtime User
This is completely untested, but can you just create a layout with only a single pane, then add the chart to that pane in the code?
So, something like:
B4X:
tabPane.LoadLayout("ChartPane", "Chart")    'ChartPane contains only a pane named pnlChart'



Sub AddChart
    Private SBChart As StackedBarChart
    Dim XAxisSBC As CategoryAxis
    Dim YAxisSBC As NumberAxis
    XAxisSBC.Initialize("XAxisSBC")
    XAxisSBC.Label = "x"
    YAxisSBC.Initialize("YAxisSBC")
    YAxisSBC.Label = "y"

    SBChart.Initialize(XAxisSBC, YAxisSBC, "SBC")
    
    pnlChart.AddNode(SBChart,0,0,pnlChart.Width,pnlChart.Height)
    
End Sub
 
Upvote 0

Chris2

Active Member
Licensed User
Longtime User
Or maybe:
B4X:
Dim tpage As TabPage
tpage.Initialize
tpage.Text="Chart"
TabPane.Tabs.Add(tpage)


Sub AddChart

    Private SBChart As StackedBarChart
    Dim XAxisSBC As CategoryAxis
    Dim YAxisSBC As NumberAxis
    XAxisSBC.Initialize("XAxisSBC")
    XAxisSBC.Label = "x"
    YAxisSBC.Initialize("YAxisSBC")
    YAxisSBC.Label = "y"

    SBChart.Initialize(XAxisSBC, YAxisSBC, "SBC")
    
    tpage.Content.AddNode(SBChart, 0, 0, tpage.Content.Width, pnlChart.Height)
    
End Sub
 
Upvote 0
Top