本文整理匯總了Java中javafx.scene.chart.XYChart.getData方法的典型用法代碼示例。如果您正苦於以下問題:Java XYChart.getData方法的具體用法?Java XYChart.getData怎麽用?Java XYChart.getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.chart.XYChart
的用法示例。
在下文中一共展示了XYChart.getData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addDataItemStrNum
import javafx.scene.chart.XYChart; //導入方法依賴的package包/類
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)));
}
示例2: addDataItemNumStr
import javafx.scene.chart.XYChart; //導入方法依賴的package包/類
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)));
}