1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4J Tutorial Charts Framework

Discussion in 'B4J Tutorials' started by Erel, Nov 20, 2013.

  1. Erel

    Erel Administrator Staff Member Licensed User

    The attached project is a port of Basic4android charts framework: http://www.basic4ppc.com/android/forum/threads/android-charts-framework.8260/#content

    [​IMG]


    [​IMG]

    Note that this example uses a TabPane. TabPanes are currently not wrapped as a B4J type. However you can still use them with the help of the Scene Builder.

    Another important point is the way we add the Canvases to each of the panes.
    We want the canvas to fill the pane.

    Usually the best way to do it is by setting all the anchors to 0:
    Code:
    AnchorPane.SetAnchors(SomeNode, 0000)
    However the automatic layout only works with resizeable nodes. Canvas and ImageView are not resizable. This means that we need to explicitly set the width and height.
    Code:
    panePie.AddNode(cvs, 00, panePie.PrefWidth, panePie.PrefHeight)
    We use PrefWidth and PrefHeight instead of Width and Height as the Width and Height of the tab panes are not available when the layout is created. They will only later be available.


    This example requires v1.00 BETA 3+.
     

    Attached Files:

    Last edited: Nov 20, 2013
    luke2012, raphaelcno and giannimaione like this.
  2. positrom2

    positrom2 Active Member Licensed User

    Where in the B4J code is the action defined that determines the plot types to be shown?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    See the code in the main module. It creates a different plot type for each of the panes.
     
  4. positrom2

    positrom2 Active Member Licensed User

    Are the different charts after having been created by the B4J code sent to the foreground just by JavaFx upon clicking on the respective tab?
    Is the click event seen in the B4J code? In Debug mode, nothing happens after Appstart has finished.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You should see the bars chart when you run the program.

    Have you modified the code?
     
  6. positrom2

    positrom2 Active Member Licensed User

    I see the different chart screens -the program works as to be expected, I did not modify it.
    I just wanted to understand what happens when I click on a tab.
    In B4A, a click event would be handled by the code.
    Here, I don't see a Sub to handle an event.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    I now understand. TabPane was not yet wrapped in B4J. So you cannot handle its unique events. In this case the TabPane doesn't even have an id.

    In the designer I set the ids of the internal AnchorPanes (open the layout to see it).

    Nothing special happens when you click on the tab. It just switches to a different tab.
     
  8. positrom2

    positrom2 Active Member Licensed User

    Thank you.
     
  9. krlos2004

    krlos2004 Member Licensed User

    for colored bars

    Chart :

    BD.Canvas.DrawRect(Rect, BD.BarsColors.Get(a), True, 1dip) 'not color

    for
    BD.Canvas.DrawRect(Rect, BD.BarsColors.Get(i-1), True, 1dip)

    ok
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice