Java Code Examples for javafx.scene.chart.CategoryAxis#setLabel()
The following examples show how to use
javafx.scene.chart.CategoryAxis#setLabel() .
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: SwingInterop.java From marathonv5 with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: AdvLineCategoryChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: MenuController.java From zest-writer with GNU General Public License v3.0 | 6 votes |
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(); }
Example 4
Source File: AdvLineCategoryChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: AdvHorizontalBarChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: InfluenceAnalysisUI.java From SONDY with GNU General Public License v3.0 | 5 votes |
public final void initializeRankDistributionChart(){ xAxis = new CategoryAxis(); yAxis = new NumberAxis(); xAxis.setLabel("Rank"); xAxis.setTickLength(5); yAxis.setTickLabelsVisible(false); yAxis.setTickMarkVisible(false); rankDistributionChart = new BarChart(xAxis,yAxis); rankDistributionChart.setLegendVisible(false); UIUtils.setSize(rankDistributionChart, Main.columnWidthRIGHT+5, 300); rankDistributionChart.setCategoryGap(0); }
Example 7
Source File: BreakingNewsDemoView.java From htm.java-examples with GNU Affero General Public License v3.0 | 5 votes |
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; }
Example 8
Source File: ChartGenerator.java From testgrid with Apache License 2.0 | 5 votes |
/** * Generates the history chart with the summary of test executions. * * @param dataSet input data-set for the chart * @param historyChartFileName file name of the history graph */ public void generateResultHistoryChart(Map<String, BuildExecutionSummary> dataSet, String historyChartFileName) { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); final StackedBarChart<String, Number> stackedBarChart = new StackedBarChart<>(xAxis, yAxis); // This represents the series of values e.g: Failed, skipped, Passed final XYChart.Series<String, Number>[] seriesSet = new XYChart.Series[]{new XYChart.Series<>(), new XYChart.Series<>(), new XYChart.Series<>()}; xAxis.setCategories(FXCollections.<String>observableArrayList(dataSet.keySet())); // Disabling animation xAxis.setAnimated(false); yAxis.setAnimated(false); stackedBarChart.setAnimated(false); // Set Axis Names xAxis.setLabel("Build date"); yAxis.setLabel("Number of infrastructure combinations"); // Setting series names seriesSet[0].setName("Test failures"); seriesSet[1].setName("Deployment errors"); seriesSet[2].setName("Test passed"); // Setting space between the bars stackedBarChart.setCategoryGap(50); //Setting the title of the bar chart. stackedBarChart.setTitle("Test Run History"); dataSet.forEach((key, summary) -> { seriesSet[0].getData().add(new XYChart.Data<>(key, summary.getFailedTestPlans())); seriesSet[1].getData().add(new XYChart.Data<>(key, summary.getSkippedTestPlans())); seriesSet[2].getData().add(new XYChart.Data<>(key, summary.getPassedTestPlans())); }); // Adding the series to the chart for (XYChart.Series series : seriesSet) { stackedBarChart.getData().add(series); } genChart(stackedBarChart, 800, 800, historyChartFileName, "styles/summary.css"); }
Example 9
Source File: ChartAudioBar.java From netbeans with Apache License 2.0 | 5 votes |
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; }
Example 10
Source File: ChartAdvancedBar.java From netbeans with Apache License 2.0 | 5 votes |
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; }
Example 11
Source File: SwingInterop.java From netbeans with Apache License 2.0 | 5 votes |
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; }
Example 12
Source File: AdvBarAudioChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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; }
Example 13
Source File: AdvancedBarChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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; }
Example 14
Source File: SwingInterop.java From marathonv5 with Apache License 2.0 | 5 votes |
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; }
Example 15
Source File: AdvBarAudioChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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; }
Example 16
Source File: AdvancedBarChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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; }
Example 17
Source File: AdvHorizontalBarChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
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; }
Example 18
Source File: ParetoChartController.java From OEE-Designer with MIT License | 5 votes |
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 19
Source File: ParetoChartController.java From OEE-Designer with MIT License | 4 votes |
private BarChart<String, Number> createBarChart(String categoryLabel) { // X-Axis category CategoryAxis xAxis = new CategoryAxis(); xAxis.setLabel(categoryLabel); // Y-Axis (%) NumberAxis yAxis = new NumberAxis(0, 100, 10); yAxis.setLabel(DesignerLocalizer.instance().getLangString("percent")); yAxis.setAutoRanging(false); yAxis.setUpperBound(100.0d); yAxis.setLowerBound(0.0d); // create bar chart BarChart<String, Number> chBarChart = new BarChart<>(xAxis, yAxis); chBarChart.setTitle(chartTitle); chBarChart.setLegendVisible(false); chBarChart.setAnimated(false); chBarChart.getData().add(barChartSeries); // add the points double total = totalCount.doubleValue(); if (total > 0.0d) { int count = 0; for (ParetoItem paretoItem : paretoItems) { if (count > TOP_N) { break; } count++; Float percentage = new Float(paretoItem.getValue().floatValue() / total * 100.0f); XYChart.Data<String, Number> point = new XYChart.Data<>(paretoItem.getCategory(), percentage); barChartSeries.getData().add(point); } } // add listener for mouse click on bar for (Series<String, Number> series : chBarChart.getData()) { for (XYChart.Data<String, Number> item : series.getData()) { item.getNode().setOnMouseClicked((MouseEvent event) -> { onBarChartNodeSelected(item); }); } } return chBarChart; }