From the course: Data Science for Java Developers
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Displaying a bar chart - Java Tutorial
From the course: Data Science for Java Developers
Displaying a bar chart
- [Instructor] And now comes the time to actually define our graph that we're going to be displaying. So, we're going to start off by creating an axis called CategoryAxis and a CategoryAxis is different than a regular axis mainly just because we're using a BarChart, here. So we're going to say CategoryAxis xAxis = new CategoryAxis() and then we're going to say NumberAxis, this is the yAxis, here, NumberAxis yAxis = new NumberAxis(). And we're going to set the labels for our axis, here. We're going to say xAxis.setLabel and the label for that is going to be Number of cylinders, and the label for our yAxis is going to be Average mpg, okay. And next, we're going to create the BarChart itself now that we have those axis. So, we're going to say BarChart and this is going to be a String and a Number, as the generic types, since once axis is using a string, right, that's this thing, here, and the other one is using a number,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Setting up JavaFX5m 38s
-
(Locked)
Formatting data for a scatterplot7m 55s
-
(Locked)
Displaying a scatterplot5m 22s
-
(Locked)
Multiple datasets on a scatterplot6m 35s
-
(Locked)
Calculating average MPG4m 46s
-
(Locked)
Displaying a bar chart4m 17s
-
(Locked)
Challenge: Displaying data on a bar chart1m 15s
-
(Locked)
Solution: Displaying data on a bar chart4m 8s
-
(Locked)
-
-
-