Created
April 18, 2016 11:17
-
-
Save Sander-Voogt/3aaa50ff860e58eb91d3e575fb83c2a1 to your computer and use it in GitHub Desktop.
This file contains 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
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.chart.*; | |
import javafx.stage.Stage; | |
import java.sql.SQLException; | |
import java.util.ArrayList; | |
public class Query1 { | |
private Database db; | |
private ArrayList<NodeClass> Kweerie1; | |
public Query1(Database db3) throws SQLException { | |
db = db3; | |
String querry = "SELECT b.jaar, (m.Totaal_wegvoertuigen / b.bevolking) as total From motorvoertuigen_rotterdam m, bevolking b Where b.jaar = m.Jaar;"; | |
db.rs = db.stmt.executeQuery(querry); | |
Kweerie1 = new ArrayList<>(); | |
while (db.rs.next()) { | |
Kweerie1.add(new NodeClass("Toename Nederland", db.rs.getInt("b.jaar"))); | |
Kweerie1.add(new NodeClass("Toename Rotterdam", db.rs.getInt("total"))); | |
} | |
} | |
public void display() { | |
Stage stage = new Stage(); | |
stage.setTitle("Linechart"); | |
final CategoryAxis xAxis = new CategoryAxis(); | |
final NumberAxis yAxis = new NumberAxis(); | |
xAxis.setLabel("Month"); | |
yAxis.setLabel("jaaa"); | |
final LineChart<String, Number> lineChart = | |
new LineChart<String, Number>(xAxis, yAxis); | |
lineChart.setTitle("Stock Monitoring, 2010"); | |
XYChart.Series series = new XYChart.Series(); | |
series.setName("My portfolio"); | |
Scene scene = new Scene(lineChart, 800, 600); | |
for (NodeClass Node : this.Kweerie1) { | |
series.getData().add(new XYChart.Data(Node.naam, Node.waarde)); | |
} | |
lineChart.getData().add(series); | |
stage.setScene(scene); | |
stage.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment