apps/samples/Ensemble8/src/samples/java/ensemble/samples/charts/bar/horizontal/HorizontalBarChartApp.java

Print this page




  37 import javafx.collections.FXCollections;
  38 import javafx.scene.Parent;
  39 import javafx.scene.Scene;
  40 import javafx.scene.chart.BarChart;
  41 import javafx.scene.chart.CategoryAxis;
  42 import javafx.scene.chart.NumberAxis;
  43 import javafx.scene.chart.XYChart;
  44 import javafx.stage.Stage;
  45 
  46 
  47 /**
  48  * Horizontal bar chart with a variety of actions and settable properties for
  49  * experimenting with the charts features.
  50  *
  51  * @sampleName Horizontal Bar Chart
  52  * @preview preview.png
  53  * @see javafx.scene.chart.BarChart
  54  * @see javafx.scene.chart.CategoryAxis
  55  * @see javafx.scene.chart.NumberAxis
  56  * @playground chart.data
  57  * 
  58  * @playground - (name="xAxis")
  59  * @playground xAxis.autoRanging
  60  * @playground xAxis.forceZeroInRange
  61  * @playground xAxis.lowerBound (min=-1000,max=3000,step=1)
  62  * @playground xAxis.upperBound (max=4000,step=1)
  63  * @playground xAxis.tickUnit (max=3000,step=1)
  64  * @playground xAxis.minorTickCount (max=16)
  65  * @playground xAxis.minorTickLength (max=15)
  66  * @playground xAxis.minorTickVisible
  67  * 
  68  * @playground xAxis.animated
  69  * @playground xAxis.label
  70  * @playground xAxis.side
  71  * @playground xAxis.tickLabelFill
  72  * @playground xAxis.tickLabelGap
  73  * @playground xAxis.tickLabelRotation (min=-180,max=180,step=1)
  74  * @playground xAxis.tickLabelsVisible
  75  * @playground xAxis.tickLength
  76  * @playground xAxis.tickMarkVisible
  77  * 
  78  * @playground - (name="yAxis")
  79  * @playground yAxis.autoRanging
  80  * @playground yAxis.gapStartAndEnd
  81  * @playground yAxis.startMargin
  82  * @playground yAxis.endMargin
  83  * 
  84  * @playground yAxis.animated
  85  * @playground yAxis.label
  86  * @playground yAxis.side
  87  * @playground yAxis.tickLabelFill
  88  * @playground yAxis.tickLabelGap
  89  * @playground yAxis.tickLabelRotation (min=-180,max=180,step=1)
  90  * @playground yAxis.tickLabelsVisible
  91  * @playground yAxis.tickLength
  92  * @playground yAxis.tickMarkVisible
  93  * 
  94  * @playground - (name="chart")
  95  * @playground chart.horizontalGridLinesVisible
  96  * @playground chart.horizontalZeroLineVisible
  97  * @playground chart.verticalGridLinesVisible
  98  * @playground chart.verticalZeroLineVisible
  99  * 
 100  * @playground chart.animated
 101  * @playground chart.legendSide
 102  * @playground chart.legendVisible
 103  * @playground chart.title
 104  * @playground chart.titleSide
 105  */
 106 public class HorizontalBarChartApp extends Application {
 107 
 108     private BarChart<Number, String> chart;
 109     private NumberAxis xAxis;
 110     private CategoryAxis yAxis;
 111 
 112     public Parent createContent() {
 113         final String[] years = {"2007", "2008", "2009"};
 114         xAxis = new NumberAxis();
 115         yAxis = new CategoryAxis();
 116         chart = new BarChart<>(xAxis, yAxis);
 117         chart.setTitle("Horizontal Bar Chart Example");
 118         yAxis.setLabel("Year");
 119         yAxis.setCategories(FXCollections.<String>observableArrayList(Arrays




  37 import javafx.collections.FXCollections;
  38 import javafx.scene.Parent;
  39 import javafx.scene.Scene;
  40 import javafx.scene.chart.BarChart;
  41 import javafx.scene.chart.CategoryAxis;
  42 import javafx.scene.chart.NumberAxis;
  43 import javafx.scene.chart.XYChart;
  44 import javafx.stage.Stage;
  45 
  46 
  47 /**
  48  * Horizontal bar chart with a variety of actions and settable properties for
  49  * experimenting with the charts features.
  50  *
  51  * @sampleName Horizontal Bar Chart
  52  * @preview preview.png
  53  * @see javafx.scene.chart.BarChart
  54  * @see javafx.scene.chart.CategoryAxis
  55  * @see javafx.scene.chart.NumberAxis
  56  * @playground chart.data

  57  * @playground - (name="xAxis")
  58  * @playground xAxis.autoRanging
  59  * @playground xAxis.forceZeroInRange
  60  * @playground xAxis.lowerBound (min=-1000,max=3000,step=1)
  61  * @playground xAxis.upperBound (max=4000,step=1)
  62  * @playground xAxis.tickUnit (max=3000,step=1)
  63  * @playground xAxis.minorTickCount (max=16)
  64  * @playground xAxis.minorTickLength (max=15)
  65  * @playground xAxis.minorTickVisible

  66  * @playground xAxis.animated
  67  * @playground xAxis.label
  68  * @playground xAxis.side
  69  * @playground xAxis.tickLabelFill
  70  * @playground xAxis.tickLabelGap
  71  * @playground xAxis.tickLabelRotation (min=-180,max=180,step=1)
  72  * @playground xAxis.tickLabelsVisible
  73  * @playground xAxis.tickLength
  74  * @playground xAxis.tickMarkVisible

  75  * @playground - (name="yAxis")
  76  * @playground yAxis.autoRanging
  77  * @playground yAxis.gapStartAndEnd
  78  * @playground yAxis.startMargin
  79  * @playground yAxis.endMargin

  80  * @playground yAxis.animated
  81  * @playground yAxis.label
  82  * @playground yAxis.side
  83  * @playground yAxis.tickLabelFill
  84  * @playground yAxis.tickLabelGap
  85  * @playground yAxis.tickLabelRotation (min=-180,max=180,step=1)
  86  * @playground yAxis.tickLabelsVisible
  87  * @playground yAxis.tickLength
  88  * @playground yAxis.tickMarkVisible

  89  * @playground - (name="chart")
  90  * @playground chart.horizontalGridLinesVisible
  91  * @playground chart.horizontalZeroLineVisible
  92  * @playground chart.verticalGridLinesVisible
  93  * @playground chart.verticalZeroLineVisible

  94  * @playground chart.animated
  95  * @playground chart.legendSide
  96  * @playground chart.legendVisible
  97  * @playground chart.title
  98  * @playground chart.titleSide
  99  */
 100 public class HorizontalBarChartApp extends Application {
 101 
 102     private BarChart<Number, String> chart;
 103     private NumberAxis xAxis;
 104     private CategoryAxis yAxis;
 105 
 106     public Parent createContent() {
 107         final String[] years = {"2007", "2008", "2009"};
 108         xAxis = new NumberAxis();
 109         yAxis = new CategoryAxis();
 110         chart = new BarChart<>(xAxis, yAxis);
 111         chart.setTitle("Horizontal Bar Chart Example");
 112         yAxis.setLabel("Year");
 113         yAxis.setCategories(FXCollections.<String>observableArrayList(Arrays