All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lwhite1.tablesaw.plotting.fx.FxBuilder Maven / Gradle / Ivy

There is a newer version: 0.7.7.3
Show newest version
package com.github.lwhite1.tablesaw.plotting.fx;

import com.github.lwhite1.tablesaw.api.NumericColumn;
import com.github.lwhite1.tablesaw.columns.Column;
import javafx.collections.FXCollections;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.layout.Background;

import java.util.List;

/**
 *
 */
public class FxBuilder {

  static NumberAxis getNumberAxis(NumericColumn numericColumn) {
    final NumberAxis numberAxis = new NumberAxis();
    numberAxis.setLabel(numericColumn.name());
    return numberAxis;
  }

  static CategoryAxis getCategoryAxis(Column categoryColumn) {
    final CategoryAxis categoryAxis = new CategoryAxis();
    categoryAxis.setLabel(categoryColumn.name());
    return categoryAxis;
  }

  static XYChart.Series getSeries(NumericColumn numericColumn, List> data) {
    XYChart.Series series1
        = new XYChart.Series<>(FXCollections.observableList(data));

    series1.setName(numericColumn.name());
    return series1;
  }

  static BarChart getBarChart(String title, CategoryAxis categoryAxis, NumberAxis numberAxis) {

    BarChart bar = new BarChart<>(categoryAxis, numberAxis);
    bar.setTitle(title);
    bar.setLegendVisible(false);
    bar.setCategoryGap(0.0);
    bar.setBarGap(0.1);
    bar.setBackground(Background.EMPTY);
    bar.setVerticalGridLinesVisible(false);
    return bar;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy