B4J Question x, y plot

Discussion in 'B4J Questions' started by bdunkleysmith, Apr 24, 2015.

  1. bdunkleysmith

    bdunkleysmith Active Member Licensed User

    As part of a B4J application I finish up with a table of data consisting of x and y coordinates (both in the range 0 - 100) and for each point value of 1 or 0.

    I want to produce a (scatter?) plot of those points, with the shape of the plotted point being determined by whether its value is 1 or 0. For instance 1 could be shown as x and 0 as o, but any distinguishable shape would be OK such as a square and circle.

    I'm just looking for a pointer on what method would suit and where to start. I was thinking javafx.scene.shape may be is where I should be.

    Thanks in anticipation of any suggestions.

    Bryon
     
  2. Daestrum

    Daestrum Well-Known Member Licensed User

    You could use the scatterchart object to display your data. Its quite easy to add to your project.
    Have attached example for you to try.
     

    Attached Files:

  3. bdunkleysmith

    bdunkleysmith Active Member Licensed User

    Daestrum,

    Thanks again for your great help. I've been able to produce the basic chart:

    [​IMG]
    but can I ask a few questions?
    • I can't see how the color and shape of the points in each series is set - where is that done?
    • If the line MainForm.RootPane.AddNode(inline.RunMethod("getChart",Null),10,10,310,310) places the scatter chart in the MainForm, how do I remove the chart so it is not visible, but MainForm remains?
    • How can I clear the displayed data with the chart framework remaining so i can display new data, presumably by invoking the line inline.RunMethod("addData",Array(x,y,v))?
    • Would it be possible to set the background of the chart to an image so the scatter points are overlaid on the image?
    Thanks,

    Bryon
     
  4. Daestrum

    Daestrum Well-Known Member Licensed User

    I can answer some of your questions
    1, It is set from css (haven't managed to get this working as I am rubbish at css)
    2, You can change the code slightly to allow for this
    Code:
    .....
        
    Dim sc As Node
        sc = inline.RunMethod(
    "getChart",Null)
        MainForm.RootPane.AddNode(sc,
    10,10,410,410)
    You can then remove the node from mainform as normal
    3, You can use remove function to get rid of a series
    4, Yes you can have an image as a background, again css is used

    This page may be useful https://docs.oracle.com/javafx/2/charts/css-styles.htm
     
  5. bdunkleysmith

    bdunkleysmith Active Member Licensed User

    I thought css may be involved and you've confirmed that for me.

    I've been able to produce a css file (and load it) that sets the shape and color of the points and sets the background of the chart to an image. Dimensioning sc as a node has also allowed me to be able to remove it. So now I've just the implementation of the remove function to get rid of the series.

    Thanks again for your help.
     
  6. Daestrum

    Daestrum Well-Known Member Licensed User

    You can use similar to this
    Code:
    inline.RunMethod("removeSeries1",Null)
    Code:
    public static void removeSeries1(){
        sc.getData().remove(series1);
    }
     
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