Java 类javafx.scene.chart.XYChart 实例源码

项目:marathonv5    文件:SwingInterop.java   
private BarChart createBarChart() {
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames()));
    xAxis.setLabel("Year");

    double tickUnit = tableModel.getTickUnit();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickUnit(tickUnit);
    yAxis.setLabel("Units Sold");

    final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData());
    tableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (e.getType() == TableModelEvent.UPDATE) {
                final int row = e.getFirstRow();
                final int column = e.getColumn();
                final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column);

                Platform.runLater(new Runnable() {
                    public void run() {
                        XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData().get(row);
                        BarChart.Data data = s.getData().get(column);
                        data.setYValue(value);
                    }
                });
            }
        }
    });
    return chart;
}
项目:Money-Manager    文件:ExpenseChart.java   
public static Series<String, Number> getExpenseData(String monthName) {

    XYChart.Series<String, Number> sector = new XYChart.Series<>();
    String allSector[] = new ComboboxList().getSectorList();

    //chart data for all other Sectors
    for (String sectorName : allSector) {
        String sectorShortName = getAbbreviateName(sectorName);
        double amount = longToDouble(new Sector().getAmountBySectorFromExpense(monthName, sectorName));
        sector.getData().add(new XYChart.Data<>(sectorShortName, amount));
    }           

    //chart data for "Adjusted Balance" Sector
    String srtName = getAbbreviateName("Adjusted Balance");
    double amnt = longToDouble(new Sector().getAmountBySectorFromExpense(monthName, "Adjusted Balance"));
    sector.getData().add(new XYChart.Data<>(srtName, amnt));

    return sector;
}
项目:incubator-netbeans    文件:ChartLine.java   
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    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)
        ))
    );
    LineChart chart = new LineChart(xAxis, yAxis, lineChartData);
    root.getChildren().add(chart);
}
项目:incubator-netbeans    文件:ChartAdvancedScatter.java   
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setSide(Side.TOP);
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setSide(Side.RIGHT);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<5;s++) {
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Data Series "+s);
        for (int i=0; i<30; i++) series.getData().add(new XYChart.Data<Number, Number>(Math.random()*98, Math.random()*98));
        sc.getData().add(series);
    }
    return sc;
}
项目:incubator-netbeans    文件:ChartAdvancedArea.java   
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;
}
项目:incubator-netbeans    文件:ChartAudioArea.java   
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;
}
项目:marathonv5    文件:ChartActions.java   
public static void addDataItemNumStr(final XYChart<Number, String> chart) {
    if (chart.getData() == null) {
        chart.setData(FXCollections.<XYChart.Series<Number, String>>observableArrayList());
    }
    if (chart.getData().isEmpty()) {
        chart.getData().add(new XYChart.Series<Number, String>());
    }

    int sIndex = (int) (Math.random() * chart.getData().size());
    XYChart.Series<Number, String> series = chart.getData().get(sIndex);

    Set<String> existingYears = new HashSet<String>();
    for (Data<Number, String> data : series.getData()) {
        existingYears.add(data.getYValue());
    }

    int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
    while (existingYears.contains(Integer.toString(randomYear))) {
        randomYear++;
    }
    series.getData().add(new XYChart.Data<Number, String>(10 + (Math.random() * 3800), Integer.toString(randomYear)));
}
项目:marathonv5    文件:AdvancedBubbleChartSample.java   
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;
}
项目:marathonv5    文件:AdvancedAreaChartSample.java   
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;
}
项目:Java-oscilloscope-project    文件:ZoomManager.java   
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
        final Collection<? extends XYChart.Data<X, Y>> data) {
    final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
    for (final Data<X, Y> i : data) {
        result.add(new Data<>(i.getXValue(), i.getYValue()));
    }
    return result;
}
项目:marathonv5    文件:AdvCandleStickChartSample.java   
@Override protected void seriesRemoved(Series<Number, Number> series) {
    // remove all candle nodes
    for (XYChart.Data<Number, Number> d : series.getData()) {
        final Node candle = d.getNode();
        if (shouldAnimate()) {
            // fade out old candle
            FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
            ft.setToValue(0);
            ft.setOnFinished(new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent actionEvent) {
                    getPlotChildren().remove(candle);
                }
            });
            ft.play();
        } else {
            getPlotChildren().remove(candle);
        }
    }
}
项目:marathonv5    文件:ChartActions.java   
public static void addDataItemStrNum(final XYChart<String, Number> chart) {
    if (chart.getData() == null) {
        chart.setData(FXCollections.<XYChart.Series<String, Number>>observableArrayList());
    }
    if (chart.getData().isEmpty()) {
        chart.getData().add(new XYChart.Series<String, Number>());
    }

    int sIndex = (int) (Math.random() * chart.getData().size());
    XYChart.Series<String, Number> series = chart.getData().get(sIndex);

    Set<String> existingYears = new HashSet<String>();
    for (Data<String, Number> data : series.getData()) {
        existingYears.add(data.getXValue());
    }

    int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
    while (existingYears.contains(Integer.toString(randomYear))) {
        randomYear++;
    }
    series.getData().add(new XYChart.Data<String, Number>(Integer.toString(randomYear), 10 + (Math.random() * 3800)));
}
项目:marathonv5    文件:AdvancedLineChartSample.java   
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;
}
项目:marathonv5    文件:AdvLineCategoryChartSample.java   
protected LineChart<String, Number> createChart() {
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<String,Number> lc = new LineChart<String,Number>(xAxis,yAxis);
    // setup chart
    lc.setTitle("LineChart with Category Axis");
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    XYChart.Series<String,Number> series = new XYChart.Series<String,Number>();
    series.setName("Data Series 1");
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[0], 50d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[1], 80d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[2], 90d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[3], 30d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[4], 122d));
    series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[5], 10d));
    lc.getData().add(series);
    return lc;
}
项目:marathonv5    文件:LineChartSample.java   
public LineChartSample() {
    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)
        ))
    );
    LineChart chart = new LineChart(xAxis, yAxis, lineChartData);
    getChildren().add(chart);
}
项目:marathonv5    文件:ScatterChartSample.java   
public ScatterChartSample() {
    NumberAxis xAxis = new NumberAxis("X-Axis", 0d, 8.0d, 1.0d);
    NumberAxis yAxis = new NumberAxis("Y-Axis", 0.0d, 5.0d, 1.0d);
    ObservableList<XYChart.Series> data = FXCollections.observableArrayList(
        new ScatterChart.Series("Series 1", FXCollections.<ScatterChart.Data>observableArrayList(
            new XYChart.Data(0.2, 3.5),
            new XYChart.Data(0.7, 4.6),
            new XYChart.Data(1.8, 1.7),
            new XYChart.Data(2.1, 2.8),
            new XYChart.Data(4.0, 2.2),
            new XYChart.Data(4.1, 2.6),
            new XYChart.Data(4.5, 2.0),
            new XYChart.Data(6.0, 3.0),
            new XYChart.Data(7.0, 2.0),
            new XYChart.Data(7.8, 4.0)
        ))
    );
    ScatterChart chart = new ScatterChart(xAxis, yAxis, data);
    getChildren().add(chart);
}
项目:marathonv5    文件:AdvancedAreaChartSample.java   
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;
}
项目:marathonv5    文件:CurveFittedAreaChartSample.java   
public CurveFittedAreaChartSample() {
    CurveFittedAreaChart chart = new CurveFittedAreaChart(
            new NumberAxis(0, 10000, 2500), new NumberAxis(0, 1000, 200));
    chart.setLegendVisible(false);
    chart.setHorizontalGridLinesVisible(false);
    chart.setVerticalGridLinesVisible(false);
    chart.setAlternativeColumnFillVisible(false);
    chart.setAlternativeRowFillVisible(false);
    final XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
    series.getData().addAll(
            new XYChart.Data<Number, Number>(0, 950),
            new XYChart.Data<Number, Number>(2000, 100),
            new XYChart.Data<Number, Number>(5000, 200),
            new XYChart.Data<Number, Number>(7500, 180),
            new XYChart.Data<Number, Number>(10000, 100));
    chart.getData().add(series);
    String curveFittedChartCss = CurveFittedAreaChartSample.class.getResource("CurveFittedChart.css").toExternalForm();
    chart.getStylesheets().add(curveFittedChartCss);
    getChildren().add(chart);
}
项目:marathonv5    文件:AdvCandleStickChartSample.java   
@Override protected void seriesRemoved(Series<Number, Number> series) {
    // remove all candle nodes
    for (XYChart.Data<Number, Number> d : series.getData()) {
        final Node candle = d.getNode();
        if (shouldAnimate()) {
            // fade out old candle
            FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
            ft.setToValue(0);
            ft.setOnFinished(new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent actionEvent) {
                    getPlotChildren().remove(candle);
                }
            });
            ft.play();
        } else {
            getPlotChildren().remove(candle);
        }
    }
}
项目:marathonv5    文件:ImageBarChartSample.java   
public ImageBarChartSample() {

        String imageBarChartCss = ImageBarChartSample.class.getResource("ImageBarChart.css").toExternalForm();

        BarChart barChart = new BarChart(new CategoryAxis(), new NumberAxis());
        barChart.setLegendVisible(false);
        barChart.getStylesheets().add(imageBarChartCss);

        barChart.getData().add(
                new XYChart.Series<String, Integer>("Sales Per Product",
                FXCollections.observableArrayList(
                new XYChart.Data<String, Integer>("SUV", 120),
                new XYChart.Data<String, Integer>("Sedan", 50),
                new XYChart.Data<String, Integer>("Truck", 180),
                new XYChart.Data<String, Integer>("Van", 20))));

        Scene scene = new Scene(barChart, 350, 300);
        scene.getStylesheets().add(ImageBarChartSample.class.getResource("ImageBarChart.css").toString());
        getChildren().add(barChart);
    }
