javafx.scene.chart.NumberAxis Java Examples

The following examples show how to use javafx.scene.chart.NumberAxis. 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: BubbleChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public BubbleChartSample() {
    NumberAxis xAxis = new NumberAxis("X", 0d, 150d, 20d);

    NumberAxis yAxis = new NumberAxis("Y", 0d, 150d, 20d);

    ObservableList<BubbleChart.Series> bubbleChartData = FXCollections.observableArrayList(
        new BubbleChart.Series("Series 1", FXCollections.observableArrayList(
            new XYChart.Data(30d, 40d, 10d),
            new XYChart.Data(60d, 20d, 13d),
            new XYChart.Data(10d, 90d, 7d),
            new XYChart.Data(100d, 40d, 10d),
            new XYChart.Data(50d, 23d, 5d)))
        ,
        new BubbleChart.Series("Series 2", FXCollections.observableArrayList(
            new XYChart.Data(13d, 100d, 7d),
            new XYChart.Data(20d, 80d, 13d),
            new XYChart.Data(100d, 60d, 10d),
            new XYChart.Data(30d, 40d, 6d),
            new XYChart.Data(50d, 20d, 12d)
        ))
    );

    BubbleChart chart = new BubbleChart(xAxis, yAxis, bubbleChartData);
    getChildren().add(chart);
}
 
Example #2
Source File: LabeledBarChart.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public static LabeledBarChart create(boolean displayCategoryAxis, ChartCoordinate chartCoordinate) {
    CategoryAxis categoryAxis = new CategoryAxis();
    categoryAxis.setSide(Side.BOTTOM);
    categoryAxis.setTickLabelsVisible(displayCategoryAxis);
    categoryAxis.setGapStartAndEnd(true);

    NumberAxis numberAxis = new NumberAxis();
    numberAxis.setSide(Side.LEFT);
    switch (chartCoordinate) {
        case LogarithmicE:
            numberAxis.setTickLabelFormatter(new LogarithmicECoordinate());
            break;
        case Logarithmic10:
            numberAxis.setTickLabelFormatter(new Logarithmic10Coordinate());
            break;
        case SquareRoot:
            numberAxis.setTickLabelFormatter(new SquareRootCoordinate());
            break;
    }

    return new LabeledBarChart(categoryAxis, numberAxis)
            .setChartCoordinate(chartCoordinate);
}
 
Example #3
Source File: OverviewPanel.java    From constellation with Apache License 2.0 6 votes vote down vote up
private AreaChart<Number, Number> createHistogram() {
    // Create the axes:
    xAxis = new NumberAxis();
    yAxis = new NumberAxis();
    yAxis.setAutoRanging(true);
    xAxis.setAutoRanging(false);
    xAxis.setAnimated(false);
    yAxis.setAnimated(false);

    // Create the histogram:
    final AreaChart<Number, Number> chart = new AreaChart<>(xAxis, yAxis);
    chart.setPadding(new Insets(0.0, 0.0, 20.0, 0.0));
    chart.setAnimated(true);

    // Hide non-relevant chart elements:
    chart.setLegendVisible(false);
    chart.setHorizontalGridLinesVisible(false);
    chart.setVerticalGridLinesVisible(false);

    // Set the min height so that elements can be sized to whatever level necessary:
    chart.setMinHeight(0d);

    // Return the newly created histogram:
    return chart;
}
 
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: SwingInterop.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private BarChart createBarChart() {
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames()));
    xAxis.setLabel("Year");

    double tickUnit = tableModel.getTickUnit();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickUnit(tickUnit);
    yAxis.setLabel("Units Sold");

    final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData());
    tableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (e.getType() == TableModelEvent.UPDATE) {
                final int row = e.getFirstRow();
                final int column = e.getColumn();
                final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column);

                Platform.runLater(new Runnable() {
                    public void run() {
                        XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData().get(row);
                        BarChart.Data data = s.getData().get(column);
                        data.setYValue(value);
                    }
                });
            }
        }
    });
    return chart;
}
 
Example #6
Source File: ChartAudioArea.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected AreaChart<Number,Number> createChart() {
    final NumberAxis xAxis = new NumberAxis(0,128,8);
    final NumberAxis yAxis = new NumberAxis(0,50,10);
    final AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis);
    // setup chart
    ac.setId("audioAreaDemo");
    ac.setLegendVisible(false);
    ac.setTitle("Live Audio Spectrum Data");
    ac.setAnimated(false);
    xAxis.setLabel("Frequency Bands");
    yAxis.setLabel("Magnitudes");
    yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB"));
    // add starting data
    XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
    series.setName("Audio Spectrum");
    //noinspection unchecked
    series1Data = new XYChart.Data[(int)xAxis.getUpperBound()];
    for (int i=0; i<series1Data.length; i++) {
        series1Data[i] = new XYChart.Data<Number,Number>(i,50);
        series.getData().add(series1Data[i]);
    }
    ac.getData().add(series);
    return ac;
}
 
Example #7
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 #8
Source File: Histogram.java    From AILibs with GNU Affero General Public License v3.0 6 votes vote down vote up
public Histogram(int n) {
	super(new CategoryAxis(), new NumberAxis());
	this.n = n;
	this.getData().add(series);
	List<Data<String,Number>> values = new ArrayList<>();
	for (int i = 0; i < n; i++) {
		values.add(new Data<>("" + i, 0));
	}
	histogramData = FXCollections.observableList(values);
	series.setData(histogramData);
	((NumberAxis)getYAxis()).setMinorTickVisible(false); // only show integers
	
	/* reasonable layout */
	this.setAnimated(false);
	this.setLegendVisible(false);
	((NumberAxis) getYAxis()).setTickUnit(1);
	((NumberAxis) getYAxis()).setTickLabelFormatter(new IntegerAxisFormatter());
	((NumberAxis) getYAxis()).setMinorTickCount(0);
}
 
Example #9
Source File: DescriptiveStatisticsTimelineView.java    From AILibs with GNU Affero General Public License v3.0 6 votes vote down vote up
public DescriptiveStatisticsTimelineView(final ObservableList<Double> scores) {
	super(new NumberAxis(), new NumberAxis());

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

	// defining a series
	this.scores = scores;
	this.performanceSeries = new Series<>();
	this.getData().add(this.performanceSeries);
	this.update();
	scores.addListener(new ListChangeListener<Double>() {

		@Override
		public void onChanged(final Change<? extends Double> c) {
			DescriptiveStatisticsTimelineView.this.update();
		}
	});
}
 
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: Renderer.java    From strangefx with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void renderMeasuredProbabilities(int[] results) {
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    BarChart<String, Integer> barChart = new BarChart(xAxis, yAxis);
    barChart.setData(getChartData(results));
    barChart.setTitle("Measured probability distribution");
    StackPane root = new StackPane();
    root.getChildren().add(barChart);
    if (myStage != null) {
        Scene oldscene = myStage.getScene();
        VBox box = (VBox)(oldscene.getRoot());
        oldscene.setRoot(new StackPane());
        box.getChildren().add(root);
        Scene newScene = new Scene(box);
        newScene.getStylesheets().add(Main.class.getResource("/styles.css").toExternalForm());
        myStage.setScene(newScene);
    } else {
        Stage stage = new Stage();
        stage.setScene(new Scene(root, 640, 480));
        stage.show();
    }

}
 
Example #12
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 #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: ScatterChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public ScatterChartSample() {
    NumberAxis xAxis = new NumberAxis("X-Axis", 0d, 8.0d, 1.0d);
    NumberAxis yAxis = new NumberAxis("Y-Axis", 0.0d, 5.0d, 1.0d);
    ObservableList<XYChart.Series> data = FXCollections.observableArrayList(
        new ScatterChart.Series("Series 1", FXCollections.<ScatterChart.Data>observableArrayList(
            new XYChart.Data(0.2, 3.5),
            new XYChart.Data(0.7, 4.6),
            new XYChart.Data(1.8, 1.7),
            new XYChart.Data(2.1, 2.8),
            new XYChart.Data(4.0, 2.2),
            new XYChart.Data(4.1, 2.6),
            new XYChart.Data(4.5, 2.0),
            new XYChart.Data(6.0, 3.0),
            new XYChart.Data(7.0, 2.0),
            new XYChart.Data(7.8, 4.0)
        ))
    );
    ScatterChart chart = new ScatterChart(xAxis, yAxis, data);
    getChildren().add(chart);
}
 
Example #15
Source File: AdvancedScatterChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setSide(Side.TOP);
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setSide(Side.RIGHT);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<5;s++) {
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Data Series "+s);
        for (int i=0; i<30; i++) series.getData().add(new XYChart.Data<Number, Number>(Math.random()*98, Math.random()*98));
        sc.getData().add(series);
    }
    return sc;
}
 
