当前位置: 首页>>代码示例>>Java>>正文


Java LineChart类代码示例

本文整理汇总了Java中javafx.scene.chart.LineChart的典型用法代码示例。如果您正苦于以下问题:Java LineChart类的具体用法?Java LineChart怎么用?Java LineChart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LineChart类属于javafx.scene.chart包,在下文中一共展示了LineChart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import javafx.scene.chart.LineChart; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ChartLine.java

示例2: initialize

import javafx.scene.chart.LineChart; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
    sdf = new SimpleDateFormat(Constants.TIMEFORMAT);

    NumberAxis numberAxis = new NumberAxis();
    DateAxis dateAxis = new DateAxis();
    lightChart = new LineChart<>(dateAxis, numberAxis);
    lightChart.setLegendVisible(false);
    lightChart.setCreateSymbols(false);
    contentPane.setCenter(lightChart);

    intervalCB.setItems(GraphInterval.INTERVALS);
    intervalCB.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (sensor != null) {
            sensor.setGraphInterval(newValue);
        }
    });
    intervalCB.getSelectionModel().select(1);

}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:21,代码来源:LightSensorPresenter.java

示例3: addDataToSeries

import javafx.scene.chart.LineChart; //导入依赖的package包/类
private void addDataToSeries() {
	for (int i = 0; i < 50; i++) { // -- add some new samples to the plot
		if (ErrorProfileView.dataError.isEmpty()) {
			break;
		}
		this.errorSeries.getData().add(
				new LineChart.Data<Number, Number>(this.xSeriesData++,
						ErrorProfileView.dataError.remove()));
	}

	// remove points to keep us at no more than MAX_DATA_POINTS
	if (this.errorSeries.getData().size() > ErrorProfileView.MAX_DATA_POINTS) {
		this.errorSeries.getData().remove(
				0,
				this.errorSeries.getData().size()
						- ErrorProfileView.MAX_DATA_POINTS);
	}

	// update Axis
	this.xAxis.setLowerBound(this.xSeriesData
			- ErrorProfileView.MAX_DATA_POINTS);
	this.xAxis.setUpperBound(this.xSeriesData - 1);

}
 
开发者ID:knr1,项目名称:ch.bfh.mobicomp,代码行数:25,代码来源:ErrorProfileView.java

示例4: simpleIndexChart

import javafx.scene.chart.LineChart; //导入依赖的package包/类
public void simpleIndexChart(Stage stage) {
    stage.setTitle("Index Chart");
    final LineChart<String, Number> lineChart
            = new LineChart<>(xAxis, yAxis);
    lineChart.setTitle("Belgium Population");
    yAxis.setLabel("Population");

    series.setName("Population");
    addDataItem(series, "1950", 8639369);
    addDataItem(series, "1960", 9118700);
    addDataItem(series, "1970", 9637800);
    addDataItem(series, "1980", 9846800);
    addDataItem(series, "1990", 9969310);
    addDataItem(series, "2000", 10263618);

    Scene scene = new Scene(lineChart, 800, 600);
    lineChart.getData().add(series);
    stage.setScene(scene);
    stage.show();
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:21,代码来源:IndexChart - MainApp.java

示例5: createChart

import javafx.scene.chart.LineChart; //导入依赖的package包/类
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;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:AdvancedLineChartSample.java

示例6: createChart

import javafx.scene.chart.LineChart; //导入依赖的package包/类
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;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:AdvLineCategoryChartSample.java

示例7: LineChartSample

import javafx.scene.chart.LineChart; //导入依赖的package包/类
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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:23,代码来源:LineChartSample.java

示例8: MonitorPaneTemplate

import javafx.scene.chart.LineChart; //导入依赖的package包/类
public MonitorPaneTemplate()
{
    super();
    super.getStyleClass().add("pane");
    
    x = new NumberAxis();
    x.setAutoRanging(false);
    
    y = new NumberAxis();
    y.setAutoRanging(false);
    
    chart = new LineChart<>(x, y);
    chart.setCreateSymbols(false);
    chart.legendVisibleProperty().setValue(false);
    chart.setPrefHeight(250);
    chart.setPrefWidth(750);
    
    data = new Series<>();
    
    chart.getData().add(data);
    
    super.getChildren().add(chart);
}
 
开发者ID:BlueGoliath,项目名称:Goliath-Overclocking-Utility-FX,代码行数:24,代码来源:MonitorPaneTemplate.java

示例9: createZoomOutLineChartEventHandler

import javafx.scene.chart.LineChart; //导入依赖的package包/类
private static EventHandler<Event> createZoomOutLineChartEventHandler(LineChart<String, Number> lineChart,
        Scene scene, int originalIndexInParent) {
    return new EventHandler<Event>() {
        @Override
        public void handle(Event e) {
            lineChart.removeEventHandler(MouseEvent.MOUSE_CLICKED, this);

            zoomOutAndReset(lineChart);

            resetToOriginalIndexInParent(lineChart, originalIndexInParent);

            lineChart.addEventHandler(MouseEvent.MOUSE_CLICKED,
                    createZoomInLineChartEventHandler(lineChart, scene));
        }

    };
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:18,代码来源:StatsDisplay.java

示例10: createZoomInLineChartEventHandler

import javafx.scene.chart.LineChart; //导入依赖的package包/类
private static EventHandler<Event> createZoomInLineChartEventHandler(LineChart<String, Number> lineChart,
        Scene scene) {
    return new EventHandler<Event>() {
        @Override
        public void handle(Event e) {
            lineChart.removeEventHandler(MouseEvent.MOUSE_CLICKED, this);

            int originalIndexInParent = getOriginalIndexInParent(lineChart);

            zoomInAndCenter(lineChart, lineChart.getWidth(), lineChart.getHeight(), false);

            lineChart.addEventHandler(MouseEvent.MOUSE_CLICKED,
                    createZoomOutLineChartEventHandler(lineChart, scene, originalIndexInParent));
        }
    };
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:17,代码来源:StatsDisplay.java

示例11: initialize

import javafx.scene.chart.LineChart; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
    sdf = new SimpleDateFormat(Constants.TIMEFORMAT);

    NumberAxis numberAxis = new NumberAxis();
    DateAxis dateAxis = new DateAxis();
    lightChart = new LineChart<>(dateAxis, numberAxis);
    contentPane.setCenter(lightChart);

    intervalCB.setItems(GraphInterval.INTERVALS);
    intervalCB.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (sensor != null) {
            sensor.setGraphInterval(newValue);
        }
    });
    intervalCB.getSelectionModel().select(1);

}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:19,代码来源:PingSensorPresenter.java

