bdunkleysmith Active Member Licensed User Longtime User Apr 24, 2015 #1 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
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
Daestrum Expert Licensed User Longtime User Apr 24, 2015 #2 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. Attachments scatterchart example.zip scatterchart example.zip 1.2 KB · Views: 451 Upvote 0
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.
bdunkleysmith Active Member Licensed User Longtime User Apr 25, 2015 #3 Daestrum, Thanks again for your great help. I've been able to produce the basic chart: 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 Upvote 0
Daestrum, Thanks again for your great help. I've been able to produce the basic chart: 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
Daestrum Expert Licensed User Longtime User Apr 25, 2015 #4 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: Copy ..... 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 Upvote 0
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: Copy ..... 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
bdunkleysmith Active Member Licensed User Longtime User Apr 25, 2015 #5 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. Upvote 0
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.
Daestrum Expert Licensed User Longtime User Apr 25, 2015 #6 You can use similar to this Code: Copy inline.RunMethod("removeSeries1",Null) Code: Copy public static void removeSeries1(){ sc.getData().remove(series1); } Upvote 0
You can use similar to this Code: Copy inline.RunMethod("removeSeries1",Null) Code: Copy public static void removeSeries1(){ sc.getData().remove(series1); }