Java Code Examples for javafx.scene.chart.NumberAxis#setAutoRanging()
The following examples show how to use
javafx.scene.chart.NumberAxis#setAutoRanging() .
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: OverviewPanel.java From constellation with Apache License 2.0 | 6 votes |
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 2
Source File: ChartAdvancedScatterLive.java From netbeans with Apache License 2.0 | 6 votes |
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 3
Source File: AdvScatterLiveChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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 4
Source File: AdvScatterLiveChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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 5
Source File: AxisInlierUtils.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private static void applyRange(NumberAxis axis, int maxNumberOfTicks, Tuple2<Double, Double> bounds) { var boundsWidth = getBoundsWidth(bounds); if (boundsWidth < 0) { throw new IllegalArgumentException( "The lower bound must be a smaller number than the upper bound"); } if (boundsWidth == 0 || Double.isNaN(boundsWidth)) { // less than 2 unique data-points: recalculating axis range doesn't make sense return; } axis.setAutoRanging(false); var lowerBound = bounds.first; var upperBound = bounds.second; // If one of the ends of the range weren't zero, // additional logic would be needed to make ticks "round". // Of course, many, if not most, charts benefit from having 0 on the axis. if (lowerBound > 0) { lowerBound = 0d; } else if (upperBound < 0) { upperBound = 0d; } axis.setLowerBound(lowerBound); axis.setUpperBound(upperBound); var referenceTickUnit = computeReferenceTickUnit(maxNumberOfTicks, bounds); var tickUnit = computeTickUnit(referenceTickUnit); axis.setTickUnit(tickUnit); }
Example 6
Source File: OfferBookChartView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void createChart() { xAxis = new NumberAxis(); xAxis.setForceZeroInRange(false); xAxis.setAutoRanging(false); xAxis.setTickLabelGap(6); xAxis.setTickMarkVisible(false); xAxis.setMinorTickVisible(false); NumberAxis yAxis = new NumberAxis(); yAxis.setForceZeroInRange(false); yAxis.setSide(Side.RIGHT); yAxis.setAutoRanging(true); yAxis.setTickMarkVisible(false); yAxis.setMinorTickVisible(false); yAxis.setTickLabelGap(5); yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis, "", " " + Res.getBaseCurrencyCode())); seriesBuy = new XYChart.Series<>(); seriesSell = new XYChart.Series<>(); areaChart = new AreaChart<>(xAxis, yAxis); areaChart.setLegendVisible(false); areaChart.setAnimated(false); areaChart.setId("charts"); areaChart.setMinHeight(270); areaChart.setPrefHeight(270); areaChart.setCreateSymbols(true); areaChart.setPadding(new Insets(0, 10, 0, 10)); areaChart.getData().addAll(List.of(seriesBuy, seriesSell)); chartPane = new AnchorPane(); chartPane.getStyleClass().add("chart-pane"); AnchorPane.setTopAnchor(areaChart, 15d); AnchorPane.setBottomAnchor(areaChart, 10d); AnchorPane.setLeftAnchor(areaChart, 10d); AnchorPane.setRightAnchor(areaChart, 0d); chartPane.getChildren().add(areaChart); }
Example 7
Source File: SupplyView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void configureAxis(NumberAxis axis) { axis.setForceZeroInRange(false); axis.setAutoRanging(true); axis.setTickMarkVisible(false); axis.setMinorTickVisible(false); axis.setTickLabelGap(6); }
Example 8
Source File: TrainingView.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 9
Source File: LRInspectorController.java From megan-ce with GNU General Public License v3.0 | 5 votes |
/** * create a horizontal axis * * @param maxReadLength * @return axis */ private static Pane createAxis(final ReadOnlyIntegerProperty maxReadLength, final ReadOnlyDoubleProperty widthProperty) { final Pane pane = new Pane(); pane.prefWidthProperty().bind(widthProperty); final NumberAxis axis = new NumberAxis(); axis.setSide(Side.TOP); axis.setAutoRanging(false); axis.setLowerBound(0); axis.prefHeightProperty().set(20); axis.prefWidthProperty().bind(widthProperty.subtract(60)); axis.setTickLabelFont(Font.font("Arial", 10)); final ChangeListener<Number> changeListener = (observable, oldValue, newValue) -> { int minX = Math.round(maxReadLength.get() / 2000.0f); // at most 2000 major ticks for (int x = 10; x < 10000000; x *= 10) { if (x >= minX && widthProperty.doubleValue() * x >= 50 * maxReadLength.doubleValue()) { axis.setUpperBound(maxReadLength.get()); axis.setTickUnit(x); return; } } axis.setTickUnit(maxReadLength.get()); axis.setUpperBound(maxReadLength.get()); }; maxReadLength.addListener(changeListener); widthProperty.addListener(changeListener); pane.getChildren().add(axis); return pane; }
Example 10
Source File: ChartUtil.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
private static XYChart.Series getSeries(LineChart chart, Double dt, String name) { NumberAxis na = (NumberAxis) chart.getYAxis(); na.setAutoRanging(true); na.setForceZeroInRange(false); XYChart.Series s = new XYChart.Series(); s.setName(name); return s; }
Example 11
Source File: ParetoChartController.java From OEE-Designer with MIT License | 5 votes |
private LineChart<String, Number> createLineChart(String categoryLabel) { // X-Axis category (not shown) CategoryAxis xAxis = new CategoryAxis(); xAxis.setLabel(categoryLabel); xAxis.setOpacity(0); // Y-Axis (%) NumberAxis yAxis = new NumberAxis(0, 100, 10); yAxis.setLabel(DesignerLocalizer.instance().getLangString("cum.percent")); yAxis.setSide(Side.RIGHT); yAxis.setAutoRanging(false); yAxis.setUpperBound(100.0d); yAxis.setLowerBound(0.0d); // create the line chart LineChart<String, Number> chLineChart = new LineChart<>(xAxis, yAxis); chLineChart.setTitle(chartTitle); chLineChart.setLegendVisible(false); chLineChart.setAnimated(false); chLineChart.setCreateSymbols(true); chLineChart.getData().add(lineChartSeries); // plot the points double total = totalCount.doubleValue(); Float cumulative = new Float(0f); for (ParetoItem paretoItem : this.paretoItems) { cumulative += new Float(paretoItem.getValue().floatValue() / total * 100.0f); XYChart.Data<String, Number> point = new XYChart.Data<>(paretoItem.getCategory(), cumulative); lineChartSeries.getData().add(point); } return chLineChart; }
Example 12
Source File: MultipleAxesLineChart.java From chart-fx with Apache License 2.0 | 5 votes |
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 13
Source File: NumberAxisBuilder.java From constellation with Apache License 2.0 | 5 votes |
@Override public Axis<Number> build() { final NumberAxis axis = new NumberAxis(); axis.setAutoRanging(true); axis.setForceZeroInRange(false); return axis; }
Example 14
Source File: ParetoChartController.java From OEE-Designer with MIT License | 4 votes |
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; }
Example 15
Source File: ChromatogramRenderer.java From old-mzmine3 with GNU General Public License v2.0 | 4 votes |
@Override public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) { return new TreeTableCell<FeatureTableRow, Object>() { @Override public void updateItem(Object object, boolean empty) { super.updateItem(object, empty); setStyle( "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;"); if (object == null) { setText(null); } else { Chromatogram chromatogram = (Chromatogram) object; ChromatographyInfo[] chromatographyInfoValues = chromatogram.getRetentionTimes(); float[] intensityValues = chromatogram.getIntensityValues(); int numOfDataPoints = chromatogram.getNumberOfDataPoints(); // x-axis NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelsVisible(false); xAxis.setOpacity(0); xAxis.setAutoRanging(false); xAxis.setLowerBound(chromatogram.getRtRange().lowerEndpoint().getRetentionTime()); xAxis.setUpperBound(chromatogram.getRtRange().upperEndpoint().getRetentionTime()); // y-axis NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelsVisible(false); yAxis.setOpacity(0); // Chart line final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); XYChart.Series series = new XYChart.Series(); for (int i = 1; i < numOfDataPoints; i++) { series.getData().add(new XYChart.Data(chromatographyInfoValues[i].getRetentionTime(), intensityValues[i])); } // Chart lineChart.getData().addAll(series); lineChart.setLegendVisible(false); lineChart.setCreateSymbols(false); lineChart.setMinSize(0, 0); lineChart.setPrefHeight(75); lineChart.setPrefWidth(100); setGraphic(lineChart); } } }; }
Example 16
Source File: FinanceUI.java From StockInference-Spark with Apache License 2.0 | 4 votes |
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 17
Source File: FinanceUI.java From StockPrediction with Apache License 2.0 | 4 votes |
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 18
Source File: VisualizerPresenter.java From HdrHistogramVisualizer with Apache License 2.0 | 4 votes |
void initializePercentileChartAxes() { checkNotNull(percentileChart); final NumberAxis xAxis = (NumberAxis) percentileChart.getXAxis(); xAxis.setAutoRanging(false); xAxis.setTickUnit(1); // log axis -> 10^x steps xAxis.setLowerBound(0); xAxis.setUpperBound(0); // Limit X range to max value to avoid empty space percentileChart.getData().addListener((ListChangeListener<XYChart.Series<Number, Number>>) c -> { double maxX = percentileChart.getData().stream() .flatMap(series -> series.getData().stream()) .mapToDouble(point -> point.getXValue().doubleValue()) .max() .orElse(0); xAxis.setUpperBound(maxX); }); // Format labels such that e.g. 10^6 is shown as 6 nines xAxis.setTickLabelFormatter(new StringConverter<Number>() { @Override public String toString(Number object) { int intValue = object.intValue(); if (object.doubleValue() > intValue) return ""; // Only label full 10^x steps switch (intValue) { case 0: return "0%"; case 1: return "90%"; case 2: return "99%"; default: String percentile = "99."; for (int i = 2; i < intValue; i++) { percentile += "9"; } return percentile + "%"; } } @Override public Number fromString(String string) { return null; } }); }
Example 19
Source File: FeatureShapeChart.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public FeatureShapeChart(@Nonnull ModularFeatureListRow row, AtomicDouble progress) { try { final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); final LineChart<Number, Number> bc = new LineChart<>(xAxis, yAxis); DataPoint max = null; double maxRT = 0; int size = row.getFeatures().size(); int fi = 0; for (ModularFeature f : row.getFeatures().values()) { XYChart.Series<Number, Number> data = new XYChart.Series<>(); List<Integer> scans = f.getScanNumbers(); List<DataPoint> dps = f.getDataPoints(); RawDataFile raw = f.getRawDataFile(); // add data points retention time -> intensity for (int i = 0; i < scans.size(); i++) { DataPoint dp = dps.get(i); double retentionTime = raw.getScan(scans.get(i)).getRetentionTime(); double intensity = dp == null ? 0 : dp.getIntensity(); data.getData().add(new XYChart.Data<>(retentionTime, intensity)); if (dp != null && (max == null || max.getIntensity() < dp.getIntensity())) { max = dp; maxRT = retentionTime; } if (progress != null) progress.addAndGet(1.0 / size / scans.size()); } fi++; bc.getData().add(data); if (progress != null) progress.set((double) fi / size); } bc.setLegendVisible(false); bc.setMinHeight(100); bc.setPrefHeight(100); bc.setMaxHeight(100); bc.setPrefWidth(150); bc.setCreateSymbols(false); // do not add data to chart xAxis.setAutoRanging(false); xAxis.setUpperBound(maxRT + 1.5d); xAxis.setLowerBound(maxRT - 1.5d); bc.setOnScroll(new EventHandler<>() { @Override public void handle(ScrollEvent event) { NumberAxis axis = xAxis; final double minX = xAxis.getLowerBound(); final double maxX = xAxis.getUpperBound(); double d = maxX - minX; double x = event.getX(); double direction = event.getDeltaY(); if (direction > 0) { if (d > 0.3) { axis.setLowerBound(minX + 0.1); axis.setUpperBound(maxX - 0.1); } } else { axis.setLowerBound(minX - 0.1); axis.setUpperBound(maxX + 0.1); } event.consume(); } }); this.getChildren().add(bc); } catch (Exception ex) { logger.log(Level.WARNING, "error in DP", ex); } }