Java Code Examples for javafx.scene.chart.NumberAxis#setLabel()

The following examples show how to use javafx.scene.chart.NumberAxis#setLabel() . 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: 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 2
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 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: 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 5
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 6
Source File: ChartAdvancedScatterLive.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.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 7
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 8
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 9
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 10
Source File: AdvHorizontalBarChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected BarChart<Number, String> createChart() {
    final String[] years = {"2007", "2008", "2009"};
    final CategoryAxis yAxis = new CategoryAxis();
    final NumberAxis xAxis = new NumberAxis();
    final BarChart<Number,String> bc = new BarChart<Number,String>(xAxis,yAxis);
    // setup chart
    bc.setTitle("Horizontal Bar Chart Example");
    yAxis.setLabel("Year");
    yAxis.setCategories(FXCollections.<String>observableArrayList(Arrays.asList(years)));
    xAxis.setLabel("Price");
    // add starting data
    XYChart.Series<Number,String> series1 = new XYChart.Series<Number,String>();
    series1.setName("Data Series 1");
    XYChart.Series<Number,String> series2 = new XYChart.Series<Number,String>();
    series2.setName("Data Series 2");
    XYChart.Series<Number,String> series3 = new XYChart.Series<Number,String>();
    series3.setName("Data Series 3");
    series1.getData().add(new XYChart.Data<Number,String>(567, years[0]));
    series1.getData().add(new XYChart.Data<Number,String>(1292, years[1]));
    series1.getData().add(new XYChart.Data<Number,String>(2180, years[2]));
    series2.getData().add(new XYChart.Data<Number,String>(956, years[0]));
    series2.getData().add(new XYChart.Data<Number,String>(1665, years[1]));
    series2.getData().add(new XYChart.Data<Number,String>(2450, years[2]));
    series3.getData().add(new XYChart.Data<Number,String>(800, years[0]));
    series3.getData().add(new XYChart.Data<Number,String>(1000, years[1]));
    series3.getData().add(new XYChart.Data<Number,String>(2800, years[2]));
    bc.getData().add(series1);
    bc.getData().add(series2);
    bc.getData().add(series3);
    return bc;
}
 
Example 11
Source File: MultipleAxesLineChart.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
public void addSeries(final XYChart.Series<Number, Number> series, final Color lineColor) {
    final NumberAxis yAxis = new NumberAxis();
    final NumberAxis xAxis = new NumberAxis();

    // style x-axis
    xAxis.setAutoRanging(false);
    xAxis.setVisible(false);
    xAxis.setOpacity(0.0); // somehow the upper setVisible does not work
    xAxis.lowerBoundProperty().bind(((NumberAxis) baseChart.getXAxis()).lowerBoundProperty());
    xAxis.upperBoundProperty().bind(((NumberAxis) baseChart.getXAxis()).upperBoundProperty());
    xAxis.tickUnitProperty().bind(((NumberAxis) baseChart.getXAxis()).tickUnitProperty());

    // style y-axis
    yAxis.setSide(Side.RIGHT);
    yAxis.setLabel(series.getName());

    // create chart
    final LineChart<Number, Number> lineChart = new LineChart<>(xAxis, yAxis);
    lineChart.setAnimated(false);
    lineChart.setLegendVisible(false);
    lineChart.getData().add(series);

    styleBackgroundChart(lineChart, lineColor);
    setFixedAxisWidth(lineChart);

    chartColorMap.put(lineChart, lineColor);
    backgroundCharts.add(lineChart);
}
 
Example 12
Source File: AdvHorizontalBarChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected BarChart<Number, String> createChart() {
    final String[] years = {"2007", "2008", "2009"};
    final CategoryAxis yAxis = new CategoryAxis();
    final NumberAxis xAxis = new NumberAxis();
    final BarChart<Number,String> bc = new BarChart<Number,String>(xAxis,yAxis);
    // setup chart
    bc.setTitle("Horizontal Bar Chart Example");
    yAxis.setLabel("Year");
    yAxis.setCategories(FXCollections.<String>observableArrayList(Arrays.asList(years)));
    xAxis.setLabel("Price");
    // add starting data
    XYChart.Series<Number,String> series1 = new XYChart.Series<Number,String>();
    series1.setName("Data Series 1");
    XYChart.Series<Number,String> series2 = new XYChart.Series<Number,String>();
    series2.setName("Data Series 2");
    XYChart.Series<Number,String> series3 = new XYChart.Series<Number,String>();
    series3.setName("Data Series 3");
    series1.getData().add(new XYChart.Data<Number,String>(567, years[0]));
    series1.getData().add(new XYChart.Data<Number,String>(1292, years[1]));
    series1.getData().add(new XYChart.Data<Number,String>(2180, years[2]));
    series2.getData().add(new XYChart.Data<Number,String>(956, years[0]));
    series2.getData().add(new XYChart.Data<Number,String>(1665, years[1]));
    series2.getData().add(new XYChart.Data<Number,String>(2450, years[2]));
    series3.getData().add(new XYChart.Data<Number,String>(800, years[0]));
    series3.getData().add(new XYChart.Data<Number,String>(1000, years[1]));
    series3.getData().add(new XYChart.Data<Number,String>(2800, years[2]));
    bc.getData().add(series1);
    bc.getData().add(series2);
    bc.getData().add(series3);
    return bc;
}
 
Example 13
Source File: AdvancedBarChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected BarChart<String, Number> createChart() {
    final String[] years = {"2007", "2008", "2009"};
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,"$",null));
    final BarChart<String,Number> bc = new BarChart<String,Number>(xAxis,yAxis);
    // setup chart
    bc.setTitle("Advanced Bar Chart");
    xAxis.setLabel("Year");
    xAxis.setCategories(FXCollections.<String>observableArrayList(Arrays.asList(years)));
    yAxis.setLabel("Price");
    // add starting data
    XYChart.Series<String,Number> series1 = new XYChart.Series<String,Number>();
    series1.setName("Data Series 1");
    XYChart.Series<String,Number> series2 = new XYChart.Series<String,Number>();
    series2.setName("Data Series 2");
    XYChart.Series<String,Number> series3 = new XYChart.Series<String,Number>();
    series3.setName("Data Series 3");
    // create sample data
    series1.getData().add(new XYChart.Data<String,Number>(years[0], 567));
    series1.getData().add(new XYChart.Data<String,Number>(years[1], 1292));
    series1.getData().add(new XYChart.Data<String,Number>(years[2], 2180));
    series2.getData().add(new XYChart.Data<String,Number>(years[0], 956));
    series2.getData().add(new XYChart.Data<String,Number>(years[1], 1665));
    series2.getData().add(new XYChart.Data<String,Number>(years[2], 2450));
    series3.getData().add(new XYChart.Data<String,Number>(years[0], 800));
    series3.getData().add(new XYChart.Data<String,Number>(years[1], 1000));
    series3.getData().add(new XYChart.Data<String,Number>(years[2], 2800));
    bc.getData().add(series1);
    bc.getData().add(series2);
    bc.getData().add(series3);
    return bc;
}
 
Example 14
Source File: AdvBarAudioChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
protected BarChart<String, Number> createChart() {
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis(0,50,10);
    final BarChart<String,Number> bc = new BarChart<String,Number>(xAxis,yAxis);
    bc.setId("barAudioDemo");
    bc.setLegendVisible(false);
    bc.setAnimated(false);
    bc.setBarGap(0);
    bc.setCategoryGap(1);
    bc.setVerticalGridLinesVisible(false);
    // setup chart
    bc.setTitle("Live Audio Spectrum Data");
    xAxis.setLabel("Frequency Bands");
    yAxis.setLabel("Magnitudes");
    yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB"));
    // add starting data
    XYChart.Series<String,Number> series1 = new XYChart.Series<String,Number>();
    series1.setName("Data Series 1");
    //noinspection unchecked
    series1Data = new XYChart.Data[128];
    String[] categories = new String[128];
    for (int i=0; i<series1Data.length; i++) {
        categories[i] = Integer.toString(i+1);
        series1Data[i] = new XYChart.Data<String,Number>(categories[i],50);
        series1.getData().add(series1Data[i]);
    }
    bc.getData().add(series1);
    return bc;
}
 
Example 15
Source File: SwingInterop.java    From marathonv5 with Apache License 2.0 5 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 16
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 17
Source File: MainApp-Camping.java    From Java-for-Data-Science with MIT License 4 votes vote down vote up
@Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("Scatter Chart Sample");
        final NumberAxis xAxis = new NumberAxis(0, 100, 10);
        final NumberAxis yAxis = new NumberAxis(0, 130000, 10000);        
        final ScatterChart<Number,Number> sc = new
            ScatterChart<Number,Number>(xAxis,yAxis);
        xAxis.setLabel("Age");                
        yAxis.setLabel("Income");
        sc.setTitle("Camping Inclination");
       
        /*
23,45600,1
26,32000,0
45,65700,1
29,25300,0
72,55600,1
24,28700,1
56,125300,1
22,34200,1
28,32800,1
32,24600,1
25,36500,1
67,76800,0
25,14500,1
86,58900,0
        */
        XYChart.Series series1 = new XYChart.Series();
        series1.setName("Camps");
        series1.getData().add(new XYChart.Data(23,45600));
        series1.getData().add(new XYChart.Data(45,65700));
        series1.getData().add(new XYChart.Data(72,55600));
        series1.getData().add(new XYChart.Data(24,28700));
        series1.getData().add(new XYChart.Data(22,34200));
        series1.getData().add(new XYChart.Data(28,32800));
        series1.getData().add(new XYChart.Data(32,24600));
        series1.getData().add(new XYChart.Data(25,36500));
        series1.getData().add(new XYChart.Data(22,43600));
        series1.getData().add(new XYChart.Data(78,125700));
        series1.getData().add(new XYChart.Data(73,56500));
        
        XYChart.Series series2 = new XYChart.Series();
        series2.setName("Doesn't Camp");
        series2.getData().add(new XYChart.Data(26,91000));
        series2.getData().add(new XYChart.Data(29,85300));
        series2.getData().add(new XYChart.Data(67,76800));
        series2.getData().add(new XYChart.Data(86,58900));
        series2.getData().add(new XYChart.Data(56,125300));
        series2.getData().add(new XYChart.Data(25,125000));
        series2.getData().add(new XYChart.Data(29,87600));
        series2.getData().add(new XYChart.Data(65,79300));
 
        sc.getData().addAll(series1, series2);
        Scene scene  = new Scene(sc, 500, 400);
        stage.setScene(scene);
        stage.show();
    }
 
Example 18
Source File: FinanceUI.java    From StockPrediction with Apache License 2.0 4 votes vote down vote up
private void init(Stage primaryStage) {
        instance = this;

        xAxis = new NumberAxis();
        xAxis.setForceZeroInRange(false);
        xAxis.setAutoRanging(true);
        xAxis.setLabel("Time");

        xAxis.setTickLabelsVisible(false);
        xAxis.setTickMarkVisible(true);
        xAxis.setMinorTickVisible(false);

        yAxis = new NumberAxis();        
        yAxis.setAutoRanging(false);
        yAxis.setForceZeroInRange(false);
        //yAxis.setLowerBound(210.4);
        //yAxis.setUpperBound(212);
        
        yAxis.setLabel("Stock Price ($)");

        //-- Chart
        final LineChart<Number, Number> sc = new LineChart<Number, Number>(xAxis, yAxis) {
            // Override to remove symbols on each data point
            @Override
            protected void dataItemAdded(Series<Number, Number> series, int itemIndex, Data<Number, Number> item) {

            }
        };
        sc.setCursor(Cursor.CROSSHAIR);
        sc.setAnimated(false);
        sc.setId("stockChart");
//        sc.setTitle("Stock Price");


        //-- Chart Series
        stockPriceSeries = new XYChart.Series<Number, Number>();
        stockPriceSeries.setName("Last Close");

        emaPriceSeries = new XYChart.Series<Number, Number>();
        emaPriceSeries.setName("Med Avg");

        predictionSeries = new XYChart.Series<Number, Number>();
        predictionSeries.setName("Predicted Med Avg.");


        sc.getData().addAll(stockPriceSeries, emaPriceSeries, predictionSeries);
        sc.getStylesheets().add("style.css");
        sc.applyCss();

        primaryStage.setScene(new Scene(sc));
    }
 
Example 19
Source File: FinanceUI.java    From StockInference-Spark with Apache License 2.0 4 votes vote down vote up
private void init(Stage primaryStage) {
        instance = this;

        xAxis = new NumberAxis();
        xAxis.setForceZeroInRange(false);
        xAxis.setAutoRanging(true);
        xAxis.setLabel("Time");

        xAxis.setTickLabelsVisible(false);
        xAxis.setTickMarkVisible(true);
        xAxis.setMinorTickVisible(false);

        yAxis = new NumberAxis();        
        yAxis.setAutoRanging(false);
        yAxis.setForceZeroInRange(false);
        //yAxis.setLowerBound(210.4);
        //yAxis.setUpperBound(212);
        
        yAxis.setLabel("Stock Price ($)");

        //-- Chart
        final LineChart<Number, Number> sc = new LineChart<Number, Number>(xAxis, yAxis) {
            // Override to remove symbols on each data point
            @Override
            protected void dataItemAdded(Series<Number, Number> series, int itemIndex, Data<Number, Number> item) {

            }
        };
        sc.setCursor(Cursor.CROSSHAIR);
        sc.setAnimated(false);
        sc.setId("stockChart");
//        sc.setTitle("Stock Price");


        //-- Chart Series
        stockPriceSeries = new XYChart.Series<Number, Number>();
        stockPriceSeries.setName("Last Close");

        emaPriceSeries = new XYChart.Series<Number, Number>();
        emaPriceSeries.setName("Med Avg");

        predictionSeries = new XYChart.Series<Number, Number>();
        predictionSeries.setName("Predicted Med Avg.");


        sc.getData().addAll(stockPriceSeries, emaPriceSeries, predictionSeries);
        sc.getStylesheets().add("style.css");
        sc.applyCss();

        primaryStage.setScene(new Scene(sc));
    }
 
Example 20
Source File: ParetoChartController.java    From OEE-Designer with MIT License 4 votes vote down vote up
private BarChart<String, Number> createBarChart(String categoryLabel) {
	// X-Axis category
	CategoryAxis xAxis = new CategoryAxis();
	xAxis.setLabel(categoryLabel);

	// Y-Axis (%)
	NumberAxis yAxis = new NumberAxis(0, 100, 10);
	yAxis.setLabel(DesignerLocalizer.instance().getLangString("percent"));
	yAxis.setAutoRanging(false);
	yAxis.setUpperBound(100.0d);
	yAxis.setLowerBound(0.0d);

	// create bar chart
	BarChart<String, Number> chBarChart = new BarChart<>(xAxis, yAxis);
	chBarChart.setTitle(chartTitle);
	chBarChart.setLegendVisible(false);
	chBarChart.setAnimated(false);
	chBarChart.getData().add(barChartSeries);

	// add the points
	double total = totalCount.doubleValue();

	if (total > 0.0d) {
		int count = 0;
		for (ParetoItem paretoItem : paretoItems) {
			if (count > TOP_N) {
				break;
			}
			count++;

			Float percentage = new Float(paretoItem.getValue().floatValue() / total * 100.0f);
			XYChart.Data<String, Number> point = new XYChart.Data<>(paretoItem.getCategory(), percentage);
			barChartSeries.getData().add(point);
		}
	}

	// add listener for mouse click on bar
	for (Series<String, Number> series : chBarChart.getData()) {
		for (XYChart.Data<String, Number> item : series.getData()) {

			item.getNode().setOnMouseClicked((MouseEvent event) -> {
				onBarChartNodeSelected(item);
			});
		}
	}

	return chBarChart;
}