javafx.scene.chart.XYChart.Series Java Examples

The following examples show how to use javafx.scene.chart.XYChart.Series. 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: ParetoChartController.java    From OEE-Designer with MIT License 6 votes vote down vote up
public void createParetoChart(String title, StackPane spPareto, List<ParetoItem> items, Number totalCount,
		String categoryLabel) {
	barChartSeries = new XYChart.Series<>();
	lineChartSeries = new XYChart.Series<>();

	this.chartTitle = title;
	this.totalCount = totalCount;

	// sort the items
	this.paretoItems = items;
	Collections.sort(paretoItems, Collections.reverseOrder());

	barChartSeries.setName(DesignerLocalizer.instance().getLangString("categories"));
	lineChartSeries.setName(DesignerLocalizer.instance().getLangString("cumulative"));

	// create the stacked charts
	layerCharts(spPareto, createBarChart(categoryLabel), createLineChart(categoryLabel));
}
 
Example #2
Source File: AdvancedBubbleChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected BubbleChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final BubbleChart<Number,Number> bc = new BubbleChart<Number,Number>(xAxis,yAxis);
    // setup chart
    bc.setTitle("Advanced BubbleChart");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<Number,Number> series1 = new XYChart.Series<Number,Number>();
    series1.setName("Data Series 1");
    for (int i=0; i<20; i++) series1.getData().add(
            new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
    XYChart.Series<Number,Number> series2 = new XYChart.Series<Number,Number>();
    series2.setName("Data Series 2");
    for (int i=0; i<20; i++) series2.getData().add(
            new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
    bc.getData().addAll(series1, series2);
    return bc;
}
 
Example #3
Source File: AdvancedLineChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected LineChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<Number,Number> lc = new LineChart<Number,Number>(xAxis,yAxis);
    // setup chart
    lc.setTitle("Basic LineChart");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
    series.setName("Data Series 1");
    series.getData().add(new XYChart.Data<Number,Number>(20d, 50d));
    series.getData().add(new XYChart.Data<Number,Number>(40d, 80d));
    series.getData().add(new XYChart.Data<Number,Number>(50d, 90d));
    series.getData().add(new XYChart.Data<Number,Number>(70d, 30d));
    series.getData().add(new XYChart.Data<Number,Number>(170d, 122d));
    lc.getData().add(series);
    return lc;
}
 
Example #4
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 #5
Source File: AdvancedBubbleChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected BubbleChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final BubbleChart<Number,Number> bc = new BubbleChart<Number,Number>(xAxis,yAxis);
    // setup chart
    bc.setTitle("Advanced BubbleChart");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<Number,Number> series1 = new XYChart.Series<Number,Number>();
    series1.setName("Data Series 1");
    for (int i=0; i<20; i++) series1.getData().add(
            new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
    XYChart.Series<Number,Number> series2 = new XYChart.Series<Number,Number>();
    series2.setName("Data Series 2");
    for (int i=0; i<20; i++) series2.getData().add(
            new XYChart.Data<Number,Number>(Math.random()*100, Math.random()*100, (Math.random()*10)));
    bc.getData().addAll(series1, series2);
    return bc;
}
 
Example #6
Source File: AdvancedLineChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected LineChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<Number,Number> lc = new LineChart<Number,Number>(xAxis,yAxis);
    // setup chart
    lc.setTitle("Basic LineChart");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
    series.setName("Data Series 1");
    series.getData().add(new XYChart.Data<Number,Number>(20d, 50d));
    series.getData().add(new XYChart.Data<Number,Number>(40d, 80d));
    series.getData().add(new XYChart.Data<Number,Number>(50d, 90d));
    series.getData().add(new XYChart.Data<Number,Number>(70d, 30d));
    series.getData().add(new XYChart.Data<Number,Number>(170d, 122d));
    lc.getData().add(series);
    return lc;
}
 
Example #7
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 #8
Source File: Clustering.java    From java-ml-projects with Apache License 2.0 6 votes vote down vote up
private void swapClusteredChartSeriesColors() {
	List<Series<Number, Number>> clusteredSeries = new ArrayList<>();
	// we have to copy the original data to swap the series
	clusteredChart.getData().forEach(serie -> {
		Series<Number, Number> series = new Series<>();
		series.setName(serie.getName());
		serie.getData().stream().map(d -> new Data<Number, Number>(d.getXValue(), d.getYValue()))
				.forEach(series.getData()::add);
		clusteredSeries.add(series);
	});
	int i = swapColorsCombinations[swapIndex][0];
	int j = swapColorsCombinations[swapIndex][1];
	Collections.swap(clusteredSeries, i, j);
	clusteredChart.getData().clear();
	clusteredChart.getData().addAll(clusteredSeries);
	swapIndex = swapIndex == NUMBER_OF_CLASSES - 1 ? 0 : swapIndex + 1;
}
 
Example #9
Source File: TrainingView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public TrainingView() {

        label = new Label();

        Button button = new Button("train network model");
        button.setOnAction(e -> {
            Task task = train();
            button.disableProperty().bind(task.runningProperty());
        });
        series = new Series();
        series.setName("#iterations");
        Chart chart = createChart(series);

        VBox controls = new VBox(15.0, label, button, chart);
        controls.setAlignment(Pos.CENTER);

        setCenter(controls);
    }
 
Example #10
Source File: Clustering.java    From java-ml-projects with Apache License 2.0 5 votes vote down vote up
private ScatterChart<Number, Number> buildChart(String chartName, List<XYChart.Series<Number, Number>> series) {
	final NumberAxis xAxis = new NumberAxis();
	final NumberAxis yAxis = new NumberAxis();
	final ScatterChart<Number, Number> sc = new ScatterChart<Number, Number>(xAxis, yAxis);
	sc.setTitle(chartName);
	sc.setPrefHeight(450);
	sc.setPrefWidth(600);
	xAxis.getValueForDisplay(1);
	yAxis.getValueForDisplay(2);
	sc.getData().addAll(series);
	return sc;
}
 
Example #11
Source File: Clustering.java    From java-ml-projects with Apache License 2.0 5 votes vote down vote up
private List<Series<Number, Number>> buildClusteredSeries() throws Exception {
	List<XYChart.Series<Number, Number>> clusteredSeries = new ArrayList<>();

	// to build the cluster we remove the class information
	Remove remove = new Remove();
	remove.setAttributeIndices("3");
	remove.setInputFormat(data);
	Instances dataToBeClustered = Filter.useFilter(data, remove);

	SimpleKMeans kmeans = new SimpleKMeans();
	kmeans.setSeed(10);
	kmeans.setPreserveInstancesOrder(true);
	kmeans.setNumClusters(3);
	kmeans.buildClusterer(dataToBeClustered);

	IntStream.range(0, 3).mapToObj(i -> {
		Series<Number, Number> newSeries = new XYChart.Series<>();
		newSeries.setName(String.valueOf(i));
		return newSeries;
	}).forEach(clusteredSeries::add);

	int[] assignments = kmeans.getAssignments();
	for (int i = 0; i < assignments.length; i++) {
		int clusterNum = assignments[i];
		clusteredSeries.get(clusterNum).getData().add(instancetoChartData(data.get(i)));
	}

	return clusteredSeries;
}
 
Example #12
Source File: Clustering.java    From java-ml-projects with Apache License 2.0 5 votes vote down vote up
private List<Series<Number, Number>> buildLabeledSeries() {
	List<XYChart.Series<Number, Number>> realSeries = new ArrayList<>();
	Attribute irisClasses = data.attribute(2);
	data.stream().collect(Collectors.groupingBy(d -> {
		int i = (int) d.value(2);
		return irisClasses.value(i);
	})).forEach((e, instances) -> {
		XYChart.Series<Number, Number> series = new XYChart.Series<>();
		series.setName(e);
		instances.stream().map(this::instancetoChartData).forEach(series.getData()::add);
		realSeries.add(series);
	});
	return realSeries;
}
 
Example #13
Source File: OutOfSampleErrorPlotPluginView.java    From AILibs with GNU Affero General Public License v3.0 5 votes vote down vote up
public OutOfSampleErrorPlotPluginView(OutOfSampleErrorPlotPluginModel model) {
	super(model, new LineChart<>(new NumberAxis(), new NumberAxis()));
	getNode().getXAxis().setLabel("elapsed time (s)");
	getNode().setTitle(getTitle());
	believedErrorSeries = new Series<>();
	believedErrorSeries.setName("Believed (internal) Error");
	outOfSampleErrorSeries = new Series<>();
	outOfSampleErrorSeries.setName("Out-of-Sample Error");
	getNode().getData().add(believedErrorSeries);
	getNode().getData().add(outOfSampleErrorSeries);
}
 
Example #14
Source File: SolutionPerformanceTimelinePluginView.java    From AILibs with GNU Affero General Public License v3.0 5 votes vote down vote up
public SolutionPerformanceTimelinePluginView(final SolutionPerformanceTimelinePluginModel model) {
	super(model, new LineChart<>(new NumberAxis(), new NumberAxis()));

	// defining the axes
	this.getNode().getXAxis().setLabel("elapsed time (s)");

	// creating the chart
	this.getNode().setTitle(this.getTitle());
	// defining a series
	this.performanceSeries = new Series<>();
	this.getNode().getData().add(this.performanceSeries);
}
 