项目:Quantify    文件:QuantifyStatisticsController.java   
@SuppressWarnings("unchecked")
public void setQuantifyData(Data data) {

    List<String> x = new ArrayList<>();
    for (int i = 1; i <= data.getBeforeData().size(); i++) {
        x.add(i + "");
    }
    originData.addAll(x);
    xAxis.setCategories(originData);
    barChart.setBarGap(3);
    XYChart.Series<String, Integer> series1 = new XYChart.Series<>();
    series1.setName("量化前");
    XYChart.Series<String, Integer> series2 = new XYChart.Series<>();
    series2.setName("量化后");
    XYChart.Series<String, Integer> series3 = new XYChart.Series<>();
    series3.setName("差  值");

    for (int i = 0; i < x.size(); i++) {
        series1.getData().add(new XYChart.Data<>(x.get(i), data.getBeforeData().get(i)));
        series2.getData().add(new XYChart.Data<>(x.get(i), data.getAfterData().get(i)));
        series3.getData().add(new XYChart.Data<>(x.get(i), data.getDifferenceData().get(i)));
    }

    barChart.getData().addAll(series1, series2, series3);
}
项目:javafx-chart-zooming    文件:ZoomManager.java   
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
        final Collection<? extends XYChart.Data<X, Y>> data) {
    final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
    for (final Data<X, Y> i : data) {
        result.add(new Data<>(i.getXValue(), i.getYValue()));
    }
    return result;
}
项目:Optics-Simulator    文件:CircleIntensityProfile.java   
/**
 * plotIntensity updates the chart with the proper central-line intensity profile using the set mmDiameter and
 * mmWavelength fields. It also updates the plot line color to correspond with the wavelength in visible light
 */
private void plotIntensity(){
    series.getData().clear();
    double xMin = computeXMin(mmDiameter, mmWavelength);
    double xMax = computeXMax(mmDiameter, mmWavelength);
    double step = computeStep(mmDiameter, mmWavelength);
    for(double x = xMin; x <= xMax; x += step){
        //System.out.printf("%f, %f\n", x, computeRelativeIntensity(x));
        series.getData().add(new XYChart.Data<Number, Number>(x, computeRelativeIntensity(x)));
    }
    //System.out.printf("\n\n\n\n");
    lineChart.setStyle("CHART_COLOR_1: " + WavelengthToColor.getHex(mmWavelength, 1.0) + ";");



}
项目:git-rekt    文件:BookingsReportScreenController.java   
/**
 * Displays on the chart the report data for the selected month.
 */
private void showDataForAllCategories() {
    this.data.clear(); // Clear any existing data

    for(String category : categories) {
        XYChart.Series<String, Number> categoryData;
        categoryData = new XYChart.Series<>();
        categoryData.setName(category);

        for(int i = 1; i <= daysInCurrentMonth.size(); i++) {
            XYChart.Data<String, Number> dayData = new XYChart.Data<>();
            dayData.setXValue(String.valueOf(i));
            double percentBooked = getPercentBookedInCategoryOnDay(category, i);
            dayData.setYValue(percentBooked);
            categoryData.getData().add(dayData);
        }
        this.data.add(categoryData);
    }
    lineChart.setData(this.data);
}
项目:shuffleboard    文件:GraphWidget.java   
private void updateSeries(XYChart.Series<Number, Number> series, long now, double newData) {
  long elapsed = now - Time.getStartTime();
  XYChart.Data<Number, Number> point = new XYChart.Data<>(elapsed, newData);
  ObservableList<XYChart.Data<Number, Number>> dataList = series.getData();
  if (!dataList.isEmpty()) {
    // Make the graph a square wave
    // This prevents the graph from appearing to be continuous when the data is discreet
    // Note this only affects the chart; the actual data is not changed
    double prev = dataList.get(dataList.size() - 1).getYValue().doubleValue();
    if (prev != newData) {
      dataList.add(new XYChart.Data<>(elapsed - 1, prev));
    }
  }
  dataList.add(point);
  realData.computeIfAbsent(series, __ -> FXCollections.observableArrayList()).add(point);
  if (!chart.getData().contains(series)
      && Optional.ofNullable(visibleSeries.get(series)).map(Property::getValue).orElse(true)) {
    chart.getData().add(series);
  }
  updateBounds(elapsed);
}
项目:shuffleboard    文件:GraphWidget.java   
private List<XYChart.Series<Number, Number>> getArraySeries(DataSource<double[]> source) {
  List<XYChart.Series<Number, Number>> series = arraySeriesMap.computeIfAbsent(source, __ -> new ArrayList<>());
  final double[] data = source.getData();
  if (data.length < series.size()) {
    while (series.size() != data.length) {
      XYChart.Series<Number, Number> removed = series.remove(series.size() - 1);
      realData.remove(removed);
      visibleSeries.remove(removed);
    }
  } else if (data.length > series.size()) {
    for (int i = series.size(); i < data.length; i++) {
      XYChart.Series<Number, Number> newSeries = new XYChart.Series<>();
      newSeries.setName(source.getName() + "[" + i + "]"); // eg "array[0]", "array[1]", etc
      series.add(newSeries);
      realData.put(newSeries, FXCollections.observableArrayList());
      visibleSeries.computeIfAbsent(newSeries, createVisibleProperty);
    }
  }
  return series;
}
项目:Recordian    文件:CompanyBarChart.java   
@Override
XYChart.Series<String, Number> barChartData() {
    XYChart.Series<String, Number> series = new XYChart.Series<>();
    List<Company> companies = companyMapper.readAll();
    Integer timesWorkedForCompany;
    for (Company company : companies) {
        timesWorkedForCompany = getNumberOfLogEntriesContainingSpecifiedDatabaseItem(company.getCompanyName());
        series.getData().add(new XYChart.Data<>(company.getCompanyName(), timesWorkedForCompany));
    }
    return series;
}
项目:Java-oscilloscope-project    文件:ZoomManager.java   
private synchronized void restoreData() {
    // make a tmp variable of data, since we will modify it but need to be
    // able to restore
    final ObservableList<XYChart.Series<X, Y>> backup2 = deepCopySeries(series);
    chart.getData().setAll(backup2);

}
项目:Recordian    文件:SupervisorBarChart.java   
@Override
XYChart.Series<String, Number> barChartData() {
    XYChart.Series<String, Number> series = new XYChart.Series<>();
    List<Supervisor> supervisors = supervisorMapper.readAll();
    Integer timesWorkedUnderSupervisor;
    for (Supervisor supervisor : supervisors) {
        timesWorkedUnderSupervisor = getNumberOfLogEntriesContainingSpecifiedDatabaseItem(supervisor.getSupervisorDisplayName());
        series.getData().add(new XYChart.Data<>(supervisor.getSupervisorDisplayName(), timesWorkedUnderSupervisor));
    }
    return series;
}
项目:Recordian    文件:LocationBarChart.java   
@Override
XYChart.Series<String, Number> barChartData() {
    XYChart.Series<String, Number> series = new XYChart.Series<>();
    List<Location> locations = locationMapper.readAll();
    Integer timesWorkedAtLocation;
    for (Location location : locations) {
        timesWorkedAtLocation = getNumberOfLogEntriesContainingSpecifiedDatabaseItem(location.getLocationName());
        series.getData().add(new XYChart.Data<>(location.getLocationName(), timesWorkedAtLocation));
    }
    return series;
}
项目:Lernkartei_2017    文件:StatisticsModel.java   
public ObservableList<XYChart.Series<String, Number>> getObservableDiagrammList (String query)
{
    if (query.equals("saulendiagramm"))
    {
        Debugger.out("StatisticsModel 1");
        return Diagramm.getChartData();
    }
    else
    {
        return null;
    }
}
项目:Lernkartei_2017    文件:Diagramm.java   
public static ObservableList<XYChart.Series<String, Number>> getChartData()
{
    Debugger.out("Diagramm getChartData says : Hello ! ");
        if (Data != null || Data.get(0).equals(null))
        {
            resetData();
        } else
        {
            Logger.out("ObservableList Data in Diagramm is already empty");
        }

        getKarteien();
        getPunkte();

        for (int i = 0; i < Stacks.size(); i++)
        {
            Series<String, Number> thisSerie = new Series<String, Number>();
            thisSerie.setName(Stacks.get(i));
            Number forChart = (Number) Punkte.get(i);
            thisSerie.getData().add(new Data<String, Number>(Stacks.get(i), forChart));
            Data.add(thisSerie);
        }
    return Data;
}
项目:Machine-Learning-End-to-Endguide-for-Java-developers    文件:ScatterChart - MainApp.java   
@Override
public void start(Stage stage) throws Exception {
    stage.setTitle("Scatter Chart Sample");
    final NumberAxis yAxis = new NumberAxis(1400, 2100, 100);
    final NumberAxis xAxis = new NumberAxis(500000, 90000000, 1000000);
    final ScatterChart<Number, Number> scatterChart = new ScatterChart<>(xAxis, yAxis);
    xAxis.setLabel("Population");
    yAxis.setLabel("Decade");
    scatterChart.setTitle("Population Scatter Graph");

    XYChart.Series series = new XYChart.Series();

    try (CSVReader dataReader = new CSVReader(new FileReader("EuropeanScatterData.csv"), ',')) {
        String[] nextLine;
        while ((nextLine = dataReader.readNext()) != null) {
            int decade = Integer.parseInt(nextLine[0]);
            int population = Integer.parseInt(nextLine[1]);
            series.getData().add(new XYChart.Data(population, decade));
            System.out.println("Decade: " + decade + "  Population: " + population);
        }
    }

    scatterChart.getData().addAll(series);
    Scene scene = new Scene(scatterChart, 500, 400);
    stage.setScene(scene);
    stage.show();
}
项目:HueSense    文件:TempSensor.java   
public TempSensor(int id, String uniqueID, HueSenseConfig config, DBManager dbMan) {
    super(id, uniqueID, SensorType.TEMPERATURE, config, dbMan);
    data = new XYChart.Series<>();
    data.setName("Temperature");
    graphInterval = new SimpleObjectProperty<>(GraphInterval.INTERVALS.get(1));
    tempOffset = new SimpleObjectProperty<>(BigDecimal.ZERO);
    if (config.getString(Constants.TEMP_OFFSET_SENSOR + id) != null) {
        tempOffset.set(new BigDecimal(config.getString(Constants.TEMP_OFFSET_SENSOR + id)));
    }
    tempOffset.addListener((observable, oldValue, newValue) -> {
        changeTempOffset();
    });

}
项目:incubator-netbeans    文件:SwingInterop.java   
private BarChart createBarChart() {
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames()));
    xAxis.setLabel("Year");

    double tickUnit = tableModel.getTickUnit();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickUnit(tickUnit);
    yAxis.setLabel("Units Sold");

    final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData());
    tableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (e.getType() == TableModelEvent.UPDATE) {
                final int row = e.getFirstRow();
                final int column = e.getColumn();
                final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column);

                Platform.runLater(new Runnable() {
                    public void run() {
                        XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData().get(row);
                        BarChart.Data data = s.getData().get(column);
                        data.setYValue(value);
                    }
                });
            }
        }
    });
    return chart;
}
项目:incubator-netbeans    文件:ChartAdvancedBar.java   
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;
}
项目:Java-oscilloscope-project    文件:ZoomManager.java   
private void doZoom(final boolean x, final Number n1, final Number n2) {
    final double min = Math.min(n1.doubleValue(), n2.doubleValue());
    final double max = Math.max(n1.doubleValue(), n2.doubleValue());
    if (max - min > 1) {
        zoomed = true;
        final Iterator<XYChart.Series<X, Y>> it = chart.getData().iterator();
        while (it.hasNext()) {
            final XYChart.Series<X, Y> s = it.next();
            final Iterator<XYChart.Data<X, Y>> it2 = s.getData().iterator();
            while (it2.hasNext()) {
                final XYChart.Data<X, Y> d = it2.next();
                final Object value;
                if (x) {
                    value = d.getXValue();
                } else {
                    value = d.getYValue();
                }
                if (value instanceof Number) {
                    final Number n = (Number) value;
                    final double dd = n.doubleValue();
                    if (dd < min || dd > max) {
                        it2.remove();
                    } else {
                    }
                }
                if (s.getData().isEmpty()) {
                    it.remove();
                }
            }
        }
    } else {
        // System.out.println("Skip tiny zoom");
    }

}
项目:pcstatus    文件:StackedAreaChartClass.java   
/**
 * 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
}
项目:pcstatus    文件:StackedAreaChartClass.java   
/**
 * add a value to stacked area chart
 * @param value value to add to the chart
 */
public void addEntryStackedAreaChart(Integer value) {
    series.getData().add(new XYChart.Data(numberOfVisibleEntries, value));
    int maxRange = 10;
    if (numberOfVisibleEntries > maxRange - 1) {
        xAxis.setUpperBound(xAxis.getUpperBound() + 1);
    }
    numberOfVisibleEntries++;
}
项目:marathonv5    文件:AdvancedStockLineChartSample.java   
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;
}