Java Code Examples for javafx.scene.chart.NumberAxis#setTickLabelFormatter()
The following examples show how to use
javafx.scene.chart.NumberAxis#setTickLabelFormatter() .
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: LabeledBarChart.java From MyBox with Apache License 2.0 | 6 votes |
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 2
Source File: LabeledHorizontalBarChart.java From MyBox with Apache License 2.0 | 6 votes |
public static LabeledHorizontalBarChart create(boolean displayCategoryAxis, ChartCoordinate chartCoordinate) { CategoryAxis categoryAxis = new CategoryAxis(); categoryAxis.setSide(Side.LEFT); categoryAxis.setTickLabelsVisible(displayCategoryAxis); categoryAxis.setGapStartAndEnd(true); NumberAxis numberAxis = new NumberAxis(); numberAxis.setSide(Side.TOP); 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 LabeledHorizontalBarChart(numberAxis, categoryAxis) .setChartCoordinate(chartCoordinate); }
Example 3
Source File: AdvAreaAudioChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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 4
Source File: SupplyView.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
private Node createBSQIssuedChart(XYChart.Series<Number, Number> series) { NumberAxis xAxis = new NumberAxis(); configureAxis(xAxis); xAxis.setTickLabelFormatter(getTimestampTickLabelFormatter("MMM uu")); NumberAxis yAxis = new NumberAxis(); configureYAxis(yAxis); yAxis.setTickLabelFormatter(BSQPriceTickLabelFormatter); AreaChart<Number, Number> chart = new AreaChart<>(xAxis, yAxis); configureChart(chart); chart.setCreateSymbols(false); chart.getData().add(series); return chart; }
Example 5
Source File: ChartAudioArea.java From netbeans with Apache License 2.0 | 6 votes |
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: AdvAreaAudioChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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: 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 8
Source File: SupplyView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
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 9
Source File: ChartAudioBar.java From netbeans with Apache License 2.0 | 5 votes |
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 10
Source File: ChartAdvancedBar.java From netbeans with Apache License 2.0 | 5 votes |
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 11
Source File: ChartAdvancedStockLine.java From netbeans with Apache License 2.0 | 5 votes |
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 12
Source File: AdvBarAudioChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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 13
Source File: AdvancedBarChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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: AdvancedStockLineChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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 15
Source File: AdvBarAudioChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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 16
Source File: AdvancedBarChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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 17
Source File: AdvancedStockLineChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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: 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; } }); }