Example #15
Source File: TilesFXSeries.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES, final Paint COLOR) {
    series = SERIES;
    stroke = COLOR;
    fill   = COLOR;
    if (null != COLOR) {
        symbolBackground = new Background(new BackgroundFill(COLOR, new CornerRadii(5), Insets.EMPTY), new BackgroundFill(Color.WHITE, new CornerRadii(5), new Insets(2)));
        legendSymbolFill = COLOR;
    }
}
 
Example #16
Source File: TilesFXSeries.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES, final Paint STROKE, final Paint FILL) {
    series = SERIES;
    stroke = STROKE;
    fill   = FILL;
    if (null != stroke & null != fill) {
        symbolBackground = new Background(new BackgroundFill(STROKE, new CornerRadii(5), Insets.EMPTY), new BackgroundFill(Color.WHITE, new CornerRadii(5), new Insets(2)));
        legendSymbolFill = stroke;
    }
}
 
Example #17
Source File: TilesFXSeries.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES, final Paint STROKE, final Paint FILL, final Background SYMBOL_BACKGROUND, final Paint LEGEND_SYMBOL_FILL) {
    series           = SERIES;
    stroke           = STROKE;
    fill             = FILL;
    symbolBackground = SYMBOL_BACKGROUND;
    legendSymbolFill = LEGEND_SYMBOL_FILL;
}
 
Example #18
Source File: TrainingView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #19
Source File: TilesFXSeries.java    From OEE-Designer with MIT License 5 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES, final Paint STROKE, final Paint FILL, final Background SYMBOL_BACKGROUND, final Paint LEGEND_SYMBOL_FILL) {
    series           = SERIES;
    stroke           = STROKE;
    fill             = FILL;
    symbolBackground = SYMBOL_BACKGROUND;
    legendSymbolFill = LEGEND_SYMBOL_FILL;
}
 
Example #20
Source File: TilesFXSeries.java    From OEE-Designer with MIT License 5 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES, final Paint STROKE, final Paint FILL) {
    series = SERIES;
    stroke = STROKE;
    fill   = FILL;
    if (null != stroke & null != fill) {
        symbolBackground = new Background(new BackgroundFill(STROKE, new CornerRadii(5), Insets.EMPTY), new BackgroundFill(Color.WHITE, new CornerRadii(5), new Insets(2)));
        legendSymbolFill = stroke;
    }
}
 
Example #21
Source File: TilesFXSeries.java    From OEE-Designer with MIT License 5 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES, final Paint COLOR) {
    series = SERIES;
    stroke = COLOR;
    fill   = COLOR;
    if (null != COLOR) {
        symbolBackground = new Background(new BackgroundFill(COLOR, new CornerRadii(5), Insets.EMPTY), new BackgroundFill(Color.WHITE, new CornerRadii(5), new Insets(2)));
        legendSymbolFill = COLOR;
    }
}
 
Example #22
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;
}
 
Example #23
Source File: TileBuilder.java    From OEE-Designer with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public final B series(final List<Series<String, Number>> SERIES) {
       properties.put("seriesList", new SimpleObjectProperty(SERIES));
       return (B)this;
   }
 
Example #24
Source File: DashboardController.java    From OEE-Designer with MIT License 4 votes vote down vote up
private void onClickLossCategory(Series<Number, String> series, XYChart.Data<Number, String> lossCategory) {
	showParetoTab(series.getName());
}
 
Example #25
Source File: TileBuilder.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
public final B series(final List<Series<String, Number>> SERIES) {
    properties.put("seriesList", new SimpleObjectProperty(SERIES));
    return (B)this;
}
 
Example #26
Source File: TileBuilder.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
public final B series(final Series<String, Number>... SERIES) {
    properties.put("seriesArray", new SimpleObjectProperty(SERIES));
    return (B)this;
}
 
Example #27
Source File: TilesFXSeries.java    From OEE-Designer with MIT License 4 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES) {
    this(SERIES, null, null);
}
 
Example #28
Source File: TilesFXSeries.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES, final Paint STROKE, final Paint FILL, final Background SYMBOL_BACKGROUND) {
    series           = SERIES;
    stroke           = STROKE;
    fill             = FILL;
    symbolBackground = SYMBOL_BACKGROUND;
}
 
Example #29
Source File: TilesFXSeries.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES, final Paint STROKE, final Paint FILL, final Paint LEGEND_SYMBOL_FILL) {
    series           = SERIES;
    stroke           = STROKE;
    fill             = FILL;
    legendSymbolFill = LEGEND_SYMBOL_FILL;
}
 
Example #30
Source File: TilesFXSeries.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
public TilesFXSeries(final Series<X, Y> SERIES) {
    this(SERIES, null, null);
}