JavaFX Area Chart Example

JavaFX Area Chart Example :

 


import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.XYChart;
import javafx.scene.effect.BlurType;
import javafx.scene.effect.DropShadow;
import javafx.scene.paint.Color;
import javafx.scene.chart.AreaChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;

 /**
 *
 * @author wordpress.JavaFXtuts.com
 */
public class Javafxtuts extends Application {
 public static void main(String[] args) {
 launch(args);
 }
 
 @Override
 public void start(Stage primaryStage) {
 Group root = new Group();
 
 CategoryAxis xAxis = new CategoryAxis();
 NumberAxis yAxis = new NumberAxis();
 
 xAxis.setLabel("Year");
 yAxis.setLabel("Price");
 
 AreaChart<String,Number> areaChart = new AreaChart<String,Number>(xAxis,yAxis);
 
 areaChart.setTitle("Area Chart");
 XYChart.Series series = new XYChart.Series();
 series.setName("XYChart.Series");
 
 series.getData().add(new XYChart.Data("2011", 120));
 series.getData().add(new XYChart.Data("2012", 180));
 series.getData().add(new XYChart.Data("2013", 80));
 series.getData().add(new XYChart.Data("2014", 100));
 series.getData().add(new XYChart.Data("2015", 200));
 series.getData().add(new XYChart.Data("2016", 50));

 
 areaChart.getData().add(series);
 
 root.getChildren().add(areaChart);
 
 primaryStage.setScene(new Scene(root, 500, 400));
 primaryStage.show();
 }
 
}

 JavaFX Area Chart Example Output :

JavaFX Area Chart Example

 

Learn More about JavaFX Area Chart  At JavaFX Area Chart

More JavaFX Chart :

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s