javafx.scene.chart.LineChart Java Examples

The following examples show how to use javafx.scene.chart.LineChart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultipleAxesLineChart.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private Node resizeBackgroundChart(final LineChart<?, ?> lineChart) {
    final HBox hBox = new HBox(lineChart);
    hBox.setAlignment(Pos.CENTER_LEFT);
    hBox.prefHeightProperty().bind(heightProperty());
    hBox.prefWidthProperty().bind(widthProperty());
    hBox.setMouseTransparent(true);

    lineChart.minWidthProperty()
            .bind(widthProperty().subtract((yAxisWidth + yAxisSeparation) * backgroundCharts.size()));
    lineChart.prefWidthProperty()
            .bind(widthProperty().subtract((yAxisWidth + yAxisSeparation) * backgroundCharts.size()));
    lineChart.maxWidthProperty()
            .bind(widthProperty().subtract((yAxisWidth + yAxisSeparation) * backgroundCharts.size()));

    lineChart.translateXProperty().bind(baseChart.getYAxis().widthProperty());
    lineChart.getYAxis().setTranslateX((yAxisWidth + yAxisSeparation) * backgroundCharts.indexOf(lineChart));
    lineChart.getXAxis().tickLabelRotationProperty().bind(baseChart.getXAxis().tickLabelRotationProperty());
    return hBox;
}
 
Example #2
Source File: OpcDaTagValueChart.java    From OEE-Designer with MIT License 6 votes vote down vote up
public LineChart<Number, Number> createChart() {

		tagValueChart.setId(chartId);
		tagValueChart.setCreateSymbols(true);
		tagValueChart.setAnimated(false);
		tagValueChart.setLegendVisible(false);

		xAxis.setLabel(xAxisLabel);
		xAxis.setForceZeroInRange(false);
		yAxis.setLabel(yAxisLabel);
		yAxis.setAutoRanging(true);

		valueDataSeries.setName(seriesName);
		tagValueChart.getData().add(valueDataSeries);

		reset(title);

		return tagValueChart;
	}
 
Example #3
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
private void displayIndex(Map<String, Double> resultIndex, String title, String header) {
    BaseDialog dialog = new BaseDialog(title, header);
    dialog.getDialogPane().setPrefSize(800, 600);
    dialog.getDialogPane().getButtonTypes().addAll(new ButtonType(Configuration.getBundle().getString("ui.actions.stats.close"), ButtonBar.ButtonData.CANCEL_CLOSE));

    // draw
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<String,Number> lineChart = new LineChart<>(xAxis, yAxis);
    lineChart.setTitle(title);
    lineChart.setLegendVisible(false);

    xAxis.setLabel(Configuration.getBundle().getString("ui.actions.stats.xaxis"));
    yAxis.setLabel(Configuration.getBundle().getString("ui.actions.readable.yaxis"));

    XYChart.Series<String, Number> series = new XYChart.Series();
    for(Map.Entry<String, Double> st:resultIndex.entrySet()) {
        series.getData().add(new XYChart.Data(st.getKey(), st.getValue()));
    }
    lineChart.getData().addAll(series);
    dialog.getDialogPane().setContent(lineChart);
    dialog.setResizable(true);
    dialog.showAndWait();
}
 
Example #4
Source File: AdvancedLineChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected LineChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<Number,Number> lc = new LineChart<Number,Number>(xAxis,yAxis);
    // setup chart
    lc.setTitle("Basic LineChart");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
    series.setName("Data Series 1");
    series.getData().add(new XYChart.Data<Number,Number>(20d, 50d));
    series.getData().add(new XYChart.Data<Number,Number>(40d, 80d));
    series.getData().add(new XYChart.Data<Number,Number>(50d, 90d));
    series.getData().add(new XYChart.Data<Number,Number>(70d, 30d));
    series.getData().add(new XYChart.Data<Number,Number>(170d, 122d));
    lc.getData().add(series);
    return lc;
}
 
Example #5
Source File: MultipleAxesLineChart.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private void styleBackgroundChart(final LineChart<?, ?> lineChart, final Color lineColor) {
    styleChartLine(lineChart, lineColor);

    final Node chartContent = lineChart.lookup(".chart-content");
    if (chartContent != null) {
        final Node chartPlotBackground = chartContent.lookup(".chart-plot-background");
        if (chartPlotBackground != null) {
            chartPlotBackground.setStyle("-fx-background-color: transparent;");
        }
    }

    lineChart.setVerticalZeroLineVisible(false);
    lineChart.setHorizontalZeroLineVisible(false);
    lineChart.setVerticalGridLinesVisible(false);
    lineChart.setHorizontalGridLinesVisible(false);
    lineChart.setCreateSymbols(false);
}
 
Example #6
Source File: AdvLineCategoryChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected LineChart<String, Number> createChart() {
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<String,Number> lc = new LineChart<String,Number>(xAxis,yAxis);
    // setup chart
    lc.setTitle("LineChart with Category Axis");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<String,Number> series = new XYChart.Series<String,Number>();
    series.setName("Data Series 1");
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[0], 50d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[1], 80d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[2], 90d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[3], 30d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[4], 122d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[5], 10d));
    lc.getData().add(series);
    return lc;
}
 
Example #7
Source File: LineChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public LineChartSample() {
    NumberAxis xAxis = new NumberAxis("Values for X-Axis", 0, 3, 1);
    NumberAxis yAxis = new NumberAxis("Values for Y-Axis", 0, 3, 1);
    ObservableList<XYChart.Series<Double,Double>> lineChartData = FXCollections.observableArrayList(
        new LineChart.Series<Double,Double>("Series 1", FXCollections.observableArrayList(
            new XYChart.Data<Double,Double>(0.0, 1.0),
            new XYChart.Data<Double,Double>(1.2, 1.4),
            new XYChart.Data<Double,Double>(2.2, 1.9),
            new XYChart.Data<Double,Double>(2.7, 2.3),
            new XYChart.Data<Double,Double>(2.9, 0.5)
        )),
        new LineChart.Series<Double,Double>("Series 2", FXCollections.observableArrayList(
            new XYChart.Data<Double,Double>(0.0, 1.6),
            new XYChart.Data<Double,Double>(0.8, 0.4),
            new XYChart.Data<Double,Double>(1.4, 2.9),
            new XYChart.Data<Double,Double>(2.1, 1.3),
            new XYChart.Data<Double,Double>(2.6, 0.9)
        ))
    );
    LineChart chart = new LineChart(xAxis, yAxis, lineChartData);
    getChildren().add(chart);
}
 
Example #8
Source File: AdvancedLineChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected LineChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<Number,Number> lc = new LineChart<Number,Number>(xAxis,yAxis);
    // setup chart
    lc.setTitle("Basic LineChart");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
    series.setName("Data Series 1");
    series.getData().add(new XYChart.Data<Number,Number>(20d, 50d));
    series.getData().add(new XYChart.Data<Number,Number>(40d, 80d));
    series.getData().add(new XYChart.Data<Number,Number>(50d, 90d));
    series.getData().add(new XYChart.Data<Number,Number>(70d, 30d));
    series.getData().add(new XYChart.Data<Number,Number>(170d, 122d));
    lc.getData().add(series);
    return lc;
}
 
Example #9
Source File: Main.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static Chart plotFunction(List<Function<Double, Double>> functions, Number xStart, Number xEnd) {
    int div = 500;
    double x0 = xStart.doubleValue();
    double x1 = xEnd.doubleValue();
    double step = 1./div* (x1-x0);
    Axis<Number> xAxis = new NumberAxis(x0, x1, .1* (x1-x0));
    Axis<Number> yAxis = new NumberAxis();
    ObservableList<XYChart.Series<Number, Number>> series = FXCollections.observableArrayList();
    LineChart<Number,Number> chart = new LineChart(xAxis, yAxis, series);
    chart.setCreateSymbols(false);
    for (Function<Double, Double> f: functions) {
        XYChart.Series<Number, Number> mainSeries = new XYChart.Series();
        series.add(mainSeries);
        ObservableList<XYChart.Data<Number, Number>> data = FXCollections.observableArrayList();
        mainSeries.setData(data);
        for (double x = x0; x < x1; x= x +step) {
            final Number y = f.apply(x);
            data.add(new XYChart.Data<>(x,y));
        }
    }
    return chart;

}
 
Example #10
Source File: AdvLineCategoryChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected LineChart<String, Number> createChart() {
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<String,Number> lc = new LineChart<String,Number>(xAxis,yAxis);
    // setup chart
    lc.setTitle("LineChart with Category Axis");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<String,Number> series = new XYChart.Series<String,Number>();
    series.setName("Data Series 1");
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[0], 50d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[1], 80d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[2], 90d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[3], 30d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[4], 122d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[5], 10d));
    lc.getData().add(series);
    return lc;
}
 
Example #11
Source File: SinChartComponent.java    From spring-labs with Apache License 2.0 6 votes vote down vote up
public SinChartComponent() {

    NumberAxis xAxis = new NumberAxis();
    xAxis.setLabel("x");

    NumberAxis yAxis = new NumberAxis();
    yAxis.setLabel("y");

    XYChart.Series<Number, Number> series = new XYChart.Series<>();
    series.setName("Sine");

    ObservableList<XYChart.Data<Number, Number>> data = series.getData();

    for (double x = -Math.PI; x < Math.PI; x += 0.5) {
      data.add(new XYChart.Data<Number, Number>(x, 10 * Math.sin(x)));
    }

    LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);
    lineChart.setTitle("Sine function");
    lineChart.getData().add(series);

    getChildren().add(lineChart);
  }
 
Example #12
Source File: MultipleAxesLineChart.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
public MultipleAxesLineChart(final LineChart<?, ?> baseChart, final Color lineColor, final Double strokeWidth) {
    if (strokeWidth != null) {
        this.strokeWidth = strokeWidth;
    }
    this.baseChart = baseChart;

    chartColorMap.put(baseChart, lineColor);

    styleBaseChart(baseChart);
    styleChartLine(baseChart, lineColor);
    setFixedAxisWidth(baseChart);

    setAlignment(Pos.CENTER_LEFT);

    backgroundCharts.addListener((final Observable observable) -> rebuildChart());

    detailsWindow = new AnchorPane();
    bindMouseEvents(baseChart, this.strokeWidth);

    rebuildChart();
}
 
Example #13
Source File: LineChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public LineChartSample() {
    NumberAxis xAxis = new NumberAxis("Values for X-Axis", 0, 3, 1);
    NumberAxis yAxis = new NumberAxis("Values for Y-Axis", 0, 3, 1);
    ObservableList<XYChart.Series<Double,Double>> lineChartData = FXCollections.observableArrayList(
        new LineChart.Series<Double,Double>("Series 1", FXCollections.observableArrayList(
            new XYChart.Data<Double,Double>(0.0, 1.0),
            new XYChart.Data<Double,Double>(1.2, 1.4),
            new XYChart.Data<Double,Double>(2.2, 1.9),
            new XYChart.Data<Double,Double>(2.7, 2.3),
            new XYChart.Data<Double,Double>(2.9, 0.5)
        )),
        new LineChart.Series<Double,Double>("Series 2", FXCollections.observableArrayList(
            new XYChart.Data<Double,Double>(0.0, 1.6),
            new XYChart.Data<Double,Double>(0.8, 0.4),
            new XYChart.Data<Double,Double>(1.4, 2.9),
            new XYChart.Data<Double,Double>(2.1, 1.3),
            new XYChart.Data<Double,Double>(2.6, 0.9)
        ))
    );
    LineChart chart = new LineChart(xAxis, yAxis, lineChartData);
    getChildren().add(chart);
}
 
Example #14
Source File: IndexChart - MainApp.java    From Java-for-Data-Science with MIT License 6 votes vote down vote up
public void simpleIndexChart(Stage stage) {
    stage.setTitle("Index Chart");
    final LineChart<String, Number> lineChart
            = new LineChart<>(xAxis, yAxis);
    lineChart.setTitle("Belgium Population");
    yAxis.setLabel("Population");

    series.setName("Population");
    addDataItem(series, "1950", 8639369);
    addDataItem(series, "1960", 9118700);
    addDataItem(series, "1970", 9637800);
    addDataItem(series, "1980", 9846800);
    addDataItem(series, "1990", 9969310);
    addDataItem(series, "2000", 10263618);

    Scene scene = new Scene(lineChart, 800, 600);
    lineChart.getData().add(series);
    stage.setScene(scene);
    stage.show();
}
 
Example #15
Source File: ChartLine.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    NumberAxis xAxis = new NumberAxis("Values for X-Axis", 0, 3, 1);
    NumberAxis yAxis = new NumberAxis("Values for Y-Axis", 0, 3, 1);
    ObservableList<XYChart.Series<Double,Double>> lineChartData = FXCollections.observableArrayList(
        new LineChart.Series<Double,Double>("Series 1", FXCollections.observableArrayList(
            new XYChart.Data<Double,Double>(0.0, 1.0),
            new XYChart.Data<Double,Double>(1.2, 1.4),
            new XYChart.Data<Double,Double>(2.2, 1.9),
            new XYChart.Data<Double,Double>(2.7, 2.3),
            new XYChart.Data<Double,Double>(2.9, 0.5)
        )),
        new LineChart.Series<Double,Double>("Series 2", FXCollections.observableArrayList(
            new XYChart.Data<Double,Double>(0.0, 1.6),
            new XYChart.Data<Double,Double>(0.8, 0.4),
            new XYChart.Data<Double,Double>(1.4, 2.9),
            new XYChart.Data<Double,Double>(2.1, 1.3),
            new XYChart.Data<Double,Double>(2.6, 0.9)
        ))
    );
    LineChart chart = new LineChart(xAxis, yAxis, lineChartData);
    root.getChildren().add(chart);
}
 
Example #16
Source File: ChooseParkingSlotController.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
@FXML
public void showDistanceChartButtonClicked(ActionEvent event) throws Exception{
	
	 Stage s = new Stage();
        //Fill stage with content
		s.setTitle("Price - Distance graph");
        final NumberAxis xAxis = new NumberAxis(), yAxis = new NumberAxis();
        xAxis.setLabel("Distance");
        yAxis.setLabel("Price");

        //creating the chart
        final LineChart<Number,Number> lineChart = new LineChart<Number,Number>(xAxis,yAxis);
                
        lineChart.setTitle("Price - Distance");
        
        //defining a series
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Price - Distance");
        
        //get data to present
        Graph g = new Graph();
        Map<Double, Double> data = g.CreatePriceDistanceData(getSelectedDestination());

        //populating the series with data
        for (Map.Entry<Double, Double> entry : data.entrySet()){
        	Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info("distance: "+ entry.getKey() + " price: " + entry.getValue());
        	series.getData().add(new Data<Number, Number>(entry.getKey(), entry.getValue()));
        }
	        
        Scene scene  = new Scene(lineChart,800,600);
        lineChart.getData().addAll(series);
       
        s.setScene(scene);
        s.show();
}
 
Example #17
Source File: ChartAdvancedStockLine.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected LineChart<Number, Number> createChart() {
    xAxis = new NumberAxis(0,24,3);
    final NumberAxis yAxis = new NumberAxis(0,100,10);
    final LineChart<Number,Number> lc = new LineChart<Number,Number>(xAxis,yAxis);
    // setup chart
    lc.setId("lineStockDemo");
    lc.setCreateSymbols(false);
    lc.setAnimated(false);
    lc.setLegendVisible(false);
    lc.setTitle("ACME Company Stock");
    xAxis.setLabel("Time");
    xAxis.setForceZeroInRange(false);
    yAxis.setLabel("Share Price");
    yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,"$",null));
    // add starting data
    hourDataSeries = new XYChart.Series<Number,Number>();
    hourDataSeries.setName("Hourly Data");
    minuteDataSeries = new XYChart.Series<Number,Number>();
    minuteDataSeries.setName("Minute Data");
    // create some starting data
    hourDataSeries.getData().add(new XYChart.Data<Number,Number>(timeInHours,prevY));
    minuteDataSeries.getData().add(new XYChart.Data<Number,Number>(timeInHours,prevY));
    for (double m=0; m<(60); m++) {
        nextTime();
        plotTime();
    }
    lc.getData().add(minuteDataSeries);
    lc.getData().add(hourDataSeries);
    return lc;
}
 
Example #18
Source File: OutOfSampleErrorPlotPluginView.java    From AILibs with GNU Affero General Public License v3.0 5 votes vote down vote up
public OutOfSampleErrorPlotPluginView(OutOfSampleErrorPlotPluginModel model) {
	super(model, new LineChart<>(new NumberAxis(), new NumberAxis()));
	getNode().getXAxis().setLabel("elapsed time (s)");
	getNode().setTitle(getTitle());
	believedErrorSeries = new Series<>();
	believedErrorSeries.setName("Believed (internal) Error");
	outOfSampleErrorSeries = new Series<>();
	outOfSampleErrorSeries.setName("Out-of-Sample Error");
	getNode().getData().add(believedErrorSeries);
	getNode().getData().add(outOfSampleErrorSeries);
}
 
Example #19
Source File: SolutionPerformanceTimelinePluginView.java    From AILibs with GNU Affero General Public License v3.0 5 votes vote down vote up
public SolutionPerformanceTimelinePluginView(final SolutionPerformanceTimelinePluginModel model) {
	super(model, new LineChart<>(new NumberAxis(), new NumberAxis()));

	// defining the axes
	this.getNode().getXAxis().setLabel("elapsed time (s)");

	// creating the chart
	this.getNode().setTitle(this.getTitle());
	// defining a series
	this.performanceSeries = new Series<>();
	this.getNode().getData().add(this.performanceSeries);
}
 
Example #20
Source File: RattingGraph.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void start(Stage s) throws Exception {
	s.setTitle("Price - Distance graph");
       final NumberAxis xAxis = new NumberAxis(), yAxis = new NumberAxis();
       xAxis.setLabel("Ratting");
       yAxis.setLabel("Price");

       //creating the chart
       final LineChart<Number,Number> lineChart = new LineChart<Number,Number>(xAxis,yAxis);
               
       lineChart.setTitle("Price - Ratting");
       
       //defining a series
       XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
       series.setName("Price - Ratting");
       
       //get data to present
       Graph g = new Graph();
       Map<Double, Double> data = g.CreatePriceRanttingData(dest);

       //populating the series with data
       for (Map.Entry<Double, Double> entry : data.entrySet()){
       	LOGGER.info("ratting: "+ entry.getKey() + " price: " + entry.getValue());
       	series.getData().add(new Data<Number, Number>(entry.getKey(), entry.getValue()));
       }
        
       Scene scene  = new Scene(lineChart,800,600);
       lineChart.getData().addAll(series);
      
       s.setScene(scene);
       s.show();
	
}
 
Example #21
Source File: ChooseParkingSlotController.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
@FXML
public void showRatingChartButtonClicked(ActionEvent event) throws Exception{
	Stage s = new Stage();
	s.setTitle("Price - Rating graph");
       final NumberAxis xAxis = new NumberAxis(), yAxis = new NumberAxis();
       xAxis.setLabel("Rating");
       yAxis.setLabel("Price");

       //creating the chart
       final LineChart<Number,Number> lineChart = new LineChart<Number,Number>(xAxis,yAxis);
               
       lineChart.setTitle("Price - Rating");
       
       //defining a series
       XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
       series.setName("Price - Rating");
       
       //get data to present
       Graph g = new Graph();
       Map<Double, Double> data = g.CreatePriceRanttingData(getSelectedDestination());

       //populating the series with data
       for (Map.Entry<Double, Double> entry : data.entrySet()){
       	Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info("rating: "+ entry.getKey() + " price: " + entry.getValue());
       	series.getData().add(new Data<Number, Number>(entry.getKey(), entry.getValue()));
       }
        
       Scene scene  = new Scene(lineChart,800,600);
       lineChart.getData().addAll(series);
      
       s.setScene(scene);
       s.show();
}
 
Example #22
Source File: AdvancedStockLineChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected LineChart<Number, Number> createChart() {
    xAxis = new NumberAxis(0,24,3);
    final NumberAxis yAxis = new NumberAxis(0,100,10);
    final LineChart<Number,Number> lc = new LineChart<Number,Number>(xAxis,yAxis);
    // setup chart
    lc.setId("lineStockDemo");
    lc.setCreateSymbols(false);
    lc.setAnimated(false);
    lc.setLegendVisible(false);
    lc.setTitle("ACME Company Stock");
    xAxis.setLabel("Time");
    xAxis.setForceZeroInRange(false);
    yAxis.setLabel("Share Price");
    yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,"$",null));
    // add starting data
    hourDataSeries = new XYChart.Series<Number,Number>();
    hourDataSeries.setName("Hourly Data");
    minuteDataSeries = new XYChart.Series<Number,Number>();
    minuteDataSeries.setName("Minute Data");
    // create some starting data
    hourDataSeries.getData().add(new XYChart.Data<Number,Number>(timeInHours,prevY));
    minuteDataSeries.getData().add(new XYChart.Data<Number,Number>(timeInHours,prevY));
    for (double m=0; m<(60); m++) {
        nextTime();
        plotTime();
    }
    lc.getData().add(minuteDataSeries);
    lc.getData().add(hourDataSeries);
    return lc;
}
 
Example #23
Source File: DistanceGraph.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void start(Stage s) throws Exception {
	s.setTitle("Price - Distance graph");
       final NumberAxis xAxis = new NumberAxis(), yAxis = new NumberAxis();
       xAxis.setLabel("Distance");
       yAxis.setLabel("Price");

       //creating the chart
       final LineChart<Number,Number> lineChart = new LineChart<Number,Number>(xAxis,yAxis);
               
       lineChart.setTitle("Price - Distance");
       
       //defining a series
       XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
       series.setName("Price - Distance");
       
       //get data to present
       Graph g = new Graph();
       Map<Double, Double> data = g.CreatePriceDistanceData(dest);

       //populating the series with data
       for (Map.Entry<Double, Double> entry : data.entrySet()){
       	LOGGER.info("distance: "+ entry.getKey() + " price: " + entry.getValue());
       	series.getData().add(new Data<Number, Number>(entry.getKey(), entry.getValue()));
       }
        
       Scene scene  = new Scene(lineChart,800,600);
       lineChart.getData().addAll(series);
      
       s.setScene(scene);
       s.show();
	
}
 
Example #24
Source File: ManageGroupsManager.java    From youtube-comment-suite with MIT License 5 votes vote down vote up
private void installDataTooltip(Tooltip tooltip, Node node, LineChart.Data<?, ?> dataPoint) {
    node.setStyle("-fx-background-color: transparent;");
    node.setOnMouseEntered(e -> node.setStyle("-fx-background-color: orangered;"));
    node.setOnMouseExited(e -> node.setStyle("-fx-background-color: transparent;"));

    Tooltip.install(node, tooltip);

    dataPoint.setNode(node);
}
 
Example #25
Source File: TrainingView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Chart createChart(Series<Integer, Double> series) {
    NumberAxis xAxis = new NumberAxis();
    xAxis.setUpperBound(620d);
    xAxis.setMinorTickCount(25);
    xAxis.setTickUnit(100);
    xAxis.setAutoRanging(false);
    NumberAxis yAxis = new NumberAxis();
    LineChart answer = new LineChart(xAxis, yAxis);
    answer.setTitle("score evolution");
    answer.setCreateSymbols(false);
    ObservableList<XYChart.Series<Integer, Double>> data = FXCollections.observableArrayList();
    data.add(series);
    answer.setData(data);
    return answer;
}
 
Example #26
Source File: BreakingNewsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 5 votes vote down vote up
public LineChart<String, Number> createChart(LabelledRadiusPane pane) {
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    
    chart = new LineChart<>(xAxis, yAxis);
    chart.setTitle("Tweet Trend Analysis");
    chart.setCreateSymbols(false);
    chart.setLegendVisible(false);

    xAxis.setLabel("Time of Tweet");
    yAxis.setUpperBound(1.0);
    yAxis.setLowerBound(0.0);
    yAxis.setLabel("Anomaly\n  Score");
    yAxis.setForceZeroInRange(true);
    
    series = new XYChart.Series<>();
    series.setName("Tweet Data");
    chart.getData().add(series);
    chartSeriesProperty.set(series);
    
    Node line = series.getNode().lookup(".chart-series-line");
    line.setStyle("-fx-stroke: rgb(20, 164, 220)");
    
    chart.setPrefWidth(1200);
    chart.setPrefHeight(275);
    chart.setLayoutY(pane.labelHeightProperty().get() + 10);
    
    return chart;
}
 
Example #27
Source File: CommitVisualizer.java    From FXTutorials with MIT License 5 votes vote down vote up
private Parent createContent() {
    StackPane root = new StackPane();
    root.setPrefSize(800, 600);

    LineChart<String, Number> chart = new LineChart<>(
            new CategoryAxis(), new NumberAxis()
    );

    chart.getData().add(extract(Paths.get("log1.txt"), "Project 1"));
    chart.getData().add(extract(Paths.get("log2.txt"), "Project 2"));

    root.getChildren().add(chart);

    return root;
}
 
Example #28
Source File: SupplyView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private Node createBSQIssuedVsBurntChart(
        XYChart.Series<Number, Number> seriesBSQIssuedMonthly,
        XYChart.Series<Number, Number> seriesBSQBurntMonthly
) {
    Supplier<NumberAxis> makeXAxis = () -> {
        NumberAxis xAxis = new NumberAxis();
        configureAxis(xAxis);
        xAxis.setTickLabelFormatter(getTimestampTickLabelFormatter("MMM uu"));
        return xAxis;
    };

    Supplier<NumberAxis> makeYAxis = () -> {
        NumberAxis yAxis = new NumberAxis();
        configureYAxis(yAxis);
        yAxis.setTickLabelFormatter(BSQPriceTickLabelFormatter);
        return yAxis;
    };

    var chart = new LineChart<>(makeXAxis.get(), makeYAxis.get());

    configureChart(chart);
    chart.setCreateSymbols(false);

    chart.getData().addAll(List.of(seriesBSQIssuedMonthly, seriesBSQBurntMonthly));

    chart.setLegendVisible(true);

    return chart;
}
 
Example #29
Source File: EventDetectionUI.java    From SONDY with GNU General Public License v3.0 5 votes vote down vote up
public final void initializeFrequencyChart(){
    xAxis = new NumberAxis(0,1,1);
    yAxis = new NumberAxis();
    xAxis.setTickLength(5);
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarkVisible(false);
    xAxis.setLabel("Time (days)");
    frequencyChart = new LineChart<>(xAxis,yAxis);
    frequencyChart.setLegendVisible(true);
    frequencyChart.setCreateSymbols(false);
    frequencyChart.setTranslateX(-5);
    UIUtils.setSize(frequencyChart, Main.columnWidthLEFT+5, 300);
}
 
Example #30
Source File: LineChartBuilderService.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
@Override
protected XYChart<String, Number> createXYChart() {
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final XYChart<String, Number> chart = new LineChart<String, Number>(xAxis, yAxis);
    chart.getStyleClass().add("chart-extension");
    return chart;
}