示例12: initialize

import javafx.scene.chart.LineChart; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
    sdf = new SimpleDateFormat(Constants.TIMEFORMAT);
    isNameEdit = false;

    NumberAxis numberAxis = new NumberAxis();
    numberAxis.setForceZeroInRange(false);
    DateAxis dateAxis = new DateAxis();
    tempChart = new LineChart<>(dateAxis, numberAxis);
    tempChart.setLegendVisible(false);
    tempChart.setCreateSymbols(false);
    contentPane.setCenter(tempChart);

    intervalCB.setItems(GraphInterval.INTERVALS);
    intervalCB.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (sensor != null) {
            sensor.setGraphInterval(newValue);
        }
    });
    intervalCB.getSelectionModel().select(1);

    offsetCB.setItems(OFFSET_VALUES);
    offsetCB.getSelectionModel().select(6);

}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:26,代码来源:TempSensorPresenter.java

示例13: DashboardPIDTuner

import javafx.scene.chart.LineChart; //导入依赖的package包/类
public DashboardPIDTuner(String name) {
	super(name, FlashboardSendableType.PIDTUNER);
	
	series = new LineChart.Series<Number, Number>();
	
	kp = new SimpleDoubleProperty();
	ki = new SimpleDoubleProperty();
	kd = new SimpleDoubleProperty();
	kf = new SimpleDoubleProperty();
	setpoint = new SimpleDoubleProperty();
	valueBinder = new SimpleDoubleProperty();
	timeBinder = new SimpleDoubleProperty();
	funcPeriodBinder = new SimpleDoubleProperty();
	
	setpointBinder = new SimpleStringProperty("0.0");
	
	tuners.put(name, this);
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:19,代码来源:DashboardPIDTuner.java

示例14: createLineChart

import javafx.scene.chart.LineChart; //导入依赖的package包/类
/**
 * get the LineChart for this history
 * @return - the line chart
 */
@SuppressWarnings("rawtypes")
public LineChart<Number, Number> createLineChart() {
  //defining the axes
  final NumberAxis xAxis = new NumberAxis();
  final NumberAxis yAxis = new NumberAxis();
  xAxis.setLabel(xTitle);
  //creating the chart
  lineChart = 
          new LineChart<Number,Number>(xAxis,yAxis);
          
  lineChart.setTitle(title);
  for (CANProperty canProperty : this.canProperties.values()) {
    Series<Number, Number> series = this.createSeries(canProperty);
    seriesMap.put(canProperty.getName(), series);
    updateSeries(series,canProperty);
    lineChart.getData().add(series);
  }
  return lineChart;
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:24,代码来源:JFXCanValueHistoryPlot.java

示例15: start

import javafx.scene.chart.LineChart; //导入依赖的package包/类
@Override public void start(Stage stage) {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    xAxis.setLabel(xName);
    yAxis.setLabel(yName);
    
    final LineChart<Number,Number> lineChart = new LineChart<Number,Number>(xAxis,yAxis);
            
    lineChart.setTitle(title);
                            
    XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
    for (int i=1; i<n+1; i++){
        series.getData().add(new XYChart.Data<Number, Number>(x[i], y[i]));
    }
    
    Scene scene  = new Scene(lineChart,800,600);
    lineChart.getData().add(series);
   
    stage.setScene(scene);
    stage.show();
}
 
开发者ID:roycan,项目名称:cs131_finals_2016,代码行数:22,代码来源:Graph2.java


注:本文中的javafx.scene.chart.LineChart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。