static NumberAxis getNumberAxis(NumberColumn numberColumn) { final NumberAxis numberAxis = new NumberAxis(); numberAxis.setLabel(numberColumn.name()); return numberAxis; }
public static void setupXAxis(NumberAxis numberAxis, long min, long max) { numberAxis.setAutoRanging(false); numberAxis.setTickUnit((max - min) / 20); numberAxis.setLowerBound(min); numberAxis.setUpperBound(max); numberAxis.setTickLabelFormatter(new StringConverter<Number>() { private final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy\nHH:mm:ss,SSS"); @Override public String toString(Number object) { return format.format(new Date(object.longValue())); } @Override public Number fromString(String string) { return null; } }); }
static Node createBubbleChart(boolean useRightTopAxis) { final Random RANDOM = new Random(29782198273l); NumberAxis xAxis = new NumberAxis(); xAxis.setLabel("Product"); NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("Number Bought/Sold"); if (useRightTopAxis) { xAxis.setSide(Side.TOP); yAxis.setSide(Side.RIGHT); } ObservableList<BubbleChart.Series> bubbleChartData = FXCollections.observableArrayList(); for (int s=0; s<8; s++) { ObservableList<BubbleChart.Data> seriesData = FXCollections.<BubbleChart.Data>observableArrayList(); for (int d=0; d<(8*(RANDOM.nextDouble()*10)); d++) { seriesData.add(new XYChart.Data(100*RANDOM.nextDouble(), -50+(150*RANDOM.nextDouble()), 5+(10*RANDOM.nextDouble()) )); } bubbleChartData.add(new ScatterChart.Series("Product "+(s+1),seriesData)); } return new BubbleChart(xAxis, yAxis, bubbleChartData); }
if (showTickMarks) { if (tickLine == null) { tickLine = new NumberAxis(); tickLine.tickLabelFormatterProperty().bind(getSkinnable().labelFormatterProperty()); tickLine.setAnimated(false); tickLine.setAutoRanging(false); tickLine.setSide(isHorizontal() ? Side.BOTTOM : Side.RIGHT); tickLine.setUpperBound(rangeSlider.getMax()); tickLine.setLowerBound(rangeSlider.getMin()); tickLine.setTickUnit(rangeSlider.getMajorTickUnit()); tickLine.setTickMarkVisible(ticksVisible); tickLine.setTickLabelsVisible(labelsVisible); tickLine.setMinorTickVisible(ticksVisible); tickLine.setMinorTickCount(Math.max(rangeSlider.getMinorTickCount(),0) + 1); getChildren().clear(); getChildren().addAll(tickLine, track, lowThumb); } else { tickLine.setTickLabelsVisible(labelsVisible); tickLine.setTickMarkVisible(ticksVisible); tickLine.setMinorTickVisible(ticksVisible);
registerChangeListener(rangeSlider.minProperty(), e -> { if (showTickMarks && tickLine != null) { tickLine.setLowerBound(getSkinnable().getMin()); registerChangeListener(rangeSlider.maxProperty(), e -> { if (showTickMarks && tickLine != null) { tickLine.setUpperBound(getSkinnable().getMax()); orientation = getSkinnable().getOrientation(); if (showTickMarks && tickLine != null) { tickLine.setSide(isHorizontal() ? Side.BOTTOM : Side.RIGHT); registerChangeListener(rangeSlider.majorTickUnitProperty(), e -> { if (tickLine != null) { tickLine.setTickUnit(getSkinnable().getMajorTickUnit()); getSkinnable().requestLayout(); registerChangeListener(rangeSlider.minorTickCountProperty(), e -> { if (tickLine != null) { tickLine.setMinorTickCount(Math.max(getSkinnable().getMinorTickCount(),0) + 1); getSkinnable().requestLayout();
static Node createScatterChart() { final Random RANDOM = new Random(29782198273l); NumberAxis xAxis = new NumberAxis("X-Axis", 0, 8, 1); NumberAxis yAxis = new NumberAxis("Y-Axis", -5, 5, 1); ObservableList<XYChart.Series> data = FXCollections.observableArrayList(); for (int s=0; s<8; s++) { ObservableList<ScatterChart.Data> seriesData = FXCollections.<ScatterChart.Data>observableArrayList(); for (int d=0; d<(8*(RANDOM.nextDouble()*10)); d++) { seriesData.add(new XYChart.Data(8*RANDOM.nextDouble(), -5+(10*RANDOM.nextDouble()))); } data.add(new ScatterChart.Series("Product "+(s+1),seriesData)); } return new ScatterChart(xAxis, yAxis, data); } }
static Node createAreaChart(Boolean stacked) { NumberAxis xAxis = new NumberAxis("X Values", 1.0d, 9.0d, 2.0d); xAxis.setTickLength(12.0f); NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("Y Values"); ObservableList<AreaChart.Series> areaChartData = FXCollections.observableArrayList( new AreaChart.Series("Series 1",FXCollections.observableArrayList(
public TPSChart() { final NumberAxis yAxis = new NumberAxis(); this.xAxis = new NumberAxis( 0, 512, 1000 ); this.xAxis.setAutoRanging( false ); this.chart = new LineChart<>( xAxis, yAxis ); this.chart.setAnimated( false ); this.chart.setCreateSymbols( false ); this.chart.setLegendVisible( false ); this.fullTimeSeries = new XYChart.Series<>(); this.actualTimeSeries = new XYChart.Series<>(); this.averageTimeSeries = new XYChart.Series<>(); this.scrollBar = new ScrollBar(); this.scrollBar.valueProperty().addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue ) { currentDataStart = (int) ( newValue.floatValue() * ( TimeUnit.SECONDS.toNanos( 1 ) / tickNanos ) * 60 ); updateChart(); } } ); }
this.averageTimeSeries.getData().clear(); this.xAxis.setLowerBound( this.currentDataStart ); this.xAxis.setUpperBound( this.currentDataStart + 60 * ( TimeUnit.SECONDS.toNanos( 1 ) / this.tickNanos ) ); for ( int i = (int) this.xAxis.getLowerBound(); i < this.xAxis.getUpperBound(); i++ ) { if ( this.data.size() > i ) { fullTimeData.add( new XYChart.Data<>( i, this.tickNanos ) ); for ( int x = (int) (this.xAxis.getUpperBound() - tps); x < this.xAxis.getUpperBound(); x++ ) { average += this.data.get( x ); for ( int x = (int) (this.xAxis.getUpperBound() - tps); x < this.xAxis.getUpperBound(); x++ ) { averageTimeData.add( new XYChart.Data<>( x, average ) );
public static void configureAxisTick(NumberAxis axis, int upperLimit) { if (upperLimit > 5000) { axis.setTickUnit(500); } else if (upperLimit > 1000) { axis.setTickUnit(100); } else if (upperLimit > 10) { axis.setTickUnit(10); } else { axis.setTickUnit(1); } } }
/** * Create the charts. * * @param timeRange * the max time range * @return the {@link LineChart} */ public static LineChart<Number, Number> createDerivativeLineChart(final int timeRange) { final NumberAxis x2Axis = new NumberAxis("Space", -100, 100, 1); final NumberAxis x1Axis = new NumberAxis("Time", 0, timeRange, 1); final LineChart<Number, Number> lineChart = new LineChart<>(x1Axis, x2Axis); lineChart.getYAxis().setAutoRanging(false); lineChart.getYAxis().setAutoRanging(false); lineChart.setAnimated(false); return lineChart; }
NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("Units Sold"); ObservableList<BarChart.Series> barChartData = FXCollections.observableArrayList(); final double negative = stacked ? 0 : -500;
static Node createLineChart() { 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) )) ); return new LineChart(xAxis, yAxis, lineChartData); }
final NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("Value");
public static BarChart<String, Number> chart( String title, StringColumn x, NumberColumn y) { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel(x.name()); yAxis.setLabel(y.name()); Table t = Table.create("", x, y); t = t.sortDescendingOn(y.name()); final BarChart<String, Number> bar = new BarChart<>(xAxis, yAxis); bar.setTitle(title); List<XYChart.Data<String, Number>> d2 = new ArrayList<>(x.size()); for (int i = 0; i < x.size(); i++) { d2.add(new XYChart.Data<>(t.stringColumn(0).get(i), t.nCol(1).get(i))); } XYChart.Series<String, Number> series1 = new XYChart.Series<>(FXCollections.observableList(d2)); series1.setName(y.name()); bar.setLegendVisible(false); bar.setCategoryGap(0.0); bar.setBarGap(0.1); bar.setBackground(Background.EMPTY); bar.setVerticalGridLinesVisible(false); bar.getData().add(series1); return bar; }