Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.java4less.rchart
Class BarPlotter

    java.lang.Object
      |
      +--com.java4less.rchart.ChartComponent
            |
            +--com.java4less.rchart.Plotter
                  |
                  +--com.java4less.rchart.BarPlotter

public class BarPlotter
extends Plotter

    Plotter used to draw a bar chart. It only accepts DataSeries of type BarDataSerie.

    Example of use:

    // data
    double[] d1={1,2,3,4,5,4,2};
    BarDataSerie data1= new BarDataSerie(d1,new FillStyle(GraphicsProvider.getColor(ChartColor.CYAN)));
    data1.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL);
    //data1.borderType=BarDataSerie.BORDER_RAISED;
    data1.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL);
    data1.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10);

    double[] d2={-2,3,4,4.2,6.4,4.5,6.1};
    BarDataSerie data2= new BarDataSerie(d2,new FillStyle(GraphicsProvider.getColor(ChartColor.GREEN)));
    data2.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10);
    data2.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL);
    data2.negativeStyle=new FillStyle(GraphicsProvider.getColor(ChartColor.RED));

    Legend l=new Legend();
    l.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL);
    l.addItem("Company A",new FillStyle(GraphicsProvider.getColor(ChartColor.CYAN)));
    l.addItem("Company B",new FillStyle(GraphicsProvider.getColor(ChartColor.GREEN)));

    // create title
    Title title=new Title("Benefits companies A & B");
    // create axis
    Axis  XAxis=new Axis(Axis.HORIZONTAL,new Scale());
    Axis  YAxis=new Axis(Axis.VERTICAL,new Scale());
    XAxis.tickAtBase=true; // draw also first tick
    XAxis.scale.min=-3;
    XAxis.scale.max=7;
    YAxis.scale.min=0;
    YAxis.scale.max=7;
    YAxis.IntegerScale=true;
    YAxis.scaleTickInterval=1;
    XAxis.scaleTickInterval=1;
    XAxis.gridStyle=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.WHITE),LineStyle.LINE_DOTS);
    YAxis.gridStyle=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.WHITE),LineStyle.LINE_DOTS);
    String[] lbls={"1998","1999","2000","2001","2002","2003","2004","2005"};
    YAxis.tickLabels=lbls;

    HAxisLabel XLabel= new HAxisLabel("million $",GraphicsProvider.getColor(ChartColor.BLACK),GraphicsProvider.getFont("Arial",ChartFont.BOLD,12));
    VAxisLabel YLabel= new VAxisLabel("Year",GraphicsProvider.getColor(ChartColor.BLACK),GraphicsProvider.getFont("Arial",ChartFont.BOLD,12));

    // plotter
    BarPlotter plot=new BarPlotter();
    plot.verticalBars=false;
    plot.interBarSpace=0;

    // create chart
    Chart chart=new Chart(title,plot,XAxis,YAxis);
    chart.XLabel=XLabel;
    chart.YLabel=YLabel;
    chart.legend=l;
    chart.addSerie(data2);
    chart.addSerie(data1);
    chart.back=new FillStyle(GraphicsProvider.getColor(ChartColor.LIGHTGRAY));

Field Summary
`boolean` | `barAtAxis` first bar at the axis
`double` | `barsBase` start bars at this position
`int` | `barWidth` Width of the bar.
`boolean` | `cumulative` If true the bars will be display on the top of each other to create a stack bar chart.
`boolean` | `cumulativeBackwardsCompatible` leave it to the default (false) unless you are upgrading your version of RChart and you want the values not to be automatically acumulated.
`boolean` | `eventChart` set it to true if you want to draw event charts.
`int` | `interBarSpace` space between two bars (pixels).
`double` | `InterGroupSpace` space between two groups of bars (pixels).
`boolean` | `summedLabels` if true labels will be the summed values of the bars
`boolean` | `verticalBars` this fields indicates whether bars (horizontal) or columns (vertical) should be used.

Fields inherited from class com.java4less.rchart.Plotter
`back, backImage, depth, visibleHeight, visibleWidth, XScale, Y2Scale, YScale`

Fields inherited from class com.java4less.rchart.ChartComponent
`height, width, x, y`

Constructor Summary
`BarPlotter()`

Method Summary
`void` | `addSerie(DataSerie s)` adds a serie to the plotter.

Methods inherited from class com.java4less.rchart.Plotter
`getCombinable, getNeedsAxis, getSerie, getSeriesCount, plot, plotBackground, replaceSerie, setSerie`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### verticalBars

    public boolean verticalBars

  this fields indicates whether bars (horizontal) or columns (vertical) should be used.

### barWidth

    public int barWidth

  Width of the bar. This will be automatically calculated if not specified (pixels).

### interBarSpace

    public int interBarSpace

  space between two bars (pixels).

### InterGroupSpace

    public double InterGroupSpace

  space between two groups of bars (pixels). This will be automatically calculated if not specified.

### cumulative

    public boolean cumulative

  If true the bars will be display on the top of each other to create a stack bar chart. Previous versions of RChart do not acumulate the values. the current version will automatically acumulate the values. If you don't want this to happen set cumulativeBackwardsCompatible

### summedLabels

    public boolean summedLabels

  if true labels will be the summed values of the bars

### eventChart

    public boolean eventChart

  set it to true if you want to draw event charts. E

### barsBase

    public double barsBase

  start bars at this position

### cumulativeBackwardsCompatible

    public boolean cumulativeBackwardsCompatible

  leave it to the default (false) unless you are upgrading your version of RChart and you want the values not to be automatically acumulated. See cumulative.

### barAtAxis

    public boolean barAtAxis

  first bar at the axis

Constructor Detail

### BarPlotter

    public BarPlotter()

Method Detail

### addSerie

    public void addSerie(DataSerie s)

  adds a serie to the plotter. Only BarDataSerie are allowed.

  Overrides:
    `addSerie` in class `Plotter`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD