Class BarSeries


  • public class BarSeries
    extends GeneralBarSeries
    The most basic form of Bar series, this can be used to plot bars to a graph like so:
      AxesGraph graph = new AxesGraph();
      BarSeries series = new BarSeries("Fruit");
      series.set("Apples", 10);
      series.set("Oranges", 13);
      graph.addSeries(series);
     
    Adding a BarSeries to an AxesGraph will typically result in the X-axis being set to a BarAxis, and the default ordering of the bars is the order they're added to the Series.

    Internally values in a Bar Series are treated as numbers, the same as all the other series. So, for instance, in the example above "Apples" is 0 and "Oranges" is 1. Then the BarAxis formats those numbers to display the correct text. This becomes important to know when adding Markers to the graph using the Series.addMarker method. For instance, to display some text above the "Apples" bar in the example above, you would call something like series.addMarker(new Text("Text", style), 0, 12)

    • Constructor Detail

      • BarSeries

        public BarSeries​(String name)
        Create a new BarSeries
        Parameters:
        name - the name of the series
    • Method Detail

      • set

        public void set​(String name,
                        double height)
        Add a bar to the series. If the BarSeries already contains a bar with that series in it, it's value will be overwritten. If you really need two bars with the same name on the series you can add a space to the end of the name, eg.
          barseries.set("Apples", 10);
          barseries.set("Apples ", 10);
         
        Parameters:
        name - the name of the bar
        height - the value of the bar
      • set

        public void set​(String name,
                        double min,
                        double max)
        Add a bar to the series, which does not necessarily have to start at y=0. This can be used to create "floating" bars.
        Parameters:
        name - the name of the bar
        min - the bottom-most Y co-ordinate of the bar
        max - the top-most Y co-ordinate of the bar