本文整理汇总了Java中javafx.scene.chart.CategoryAxis.setLabel方法的典型用法代码示例。如果您正苦于以下问题:Java CategoryAxis.setLabel方法的具体用法?Java CategoryAxis.setLabel怎么用?Java CategoryAxis.setLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.chart.CategoryAxis
的用法示例。
在下文中一共展示了CategoryAxis.setLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBarChart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
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;
}
示例2: createChart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的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;
}
示例3: createChart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
protected BarChart<String, Number> createChart() {
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis(0,50,10);
final BarChart<String,Number> bc = new BarChart<String,Number>(xAxis,yAxis);
bc.setId("barAudioDemo");
bc.setLegendVisible(false);
bc.setAnimated(false);
bc.setBarGap(0);
bc.setCategoryGap(1);
bc.setVerticalGridLinesVisible(false);
// setup chart
bc.setTitle("Live Audio Spectrum Data");
xAxis.setLabel("Frequency Bands");
yAxis.setLabel("Magnitudes");
yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB"));
// add starting data
XYChart.Series<String,Number> series1 = new XYChart.Series<String,Number>();
series1.setName("Data Series 1");
//noinspection unchecked
series1Data = new XYChart.Data[128];
String[] categories = new String[128];
for (int i=0; i<series1Data.length; i++) {
categories[i] = Integer.toString(i+1);
series1Data[i] = new XYChart.Data<String,Number>(categories[i],50);
series1.getData().add(series1Data[i]);
}
bc.getData().add(series1);
return bc;
}
示例4: displayIndex
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
private void displayIndex(Map<String, Double> resultIndex, String title, String header) {
BaseDialog dialog = new BaseDialog(title, header);
dialog.getDialogPane().setPrefSize(800, 600);
dialog.getDialogPane().getButtonTypes().addAll(new ButtonType(Configuration.getBundle().getString("ui.actions.stats.close"), ButtonBar.ButtonData.CANCEL_CLOSE));
// draw
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
final LineChart<String,Number> lineChart = new LineChart<>(xAxis, yAxis);
lineChart.setTitle(title);
lineChart.setLegendVisible(false);
xAxis.setLabel(Configuration.getBundle().getString("ui.actions.stats.xaxis"));
yAxis.setLabel(Configuration.getBundle().getString("ui.actions.readable.yaxis"));
XYChart.Series<String, Number> series = new XYChart.Series();
for(Map.Entry<String, Double> st:resultIndex.entrySet()) {
series.getData().add(new XYChart.Data(st.getKey(), st.getValue()));
}
lineChart.getData().addAll(series);
dialog.getDialogPane().setContent(lineChart);
dialog.setResizable(true);
dialog.showAndWait();
}
示例5: handleFirstLoginsChart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
private void handleFirstLoginsChart() throws IOException, InterruptedException, ExecutionException {
FutureRequest<LinkedHashMap<LocalDateTime, Integer>> requestResult = sock.submit(new NewPlayerLoginsRequest(
startDatePicker.getValue(),
endDatePicker.getValue().plusDays(1)
));
LinkedHashMap<LocalDateTime, Integer> counts = requestResult.get();
XYChart.Series<String, Number> series = new XYChart.Series<>();
for(Map.Entry<LocalDateTime, Integer> e : counts.entrySet()) {
series.getData().add(new XYChart.Data(e.getKey().toString(), e.getValue()));
}
series.setName("New Players");
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Time Joined");
yAxis.setLabel("Players Joined");
yAxis.setTickLength(5);
yAxis.setMinorTickLength(1);
xAxis.setAutoRanging(true);
final BarChart<String, Number> barChart = new BarChart<>(xAxis, yAxis);
barChart.setTitle("New Players");
barChart.getData().add(series);
chartPane.setCenter(barChart);
chartPane.layout();
}
示例6: createChart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
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;
}
示例7: createChart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
protected BarChart<Number, String> createChart() {
final String[] years = {"2007", "2008", "2009"};
final CategoryAxis yAxis = new CategoryAxis();
final NumberAxis xAxis = new NumberAxis();
final BarChart<Number,String> bc = new BarChart<Number,String>(xAxis,yAxis);
// setup chart
bc.setTitle("Horizontal Bar Chart Example");
yAxis.setLabel("Year");
yAxis.setCategories(FXCollections.<String>observableArrayList(Arrays.asList(years)));
xAxis.setLabel("Price");
// add starting data
XYChart.Series<Number,String> series1 = new XYChart.Series<Number,String>();
series1.setName("Data Series 1");
XYChart.Series<Number,String> series2 = new XYChart.Series<Number,String>();
series2.setName("Data Series 2");
XYChart.Series<Number,String> series3 = new XYChart.Series<Number,String>();
series3.setName("Data Series 3");
series1.getData().add(new XYChart.Data<Number,String>(567, years[0]));
series1.getData().add(new XYChart.Data<Number,String>(1292, years[1]));
series1.getData().add(new XYChart.Data<Number,String>(2180, years[2]));
series2.getData().add(new XYChart.Data<Number,String>(956, years[0]));
series2.getData().add(new XYChart.Data<Number,String>(1665, years[1]));
series2.getData().add(new XYChart.Data<Number,String>(2450, years[2]));
series3.getData().add(new XYChart.Data<Number,String>(800, years[0]));
series3.getData().add(new XYChart.Data<Number,String>(1000, years[1]));
series3.getData().add(new XYChart.Data<Number,String>(2800, years[2]));
bc.getData().add(series1);
bc.getData().add(series2);
bc.getData().add(series3);
return bc;
}
示例8: start
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
BorderPane root = new BorderPane();
JFXTabPane tabPane = new JFXTabPane();
Tab tab1 = new Tab();
tab1.setText("Graph Tab");
Tab tab2 = new Tab();
tab2.setText("Empty Tab");
BorderPane gPane = new BorderPane();
CategoryAxis x = new CategoryAxis();
x.setLabel("Visited Sites");
NumberAxis y = new NumberAxis();
y.setLabel("Hits");
lineChart = new LineChart<>(x, y);
set2 = new XYChart.Series<>();
set2.getData().add(new XYChart.Data("Ramzan",62));
// set2.getData().add(new XYChart.Data("Hussan",421));
// set2.getData().add(new XYChart.Data("Shoaib",92));
// set2.getData().add(new XYChart.Data("Sudo",42));
lineChart.setTitle("History Statistics");
lineChart.getData().add(set2);
JFXButton button = new JFXButton("add");
button.addEventHandler(MouseEvent.MOUSE_CLICKED, e ->{
set2.getData().remove(0);
set2.getData().add(new XYChart.Data("chhala",45));
});
gPane.setCenter(lineChart);
gPane.setLeft(button);
tab1.setContent(gPane);
tabPane.getTabs().addAll(tab1,tab2);
root.setCenter(tabPane);
Scene scene = new Scene(root,800,600);
stage.setScene(scene);
stage.show();
final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
Random rand = new Random();
System.out.println(set2.getData().size());
java.util.Date date = new java.util.Date();
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
set2.getData().add(new XYChart.Data(timeFormat.format(date),rand.nextInt(20)));
}
}, 0, 1, TimeUnit.SECONDS);
}
示例9: showTrackingData
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
public void showTrackingData(){
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("TDD Trainer by Team ImmortalsGG");
alert.setHeaderText("Klick 'show details' fuer einen Graph deiner Aktivitaet");
CategoryAxis tasks = new CategoryAxis();
NumberAxis time = new NumberAxis();
BarChart<String,Number> barChart = new BarChart<>(tasks,time);
if (log.size()==1){
barChart.setTitle("Tracking Information: Ein Schritt bis jetzt");
}else {
barChart.setTitle("Tracking Information: " + log.size() + " Schritte bis jetzt");
}
tasks.setLabel("Schritte");
time.setLabel("verbrachte Zeit");
XYChart.Series series1 = new XYChart.Series();
for(TDDTuple date : log){
series1.getData().add(new XYChart.Data(date.getTask(), date.getSeconds()));
}
barChart.getData().addAll(series1);
barChart.setPrefWidth(1000);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(barChart,0,0);
alert.getDialogPane().setExpandableContent(expContent);
alert.showAndWait();
}
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-immortalsgg,代码行数:33,代码来源:TDDAlert.java
示例10: chart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
public static BarChart<String, Number> chart(
String title,
CategoryColumn x,
NumericColumn y) {
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel(x.name());
yAxis.setLabel(y.name());
Table t = Table.create("", x, y);
t = t.sortDescendingOn(y.name());
final BarChart<String, Number> bar = new BarChart<>(xAxis, yAxis);
bar.setTitle(title);
List<XYChart.Data<String, Number>> d2 = new ArrayList<>(x.size());
for (int i = 0; i < x.size(); i++) {
d2.add(new XYChart.Data<>(t.categoryColumn(0).get(i), t.nCol(1).getFloat(i)));
}
XYChart.Series<String, Number> series1
= new XYChart.Series<>(FXCollections.observableList(d2));
series1.setName(y.name());
bar.setLegendVisible(false);
bar.setCategoryGap(0.0);
bar.setBarGap(0.1);
bar.setBackground(Background.EMPTY);
bar.setVerticalGridLinesVisible(false);
bar.getData().add(series1);
return bar;
}
示例11: GraphModel
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
public GraphModel() {
xAxis = new CategoryAxis();
xAxis.setLabel("Sätze");
xAxis.setTickLabelRotation(70d);
yAxis = new NumberAxis();
yAxis.setUpperBound(100);
yAxis.setLowerBound(0);
yAxis.setAutoRanging(false);
yAxis.setLabel("Prozent");
}
示例12: createChart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
public LineChart<String, Number> createChart(LabelledRadiusPane pane) {
CategoryAxis xAxis = new CategoryAxis();
NumberAxis yAxis = new NumberAxis();
chart = new LineChart<>(xAxis, yAxis);
chart.setTitle("Tweet Trend Analysis");
chart.setCreateSymbols(false);
chart.setLegendVisible(false);
xAxis.setLabel("Time of Tweet");
yAxis.setUpperBound(1.0);
yAxis.setLowerBound(0.0);
yAxis.setLabel("Anomaly\n Score");
yAxis.setForceZeroInRange(true);
series = new XYChart.Series<>();
series.setName("Tweet Data");
chart.getData().add(series);
chartSeriesProperty.set(series);
Node line = series.getNode().lookup(".chart-series-line");
line.setStyle("-fx-stroke: rgb(20, 164, 220)");
chart.setPrefWidth(1200);
chart.setPrefHeight(275);
chart.setLayoutY(pane.labelHeightProperty().get() + 10);
return chart;
}
示例13: handleUniqueLoginsChart
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
private void handleUniqueLoginsChart() throws IOException, InterruptedException, ExecutionException {
final LocalDate start = startDatePicker.getValue();
final LocalDate end = endDatePicker.getValue().plusDays(1);
FutureRequest<Map<LocalDate, Integer>> requestResult = sock.submit(new UniqueLoginsPerDayRequest(
start, end));
Map<LocalDate, Integer> uniqueLogins = requestResult.get();
LocalDate c = start;
XYChart.Series<String, Number> series = new XYChart.Series<>();
while(c.isBefore(end)) {
if(uniqueLogins.containsKey(c)) {
series.getData().add(new XYChart.Data(c.toString(), uniqueLogins.get(c)));
} else {
series.getData().add(new XYChart.Data(c.toString(), 0));
}
c = c.plusDays(1);
}
series.setName("Unique Logins per Day");
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Day");
yAxis.setLabel("Unique Logins");
yAxis.setTickLength(5);
yAxis.setMinorTickLength(1);
xAxis.setAutoRanging(true);
final BarChart<String, Number> barChart = new BarChart<>(xAxis, yAxis);
barChart.setTitle("Unique Logins");
barChart.getData().add(series);
chartPane.setCenter(barChart);
chartPane.layout();
}
示例14: getResultsContent
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Parent getResultsContent() {
NumberAxis xAxis = new NumberAxis();
CategoryAxis yAxis = new CategoryAxis();
BarChart<Number, String> chart = new BarChart<>(xAxis, yAxis);
chart.setTitle("Data structure packet size based on number of packets");
yAxis.setLabel("Number of Packets");
yAxis.setCategories(FXCollections.<String>observableArrayList(Arrays.asList(new String[] {String.valueOf(numPackets)})));
xAxis.setLabel("Size (in bytes). Lower is better");
for (int i = 0; i < results.size(); i++) {
XYChart.Series<Number, String> series = new XYChart.Series<Number, String>();
series.setName(results.get(i).name);
series.getData().addAll(
new XYChart.Data<Number, String>(results.get(i).size, String.valueOf(numPackets))
// new XYChart.Data<Number, String>(results1000.get(i).size, "1000"),
// new XYChart.Data<Number, String>(results10000.get(i).size, "10000")
);
series.getData().forEach(data -> {
Label l = new Label(data.getXValue().toString());
l.setAlignment(Pos.CENTER_RIGHT);
data.setNode(l);
});
chart.getData().add(series);
}
return chart;
}
示例15: getResultsContent
import javafx.scene.chart.CategoryAxis; //导入方法依赖的package包/类
@Override
public Parent getResultsContent() {
NumberAxis xAxis = new NumberAxis();
CategoryAxis yAxis = new CategoryAxis();
BarChart<Number, String> chart = new BarChart<>(xAxis, yAxis);
chart.setTitle(String.valueOf(numPackets) + " packets");
yAxis.setLabel("Compression");
yAxis.setCategories(FXCollections.<String>observableArrayList("NONE", "ZIP", "LZMA"));
xAxis.setLabel("Time (in seconds). Lower is better");
for (int i = 0; i < results.size(); i++) {
XYChart.Series<Number, String> series = new XYChart.Series<Number, String>();
series.setName(results.get(i).name);
series.getData().addAll(
new XYChart.Data<Number, String>(results.get(i).timeTook, "NONE"),
new XYChart.Data<Number, String>(results.get(i).timeTookZIP + results.get(i).timeTook, "ZIP"),
new XYChart.Data<Number, String>(results.get(i).timeTookLZMA + results.get(i).timeTook, "LZMA")
);
series.getData().forEach(data -> {
Label l = new Label(String.format("%.3f", data.getXValue().doubleValue()));
l.setAlignment(Pos.CENTER_RIGHT);
data.setNode(l);
});
chart.getData().add(series);
}
return chart;
}