/** * the constructor is responsible for initialize the chart (lower and upper buonds, name, colors) * @param stackedAreaChart is the type of chart for battery performance */ public StackedAreaChartClass(StackedAreaChart stackedAreaChart){ NumberAxis yaxis = (NumberAxis) stackedAreaChart.getYAxis(); //getter and setting proprieties for y and x axes xAxis = (NumberAxis) stackedAreaChart.getXAxis(); xAxis.setLowerBound(0); xAxis.setUpperBound(10); xAxis.setAutoRanging(false); xAxis.setTickLabelsVisible(false); //hide numbers on x axis stackedAreaChart.setVerticalGridLinesVisible(false);//hide vertical lines stackedAreaChart.animatedProperty().setValue(false); yaxis.setAutoRanging(false); yaxis.setLowerBound(0); yaxis.setUpperBound(100); //set series of content to draw chart series = new XYChart.Series(); series.setName("Battery level"); stackedAreaChart.getData().add(series); //setting colors of charts Node fill = series.getNode().lookup(".chart-series-area-fill"); fill.setStyle("-fx-fill: #fff7ad;"); Node line = series.getNode().lookup(".chart-series-area-line"); line.setStyle("-fx-stroke: #8bc34a;" + "-fx-stroke-width: 3px;"); // set width of line stackedAreaChart.setStyle("CHART_COLOR_1: #8bc34a;"); //color of dots }
@Override protected Chart getNewChartInstance() { NumberAxis axis1 = new NumberAxis(0, 100, 10); NumberAxis axis2 = new NumberAxis(0, 100, 10); StackedAreaChart chart = new StackedAreaChart(axis1, axis2); return chart; }
@Test(timeout = 60000) public void createSymbolsPropertyTest() { assertTrue(new AreaChart(new NumberAxis(), new NumberAxis()).getCreateSymbols()); assertTrue(new StackedAreaChart(new NumberAxis(), new NumberAxis()).getCreateSymbols()); populateChart(); checkTextFieldText(AreaTestsProperties.createSymbols, "true"); checkDotsCount(30); setPropertyByToggleClick(SettingType.BIDIRECTIONAL, AreaTestsProperties.createSymbols, false); checkTextFieldText(AreaTestsProperties.createSymbols, "false"); checkDotsCount(0); setPropertyByToggleClick(SettingType.SETTER, AreaTestsProperties.createSymbols, true); checkTextFieldText(AreaTestsProperties.createSymbols, "true"); checkDotsCount(30); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, AreaTestsProperties.createSymbols, false); checkTextFieldText(AreaTestsProperties.createSymbols, "false"); checkDotsCount(0); removeFromIndex(2, 1, 0); checkDotsCount(0); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, AreaTestsProperties.createSymbols, true); addSeries("Series C", 0, 100, 30); checkDotsCount(30); removeFromIndex(0); checkDotsCount(0); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, AreaTestsProperties.createSymbols, false); checkDotsCount(0); addSeries("Series C", 0, 100, 30); checkDotsCount(0); }
@Override protected XYChart<ZonedDateTime, Double> buildChart(ZonedDateTimeAxis xAxis, ValueAxis<Double> yAxis, BooleanProperty showSymbolsProperty) { StackedAreaChart<ZonedDateTime, Double> newChart = new StackedAreaChart<>(xAxis, yAxis); newChart.setCreateSymbols(false); newChart.createSymbolsProperty().bindBidirectional(showSymbolsProperty); return newChart; }
@Test public void testGetStackedAreaChartAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(StackedAreaChart.class); assertThat(adjuster, is(instanceOf(RegionAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(Region.class))); }
@Override protected XYChart<String, Number> createXYChart() { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); final XYChart<String, Number> chart = new StackedAreaChart<String, Number>(xAxis, yAxis); chart.getStyleClass().add("chart-extension"); return chart; }
public StackedAreaChartSample() { NumberAxis xAxis = NumberAxisBuilder.create() .label("X Values") .lowerBound(1.0d) .upperBound(9.0d) .tickUnit(2.0d).build(); NumberAxis yAxis = NumberAxisBuilder.create() .label("Y Values") .lowerBound(0.0d) .upperBound(30.0d) .tickUnit(2.0d).build(); ObservableList<StackedAreaChart.Series> areaChartData = FXCollections.observableArrayList( new StackedAreaChart.Series("Series 1",FXCollections.observableArrayList( new StackedAreaChart.Data(0,4), new StackedAreaChart.Data(2,5), new StackedAreaChart.Data(4,4), new StackedAreaChart.Data(6,2), new StackedAreaChart.Data(8,6), new StackedAreaChart.Data(10,8) )), new StackedAreaChart.Series("Series 2", FXCollections.observableArrayList( new StackedAreaChart.Data(0,8), new StackedAreaChart.Data(2,2), new StackedAreaChart.Data(4,9), new StackedAreaChart.Data(6,7), new StackedAreaChart.Data(8,5), new StackedAreaChart.Data(10,7) )), new StackedAreaChart.Series("Series 3", FXCollections.observableArrayList( new StackedAreaChart.Data(0,2), new StackedAreaChart.Data(2,5), new StackedAreaChart.Data(4,8), new StackedAreaChart.Data(6,6), new StackedAreaChart.Data(8,9), new StackedAreaChart.Data(10,7) )) ); StackedAreaChart chart = new StackedAreaChart(xAxis, yAxis, areaChartData); getChildren().add(chart); }
protected Chart createObject(Axis x_axis, Axis y_axis, double width, double height) { Series s1 = new Series( FXCollections.observableArrayList( new XYChart.Data(1,2), new XYChart.Data(2,3), new XYChart.Data(3,5), new XYChart.Data(4,1), new XYChart.Data(6,4), new XYChart.Data(7,2), new XYChart.Data(8,3), new XYChart.Data(9,4) )); s1.setName("Set 1"); Series s2 = new Series( FXCollections.observableArrayList( new XYChart.Data(1,1), new XYChart.Data(2,4), new XYChart.Data(3,2), new XYChart.Data(6,5), new XYChart.Data(7,3), new XYChart.Data(8,2), new XYChart.Data(9,1) )); s2.setName("Set 2"); Series s3 = new Series( FXCollections.observableArrayList( new XYChart.Data(1,5), new XYChart.Data(2,3), new XYChart.Data(3,1), new XYChart.Data(4,2), new XYChart.Data(6,3), new XYChart.Data(7,1), new XYChart.Data(8,4) )); s3.setName("Set 3"); ObservableList data = FXCollections.observableArrayList(s1, s2, s3); StackedAreaChart chart = new StackedAreaChart(x_axis, y_axis, data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("StackedAreaChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
public StackedAreaChart getNewChart() { StackedAreaChart chart = new StackedAreaChart(axis1, axis2); chart.setTitle("StackedAreaChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }