Java Code Examples for javafx.scene.chart.LineChart#setCreateSymbols()

The following examples show how to use javafx.scene.chart.LineChart#setCreateSymbols() . 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: Main.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static Chart plotFunction(List<Function<Double, Double>> functions, Number xStart, Number xEnd) {
    int div = 500;
    double x0 = xStart.doubleValue();
    double x1 = xEnd.doubleValue();
    double step = 1./div* (x1-x0);
    Axis<Number> xAxis = new NumberAxis(x0, x1, .1* (x1-x0));
    Axis<Number> yAxis = new NumberAxis();
    ObservableList<XYChart.Series<Number, Number>> series = FXCollections.observableArrayList();
    LineChart<Number,Number> chart = new LineChart(xAxis, yAxis, series);
    chart.setCreateSymbols(false);
    for (Function<Double, Double> f: functions) {
        XYChart.Series<Number, Number> mainSeries = new XYChart.Series();
        series.add(mainSeries);
        ObservableList<XYChart.Data<Number, Number>> data = FXCollections.observableArrayList();
        mainSeries.setData(data);
        for (double x = x0; x < x1; x= x +step) {
            final Number y = f.apply(x);
            data.add(new XYChart.Data<>(x,y));
        }
    }
    return chart;

}
 
Example 2
Source File: MultipleAxesLineChart.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private void styleBackgroundChart(final LineChart<?, ?> lineChart, final Color lineColor) {
    styleChartLine(lineChart, lineColor);

    final Node chartContent = lineChart.lookup(".chart-content");
    if (chartContent != null) {
        final Node chartPlotBackground = chartContent.lookup(".chart-plot-background");
        if (chartPlotBackground != null) {
            chartPlotBackground.setStyle("-fx-background-color: transparent;");
        }
    }

    lineChart.setVerticalZeroLineVisible(false);
    lineChart.setHorizontalZeroLineVisible(false);
    lineChart.setVerticalGridLinesVisible(false);
    lineChart.setHorizontalGridLinesVisible(false);
    lineChart.setCreateSymbols(false);
}
 
Example 3
Source File: MultipleAxesLineChart.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private void styleBaseChart(final LineChart<?, ?> baseChart) {
    baseChart.setCreateSymbols(false);
    baseChart.setLegendVisible(false);
    baseChart.getXAxis().setAutoRanging(false);
    baseChart.getXAxis().setAnimated(false);
    baseChart.getYAxis().setAnimated(false);
}
 
Example 4
Source File: ParetoChartController.java    From OEE-Designer with MIT License 5 votes vote down vote up
private LineChart<String, Number> createLineChart(String categoryLabel) {
	// X-Axis category (not shown)
	CategoryAxis xAxis = new CategoryAxis();
	xAxis.setLabel(categoryLabel);
	xAxis.setOpacity(0);

	// Y-Axis (%)
	NumberAxis yAxis = new NumberAxis(0, 100, 10);
	yAxis.setLabel(DesignerLocalizer.instance().getLangString("cum.percent"));
	yAxis.setSide(Side.RIGHT);
	yAxis.setAutoRanging(false);
	yAxis.setUpperBound(100.0d);
	yAxis.setLowerBound(0.0d);

	// create the line chart
	LineChart<String, Number> chLineChart = new LineChart<>(xAxis, yAxis);
	chLineChart.setTitle(chartTitle);
	chLineChart.setLegendVisible(false);
	chLineChart.setAnimated(false);
	chLineChart.setCreateSymbols(true);
	chLineChart.getData().add(lineChartSeries);

	// plot the points
	double total = totalCount.doubleValue();
	Float cumulative = new Float(0f);

	for (ParetoItem paretoItem : this.paretoItems) {
		cumulative += new Float(paretoItem.getValue().floatValue() / total * 100.0f);
		XYChart.Data<String, Number> point = new XYChart.Data<>(paretoItem.getCategory(), cumulative);
		lineChartSeries.getData().add(point);
	}

	return chLineChart;
}
 
Example 5
Source File: AdvancedStockLineChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: AdvancedStockLineChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: ChartAdvancedStockLine.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 8
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 9
Source File: FeatureShapeChart.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public FeatureShapeChart(@Nonnull ModularFeatureListRow row, AtomicDouble progress) {
  try {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<Number, Number> bc = new LineChart<>(xAxis, yAxis);

    DataPoint max = null;
    double maxRT = 0;
    int size = row.getFeatures().size();
    int fi = 0;
    for (ModularFeature f : row.getFeatures().values()) {
      XYChart.Series<Number, Number> data = new XYChart.Series<>();
      List<Integer> scans = f.getScanNumbers();
      List<DataPoint> dps = f.getDataPoints();
      RawDataFile raw = f.getRawDataFile();
      // add data points retention time -> intensity
      for (int i = 0; i < scans.size(); i++) {
        DataPoint dp = dps.get(i);
        double retentionTime = raw.getScan(scans.get(i)).getRetentionTime();
        double intensity = dp == null ? 0 : dp.getIntensity();
        data.getData().add(new XYChart.Data<>(retentionTime, intensity));
        if (dp != null && (max == null || max.getIntensity() < dp.getIntensity())) {
          max = dp;
          maxRT = retentionTime;
        }
        if (progress != null)
          progress.addAndGet(1.0 / size / scans.size());
      }
      fi++;
      bc.getData().add(data);
      if (progress != null)
        progress.set((double) fi / size);
    }

    bc.setLegendVisible(false);
    bc.setMinHeight(100);
    bc.setPrefHeight(100);
    bc.setMaxHeight(100);
    bc.setPrefWidth(150);
    bc.setCreateSymbols(false);

    // do not add data to chart
    xAxis.setAutoRanging(false);
    xAxis.setUpperBound(maxRT + 1.5d);
    xAxis.setLowerBound(maxRT - 1.5d);

    bc.setOnScroll(new EventHandler<>() {
      @Override
      public void handle(ScrollEvent event) {
        NumberAxis axis = xAxis;
        final double minX = xAxis.getLowerBound();
        final double maxX = xAxis.getUpperBound();
        double d = maxX - minX;
        double x = event.getX();
        double direction = event.getDeltaY();
        if (direction > 0) {
          if (d > 0.3) {
            axis.setLowerBound(minX + 0.1);
            axis.setUpperBound(maxX - 0.1);
          }
        } else {
          axis.setLowerBound(minX - 0.1);
          axis.setUpperBound(maxX + 0.1);
        }
        event.consume();
      }
    });

    this.getChildren().add(bc);
  } catch (Exception ex) {
    logger.log(Level.WARNING, "error in DP", ex);
  }
}
 
Example 10
Source File: ChromatogramRenderer.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public TreeTableCell<FeatureTableRow, Object> call(TreeTableColumn<FeatureTableRow, Object> p) {
  return new TreeTableCell<FeatureTableRow, Object>() {
    @Override
    public void updateItem(Object object, boolean empty) {
      super.updateItem(object, empty);
      setStyle(
          "-fx-border-color: transparent -fx-table-cell-border-color -fx-table-cell-border-color transparent;");
      if (object == null) {
        setText(null);
      } else {

        Chromatogram chromatogram = (Chromatogram) object;

        ChromatographyInfo[] chromatographyInfoValues = chromatogram.getRetentionTimes();
        float[] intensityValues = chromatogram.getIntensityValues();
        int numOfDataPoints = chromatogram.getNumberOfDataPoints();

        // x-axis
        NumberAxis xAxis = new NumberAxis();
        xAxis.setTickLabelsVisible(false);
        xAxis.setOpacity(0);
        xAxis.setAutoRanging(false);
        xAxis.setLowerBound(chromatogram.getRtRange().lowerEndpoint().getRetentionTime());
        xAxis.setUpperBound(chromatogram.getRtRange().upperEndpoint().getRetentionTime());

        // y-axis
        NumberAxis yAxis = new NumberAxis();
        yAxis.setTickLabelsVisible(false);
        yAxis.setOpacity(0);

        // Chart line
        final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);
        XYChart.Series series = new XYChart.Series();
        for (int i = 1; i < numOfDataPoints; i++) {
          series.getData().add(new XYChart.Data(chromatographyInfoValues[i].getRetentionTime(),
              intensityValues[i]));
        }

        // Chart
        lineChart.getData().addAll(series);
        lineChart.setLegendVisible(false);
        lineChart.setCreateSymbols(false);
        lineChart.setMinSize(0, 0);
        lineChart.setPrefHeight(75);
        lineChart.setPrefWidth(100);

        setGraphic(lineChart);
      }
    }
  };
}