Example #16
Source File: AdvancedBubbleChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected BubbleChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final BubbleChart<Number,Number> bc = new BubbleChart<Number,Number>(xAxis,yAxis);
    // setup chart
    bc.setTitle("Advanced BubbleChart");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<Number,Number> series1 = new XYChart.Series<Number,Number>();
    series1.setName("Data Series 1");
    for (int i=0; i<20; i++) series1.getData().add(
            new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
    XYChart.Series<Number,Number> series2 = new XYChart.Series<Number,Number>();
    series2.setName("Data Series 2");
    for (int i=0; i<20; i++) series2.getData().add(
            new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
    bc.getData().addAll(series1, series2);
    return bc;
}
 
Example #17
Source File: AdvancedAreaChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected AreaChart<Number, Number> createChart() {
    NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();
    AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis);
    // setup chart
    ac.setTitle("Area Chart Example");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<3;s++) {
        XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
        series.setName("Data Series "+s);
        double x = 0;
        while (x<95) {
            series.getData().add(new XYChart.Data<Number,Number>(x, Math.random()*99));
            x += 5 + (15*Math.random());
        }
        series.getData().add(new XYChart.Data<Number,Number>(99d, Math.random()*99));
        ac.getData().add(series);
    }
    return ac;
}
 
Example #18
Source File: ChartAdvancedArea.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected AreaChart<Number, Number> createChart() {
    NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();
    AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis);
    // setup chart
    ac.setTitle("Area Chart Example");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<3;s++) {
        XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
        series.setName("Data Series "+s);
        double x = 0;
        while (x<95) {
            series.getData().add(new XYChart.Data<Number,Number>(x, Math.random()*99));
            x += 5 + (15*Math.random());
        }
        series.getData().add(new XYChart.Data<Number,Number>(99d, Math.random()*99));
        ac.getData().add(series);
    }
    return ac;
}
 
Example #19
Source File: ChartAdvancedScatter.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setSide(Side.TOP);
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setSide(Side.RIGHT);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<5;s++) {
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Data Series "+s);
        for (int i=0; i<30; i++) series.getData().add(new XYChart.Data<Number, Number>(Math.random()*98, Math.random()*98));
        sc.getData().add(series);
    }
    return sc;
}
 
Example #20
Source File: BarChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public BarChartSample() {
    String[] years = {"2007", "2008", "2009"};
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(years));
    NumberAxis yAxis = new NumberAxis("Units Sold", 0.0d, 3000.0d, 1000.0d);
    ObservableList<BarChart.Series> barChartData = FXCollections.observableArrayList(
        new BarChart.Series("Apples", FXCollections.observableArrayList(
           new BarChart.Data(years[0], 567d),
           new BarChart.Data(years[1], 1292d),
           new BarChart.Data(years[2], 1292d)
        )),
        new BarChart.Series("Lemons", FXCollections.observableArrayList(
           new BarChart.Data(years[0], 956),
           new BarChart.Data(years[1], 1665),
           new BarChart.Data(years[2], 2559)
        )),
        new BarChart.Series("Oranges", FXCollections.observableArrayList(
           new BarChart.Data(years[0], 1154),
           new BarChart.Data(years[1], 1927),
           new BarChart.Data(years[2], 2774)
        ))
    );
    BarChart chart = new BarChart(xAxis, yAxis, barChartData, 25.0d);
    getChildren().add(chart);
}
 
Example #21
Source File: WordFrequencyApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Parent createContent() {
    StackPane root = new StackPane();
    root.setPrefSize(800, 600);

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

    XYChart.Series<String, Number> series = new XYChart.Series<>();

    extractor.extract()
            .stream()
            .sorted((e1, e2) -> e2.getFrequency() - e1.getFrequency())
            .limit(10)
            .forEach(entry -> {
                series.getData().add(new XYChart.Data<>(entry.getWord(), entry.getFrequency()));
            });

    chart.getData().add(series);

    root.getChildren().add(chart);

    return root;
}
 
Example #22
Source File: BarChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public BarChartSample() {
    String[] years = {"2007", "2008", "2009"};
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(years));
    NumberAxis yAxis = new NumberAxis("Units Sold", 0.0d, 3000.0d, 1000.0d);
    ObservableList<BarChart.Series> barChartData = FXCollections.observableArrayList(
        new BarChart.Series("Apples", FXCollections.observableArrayList(
           new BarChart.Data(years[0], 567d),
           new BarChart.Data(years[1], 1292d),
           new BarChart.Data(years[2], 1292d)
        )),
        new BarChart.Series("Lemons", FXCollections.observableArrayList(
           new BarChart.Data(years[0], 956),
           new BarChart.Data(years[1], 1665),
           new BarChart.Data(years[2], 2559)
        )),
        new BarChart.Series("Oranges", FXCollections.observableArrayList(
           new BarChart.Data(years[0], 1154),
           new BarChart.Data(years[1], 1927),
           new BarChart.Data(years[2], 2774)
        ))
    );
    BarChart chart = new BarChart(xAxis, yAxis, barChartData, 25.0d);
    getChildren().add(chart);
}
 
Example #23
Source File: AdvAreaAudioChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected AreaChart<Number,Number> createChart() {
    final NumberAxis xAxis = new NumberAxis(0,128,8);
    final NumberAxis yAxis = new NumberAxis(0,50,10);
    final AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis);
    // setup chart
    ac.setId("audioAreaDemo");
    ac.setLegendVisible(false);
    ac.setTitle("Live Audio Spectrum Data");
    ac.setAnimated(false);
    xAxis.setLabel("Frequency Bands");
    yAxis.setLabel("Magnitudes");
    yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB"));
    // add starting data
    XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
    series.setName("Audio Spectrum");
    //noinspection unchecked
    series1Data = new XYChart.Data[(int)xAxis.getUpperBound()];
    for (int i=0; i<series1Data.length; i++) {
        series1Data[i] = new XYChart.Data<Number,Number>(i,50);
        series.getData().add(series1Data[i]);
    }
    ac.getData().add(series);
    return ac;
}
 
Example #24
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 #25
Source File: AxisInlierUtils.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static ListChangeListener<XYChart.Data<Number, Number>> getListenerThatZoomsToInliers(
        NumberAxis axis,
        int maxNumberOfTicks,
        double percentToTrim,
        double howManyStdDevsConstituteOutlier
) {
    return change -> {
        boolean axisHasBeenInitialized = axis != null;
        if (axisHasBeenInitialized) {
            zoomToInliers(
                    axis,
                    change.getList(),
                    maxNumberOfTicks,
                    percentToTrim,
                    howManyStdDevsConstituteOutlier
            );
        }
    };
}
 
Example #26
Source File: ScatterChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public ScatterChartSample() {
    NumberAxis xAxis = new NumberAxis("X-Axis", 0d, 8.0d, 1.0d);
    NumberAxis yAxis = new NumberAxis("Y-Axis", 0.0d, 5.0d, 1.0d);
    ObservableList<XYChart.Series> data = FXCollections.observableArrayList(
        new ScatterChart.Series("Series 1", FXCollections.<ScatterChart.Data>observableArrayList(
            new XYChart.Data(0.2, 3.5),
            new XYChart.Data(0.7, 4.6),
            new XYChart.Data(1.8, 1.7),
            new XYChart.Data(2.1, 2.8),
            new XYChart.Data(4.0, 2.2),
            new XYChart.Data(4.1, 2.6),
            new XYChart.Data(4.5, 2.0),
            new XYChart.Data(6.0, 3.0),
            new XYChart.Data(7.0, 2.0),
            new XYChart.Data(7.8, 4.0)
        ))
    );
    ScatterChart chart = new ScatterChart(xAxis, yAxis, data);
    getChildren().add(chart);
}
 
Example #27
Source File: AdvScatterLiveChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setForceZeroInRange(false);
    final NumberAxis yAxis = new NumberAxis(-100,100,10);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    sc.setId("liveScatterChart");
    sc.setTitle("Animated Sine Wave ScatterChart");
    xAxis.setLabel("X Axis");
    xAxis.setAnimated(false);
    yAxis.setLabel("Y Axis");
    yAxis.setAutoRanging(false);
    // add starting data
    series = new ScatterChart.Series<Number,Number>();
    series.setName("Sine Wave");
    series.getData().add(new ScatterChart.Data<Number, Number>(5d, 5d));
    sc.getData().add(series);
    return sc;
}
 
Example #28
Source File: AdvancedScatterChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setSide(Side.TOP);
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setSide(Side.RIGHT);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<5;s++) {
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Data Series "+s);
        for (int i=0; i<30; i++) series.getData().add(new XYChart.Data<Number, Number>(Math.random()*98, Math.random()*98));
        sc.getData().add(series);
    }
    return sc;
}
 
Example #29
Source File: AdvancedBubbleChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected BubbleChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final BubbleChart<Number,Number> bc = new BubbleChart<Number,Number>(xAxis,yAxis);
    // setup chart
    bc.setTitle("Advanced BubbleChart");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<Number,Number> series1 = new XYChart.Series<Number,Number>();
    series1.setName("Data Series 1");
    for (int i=0; i<20; i++) series1.getData().add(
            new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
    XYChart.Series<Number,Number> series2 = new XYChart.Series<Number,Number>();
    series2.setName("Data Series 2");
    for (int i=0; i<20; i++) series2.getData().add(
            new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
    bc.getData().addAll(series1, series2);
    return bc;
}
 
Example #30
Source File: AdvancedAreaChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected AreaChart<Number, Number> createChart() {
    NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();
    AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis);
    // setup chart
    ac.setTitle("Area Chart Example");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<3;s++) {
        XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
        series.setName("Data Series "+s);
        double x = 0;
        while (x<95) {
            series.getData().add(new XYChart.Data<Number,Number>(x, Math.random()*99));
            x += 5 + (15*Math.random());
        }
        series.getData().add(new XYChart.Data<Number,Number>(99d, Math.random()*99));
        ac.getData().add(series);
    }
    return ac;
}