Created
May 11, 2021 18:55
-
-
Save Da9el00/628d84f1556e4ad852aa78167346fc4a to your computer and use it in GitHub Desktop.
JavaFX and Scene Builder BubbleChart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package sample; | |
| import javafx.fxml.FXML; | |
| import javafx.fxml.Initializable; | |
| import javafx.scene.chart.BubbleChart; | |
| import javafx.scene.chart.XYChart; | |
| import java.net.URL; | |
| import java.util.ResourceBundle; | |
| public class Controller implements Initializable { | |
| @FXML | |
| private BubbleChart<Integer, Integer> bubbleChart; | |
| XYChart.Series series1 = new XYChart.Series(); | |
| XYChart.Series series2 = new XYChart.Series(); | |
| @Override | |
| public void initialize(URL url, ResourceBundle resourceBundle) { | |
| bubbleChart.getXAxis().setLabel("Week"); | |
| bubbleChart.getYAxis().setLabel("Budget"); | |
| series1.setName("Product"); | |
| series1.getData().add(new XYChart.Data(1, 35)); | |
| series1.getData().add(new XYChart.Data(13, 67, 7)); | |
| series1.getData().add(new XYChart.Data(22, 24)); | |
| series1.getData().add(new XYChart.Data(24, 12)); | |
| series1.getData().add(new XYChart.Data(42, 5)); | |
| series1.getData().add(new XYChart.Data(45, 5)); | |
| series1.getData().add(new XYChart.Data(49, 32)); | |
| series1.getData().add(new XYChart.Data(50, 44)); | |
| series2.setName("Product_2"); | |
| series2.getData().add(new XYChart.Data(12, 33)); | |
| series2.getData().add(new XYChart.Data(13, 23, 7)); | |
| series2.getData().add(new XYChart.Data(43, 12)); | |
| series2.getData().add(new XYChart.Data(23, 43)); | |
| series2.getData().add(new XYChart.Data(43, 34)); | |
| series2.getData().add(new XYChart.Data(12, 33)); | |
| series2.getData().add(new XYChart.Data(43, 3)); | |
| series2.getData().add(new XYChart.Data(11, 41)); | |
| bubbleChart.getData().addAll(series1, series2); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment